feat/CUS-11476-Added class to store the count matching regex#360
Conversation
📝 WalkthroughWalkthroughThe pull request updates the Maven artifact version to 1.0.7 and introduces new regex action classes for extracting and counting pattern matches across multiple platforms (Android, iOS, Desktop, Web, Mobile Web). Additionally, existing occurrence-based regex actions are updated to remove platform-specific language from their messaging output. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (14)
validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/ios/StoreMatchingRegexValueInAVariableOccurrence.java (2)
6-6: Remove unused importWebAction.The class extends
IOSAction, making theWebActionimport unnecessary.♻️ Proposed fix
import com.testsigma.sdk.IOSAction; import com.testsigma.sdk.Result; -import com.testsigma.sdk.WebAction; import com.testsigma.sdk.annotation.Action;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/ios/StoreMatchingRegexValueInAVariableOccurrence.java` at line 6, Remove the unused import com.testsigma.sdk.WebAction from the top of the file; the class StoreMatchingRegexValueInAVariableOccurrence already extends IOSAction so WebAction is not referenced—delete the import line and run a quick compile or organize/imports to ensure no other unused imports remain.
76-76: ReplaceSystem.out.printlnwith logger for consistency.Same issue as other platform variants—use
logger.info()instead.♻️ Proposed fix
- System.out.println("Matched string : " + matchedString); + logger.info("Matched string : " + matchedString);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/ios/StoreMatchingRegexValueInAVariableOccurrence.java` at line 76, Replace the System.out.println call in StoreMatchingRegexValueInAVariableOccurrence (the line printing "Matched string : " + matchedString) with logger.info(...) for consistency with other variants; use the existing logger instance (or add a private static final Logger logger if missing) and format the message the same way ("Matched string : " + matchedString) so logging is consistent across platforms.validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/RegExPatternMatch.java (3)
63-68: Remove commented-out code.Commented-out
mainmethod should be deleted to keep the codebase clean.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/RegExPatternMatch.java` around lines 63 - 68, Remove the commented-out main method block inside the RegExPatternMatch class (the multi-line comment that contains "public static void main" and the MyFirstWebAction setup lines) to clean up dead code; locate the commented snippet in RegExPatternMatch.java and delete the entire commented section including its opening /* and closing */ so no leftover commented test code remains.
33-34: Remove duplicate logging.Test data and regex pattern are logged at lines 33-34, then again at lines 40-41.
Also applies to: 40-41
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/RegExPatternMatch.java` around lines 33 - 34, The code currently logs testData and regExPattern twice in RegExPatternMatch (logger.info("Test Data::" + testData.getValue()) and logger.info("RegEx Pattern::" + regExPattern.getValue()) appear at both sets of lines); remove the duplicate pair so each value is logged only once (keep one pair of logger.info calls referencing testData.getValue() and regExPattern.getValue(), and delete the other), ensuring the logger variable and surrounding method behavior (in RegExPatternMatch) remain unchanged.
36-54: Simplify result handling—resultvariable is unused.Since both branches return immediately, the
resultvariable assignment on lines 36, 51, and 56 is redundant.♻️ Proposed simplification
- com.testsigma.sdk.Result result = com.testsigma.sdk.Result.SUCCESS; - try { logger.info("Compiling the regex pattern and matching with the test data"); - logger.info("Pattern::" + regExPattern.getValue().toString()); - logger.info("Test Data::" + testData.getValue().toString()); Pattern pattern = Pattern.compile(regExPattern.getValue().toString()); logger.info("Pattern compiled successfully"); Matcher matcher = pattern.matcher(testData.getValue().toString()); logger.info("Matcher created successfully"); if (matcher.matches()) { setSuccessMessage("The input string matches the pattern."); return Result.SUCCESS; } else { - result = com.testsigma.sdk.Result.FAILED; setErrorMessage("The input string does not match the pattern."); - return result; + return Result.FAILED; } } catch (Exception error) { - result = com.testsigma.sdk.Result.FAILED; logger.info(" Exception occurred while executing the action::" + ExceptionUtils.getStackTrace(error)); setErrorMessage("Exception occurred while executing the action::" + error.getMessage()); - return result; + return Result.FAILED; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/RegExPatternMatch.java` around lines 36 - 54, The local variable result in RegExPatternMatch is unused because both branches return immediately; remove the declaration "com.testsigma.sdk.Result result = com.testsigma.sdk.Result.SUCCESS;" and any assignments to result (e.g., where it’s set to com.testsigma.sdk.Result.FAILED) and instead directly return Result.FAILED in the failing branch (leave the success branch returning Result.SUCCESS). Update the code around Pattern.compile, Matcher matcher = pattern.matcher(...), and the if (matcher.matches()) block accordingly to eliminate the redundant variable.validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariable.java (1)
38-38: Use camelCase for local variables.
Regexshould beregexto follow Java naming conventions.♻️ Proposed fix
- String Regex = regex.getValue().toString(); + String regexValue = regex.getValue().toString();Update subsequent usages (lines 42, 46) accordingly.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariable.java` at line 38, In StoreMatchingRegexValueInAVariable, rename the local variable "Regex" to follow Java camelCase (e.g., "regex") where it's assigned from regex.getValue().toString(), and update all subsequent usages in this class/method (references to "Regex" later in the method) to the new name to keep naming consistent and compile correctly.validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/android/StoreMatchingRegexValueInAVariableOccurrence.java (2)
6-6: Remove unused importWebAction.The class extends
AndroidAction, making theWebActionimport unnecessary.♻️ Proposed fix
import com.testsigma.sdk.ApplicationType; import com.testsigma.sdk.Result; -import com.testsigma.sdk.WebAction; import com.testsigma.sdk.annotation.Action;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/android/StoreMatchingRegexValueInAVariableOccurrence.java` at line 6, Remove the unused import "com.testsigma.sdk.WebAction" from the top of the file; the class StoreMatchingRegexValueInAVariableOccurrence already extends AndroidAction so the WebAction import is unnecessary—delete the import line to clean up unused dependencies.
76-76: ReplaceSystem.out.printlnwith logger for consistency.Same issue as other platform variants—use
logger.info()instead.♻️ Proposed fix
- System.out.println("Matched string : " + matchedString); + logger.info("Matched string : " + matchedString);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/android/StoreMatchingRegexValueInAVariableOccurrence.java` at line 76, Replace the direct stdout call with the class logger: in StoreMatchingRegexValueInAVariableOccurrence where System.out.println("Matched string : " + matchedString) is used, change it to use the class logger (logger.info) and log the matchedString with the same message format; ensure you reference the existing logger instance in that class and remove the System.out.println call so logging is consistent across platform variants.validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/mobile_web/StoreMatchingRegexValueInAVariableOccurrence.java (2)
75-75: ReplaceSystem.out.printlnwith logger for consistency.The codebase uses
logger.info()elsewhere for output. UsingSystem.out.printlnbypasses the logging framework, making it harder to control log levels and capture output in test reports.♻️ Proposed fix
- System.out.println("Matched string : " + matchedString); + logger.info("Matched string : " + matchedString);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/mobile_web/StoreMatchingRegexValueInAVariableOccurrence.java` at line 75, Replace the direct System.out.println call in StoreMatchingRegexValueInAVariableOccurrence (the line printing "Matched string : " + matchedString) with the project's logger API—use logger.info with the same message format so logs go through the logging framework and respect log levels; locate the print in the method where matchedString is produced and swap it to logger.info("Matched string : " + matchedString) (or the equivalent string formatting used elsewhere) to keep output consistent.
46-47: Consider validatingoccurrenceValuefor edge cases.
Integer.parseIntwill throwNumberFormatExceptionfor non-integer inputs, which is caught by the genericExceptionhandler. However, there's no validation for invalid occurrence values (e.g., 0 or negative numbers), which would silently result in no match being found.💡 Proposed validation
int occurrenceValue = Integer.parseInt(occurrence.getValue().toString()); + if (occurrenceValue <= 0) { + setErrorMessage("Occurrence value must be a positive integer"); + return Result.FAILED; + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/mobile_web/StoreMatchingRegexValueInAVariableOccurrence.java` around lines 46 - 47, Validate and explicitly handle the occurrence parsing and edge cases: replace the plain Integer.parseInt(occurrence.getValue().toString()) use in StoreMatchingRegexValueInAVariableOccurrence with a guarded parse that catches NumberFormatException (so you don't swallow it under the generic Exception block) and then check the parsed occurrenceValue is >= 1; if the value is non-numeric, zero, or negative, throw or return a clear validation error (e.g., IllegalArgumentException or a step-fail with a descriptive message) so invalid inputs don't silently produce no matches.validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/Regex.java (1)
3-4: Remove unused imports.
ResultandExceptionUtilsare imported but not used.♻️ Proposed fix
package com.testsigma.addons.web; -import com.testsigma.sdk.Result; -import org.apache.commons.lang3.exception.ExceptionUtils; - import java.util.regex.Matcher; import java.util.regex.Pattern;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/Regex.java` around lines 3 - 4, The imports com.testsigma.sdk.Result and org.apache.commons.lang3.exception.ExceptionUtils are unused in the Regex class; remove those unused import lines to clean up the file and avoid compiler/lint warnings—locate the import block at the top of Regex.java and delete the two import statements referencing Result and ExceptionUtils.validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/StoreMatchingRegexValueInAVariableOccurrence.java (1)
75-75: ReplaceSystem.out.printlnwith logger for consistency.Same issue as other platform variants—use
logger.info()instead.♻️ Proposed fix
- System.out.println("Matched string : " + matchedString); + logger.info("Matched string : " + matchedString);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/StoreMatchingRegexValueInAVariableOccurrence.java` at line 75, Replace the System.out.println call in StoreMatchingRegexValueInAVariableOccurrence (the line printing "Matched string : " + matchedString) with the class logger; remove the println and call logger.info to log the matchedString (e.g., logger.info(...)) and ensure the class has a proper Logger instance (e.g., a private static final Logger logger = LoggerFactory.getLogger(StoreMatchingRegexValueInAVariableOccurrence.class) or equivalent) so logging is consistent with other platform variants.validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/RegExPatternMatch.java (1)
58-63: Remove commented-out test harness code from production action class.Line 58–63 is dead commented code and should be removed for maintainability.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/RegExPatternMatch.java` around lines 58 - 63, Remove the dead commented test-harness block (the commented-out main method that instantiates MyFirstWebAction and calls setTestData, setRegExPattern, and execute) from the RegExPatternMatch.java production action class; simply delete the entire commented section so the class contains only the production code and no leftover test scaffolding (look for the commented "public static void main" block referencing MyFirstWebAction, setTestData, setRegExPattern, and execute).validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariableOccurrence.java (1)
76-76: Use framework logger instead ofSystem.out.println.Line 76 should use
loggerto keep logging consistent and controllable.Proposed fix
- System.out.println("Matched string : " + matchedString); + logger.info("Matched string stored in runtime variable '{}'", varName);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariableOccurrence.java` at line 76, Replace the direct System.out.println call in StoreMatchingRegexValueInAVariableOccurrence that prints "Matched string : " + matchedString with the framework logger (use the existing logger instance in the class) so logs follow the project's logging strategy; call logger.info (or logger.debug if this is verbose) and include matchedString in the log message (use parameterized logging if supported).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/RegExPatternMatch.java`:
- Around line 34-35: In RegExPatternMatch, avoid logging raw test payloads from
testData.getValue() and regExPattern.getValue(); replace the two
logger.info(...) calls with logging that either omits the full values (log only
that values were received or their lengths/types) or logs redacted/masked
versions (e.g., replace characters with asterisks or call a sanitize/mask helper
like maskSensitive(value)) and/or lower-severity debug without actual contents;
update references to testData.getValue() and regExPattern.getValue() accordingly
to ensure no sensitive content is written to logs.
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariable.java`:
- Around line 59-65: The catch block in StoreMatchingRegexValueInAVariable
currently logs the exception and sets an error message but leaves the local
result variable as Result.SUCCESS, causing the method to incorrectly report
success; update the catch block in the method (where
logger.debug(e.getMessage()) and setErrorMessage(...) are called) to set result
= Result.FAILED (or return Result.FAILED) and include the exception details in
the log/error message so failures are propagated correctly.
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariableOccurrence.java`:
- Around line 49-52: The three logger.info lines in
StoreMatchingRegexValueInAVariableOccurrence that print inputData, regexValue,
and varName must not emit raw values; replace them with either no-op or
sanitized/masked logging (e.g., log only lengths, types, or a fixed placeholder)
and/or lower the level to debug if non-sensitive telemetry is required;
specifically update the references to inputData, regexValue, and varName so the
logger does not output actual payloads (mask values, log "REDACTED" or
value.length(), or remove the logs entirely).
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/Regex.java`:
- Around line 1-24: The class Regex contains a standalone main method with
hardcoded test values (Pattern/Matcher usage) that is not part of the Testsigma
addon framework; remove the main method or relocate this test code to the test
sources (e.g., unit test class) so the production class Regex only contains
framework-relevant logic, ensure you delete the main(String[] args) method and
any test-only imports/usages (Pattern/Matcher test block) from the Regex class.
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/StoreMatchingRegexCountValue.java`:
- Around line 44-47: The logger.info calls in StoreMatchingRegexCountValue that
print inputData and regexValue expose raw payloads; replace those direct logs
with non-sensitive summaries (e.g., log only varName, lengths, a hash or masked
version of inputData and regexValue, or a boolean indicating presence) and/or
remove them entirely; update the logging lines referencing logger.info,
inputData, regexValue and varName so they do not emit raw content but instead
emit safe metadata (lengths, truncated/masked strings, or hashes) to preserve
useful info without leaking sensitive data.
---
Nitpick comments:
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/android/StoreMatchingRegexValueInAVariableOccurrence.java`:
- Line 6: Remove the unused import "com.testsigma.sdk.WebAction" from the top of
the file; the class StoreMatchingRegexValueInAVariableOccurrence already extends
AndroidAction so the WebAction import is unnecessary—delete the import line to
clean up unused dependencies.
- Line 76: Replace the direct stdout call with the class logger: in
StoreMatchingRegexValueInAVariableOccurrence where System.out.println("Matched
string : " + matchedString) is used, change it to use the class logger
(logger.info) and log the matchedString with the same message format; ensure you
reference the existing logger instance in that class and remove the
System.out.println call so logging is consistent across platform variants.
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/RegExPatternMatch.java`:
- Around line 58-63: Remove the dead commented test-harness block (the
commented-out main method that instantiates MyFirstWebAction and calls
setTestData, setRegExPattern, and execute) from the RegExPatternMatch.java
production action class; simply delete the entire commented section so the class
contains only the production code and no leftover test scaffolding (look for the
commented "public static void main" block referencing MyFirstWebAction,
setTestData, setRegExPattern, and execute).
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariable.java`:
- Line 38: In StoreMatchingRegexValueInAVariable, rename the local variable
"Regex" to follow Java camelCase (e.g., "regex") where it's assigned from
regex.getValue().toString(), and update all subsequent usages in this
class/method (references to "Regex" later in the method) to the new name to keep
naming consistent and compile correctly.
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariableOccurrence.java`:
- Line 76: Replace the direct System.out.println call in
StoreMatchingRegexValueInAVariableOccurrence that prints "Matched string : " +
matchedString with the framework logger (use the existing logger instance in the
class) so logs follow the project's logging strategy; call logger.info (or
logger.debug if this is verbose) and include matchedString in the log message
(use parameterized logging if supported).
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/ios/StoreMatchingRegexValueInAVariableOccurrence.java`:
- Line 6: Remove the unused import com.testsigma.sdk.WebAction from the top of
the file; the class StoreMatchingRegexValueInAVariableOccurrence already extends
IOSAction so WebAction is not referenced—delete the import line and run a quick
compile or organize/imports to ensure no other unused imports remain.
- Line 76: Replace the System.out.println call in
StoreMatchingRegexValueInAVariableOccurrence (the line printing "Matched string
: " + matchedString) with logger.info(...) for consistency with other variants;
use the existing logger instance (or add a private static final Logger logger if
missing) and format the message the same way ("Matched string : " +
matchedString) so logging is consistent across platforms.
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/mobile_web/StoreMatchingRegexValueInAVariableOccurrence.java`:
- Line 75: Replace the direct System.out.println call in
StoreMatchingRegexValueInAVariableOccurrence (the line printing "Matched string
: " + matchedString) with the project's logger API—use logger.info with the same
message format so logs go through the logging framework and respect log levels;
locate the print in the method where matchedString is produced and swap it to
logger.info("Matched string : " + matchedString) (or the equivalent string
formatting used elsewhere) to keep output consistent.
- Around line 46-47: Validate and explicitly handle the occurrence parsing and
edge cases: replace the plain Integer.parseInt(occurrence.getValue().toString())
use in StoreMatchingRegexValueInAVariableOccurrence with a guarded parse that
catches NumberFormatException (so you don't swallow it under the generic
Exception block) and then check the parsed occurrenceValue is >= 1; if the value
is non-numeric, zero, or negative, throw or return a clear validation error
(e.g., IllegalArgumentException or a step-fail with a descriptive message) so
invalid inputs don't silently produce no matches.
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/Regex.java`:
- Around line 3-4: The imports com.testsigma.sdk.Result and
org.apache.commons.lang3.exception.ExceptionUtils are unused in the Regex class;
remove those unused import lines to clean up the file and avoid compiler/lint
warnings—locate the import block at the top of Regex.java and delete the two
import statements referencing Result and ExceptionUtils.
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/RegExPatternMatch.java`:
- Around line 63-68: Remove the commented-out main method block inside the
RegExPatternMatch class (the multi-line comment that contains "public static
void main" and the MyFirstWebAction setup lines) to clean up dead code; locate
the commented snippet in RegExPatternMatch.java and delete the entire commented
section including its opening /* and closing */ so no leftover commented test
code remains.
- Around line 33-34: The code currently logs testData and regExPattern twice in
RegExPatternMatch (logger.info("Test Data::" + testData.getValue()) and
logger.info("RegEx Pattern::" + regExPattern.getValue()) appear at both sets of
lines); remove the duplicate pair so each value is logged only once (keep one
pair of logger.info calls referencing testData.getValue() and
regExPattern.getValue(), and delete the other), ensuring the logger variable and
surrounding method behavior (in RegExPatternMatch) remain unchanged.
- Around line 36-54: The local variable result in RegExPatternMatch is unused
because both branches return immediately; remove the declaration
"com.testsigma.sdk.Result result = com.testsigma.sdk.Result.SUCCESS;" and any
assignments to result (e.g., where it’s set to com.testsigma.sdk.Result.FAILED)
and instead directly return Result.FAILED in the failing branch (leave the
success branch returning Result.SUCCESS). Update the code around
Pattern.compile, Matcher matcher = pattern.matcher(...), and the if
(matcher.matches()) block accordingly to eliminate the redundant variable.
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/StoreMatchingRegexValueInAVariableOccurrence.java`:
- Line 75: Replace the System.out.println call in
StoreMatchingRegexValueInAVariableOccurrence (the line printing "Matched string
: " + matchedString) with the class logger; remove the println and call
logger.info to log the matchedString (e.g., logger.info(...)) and ensure the
class has a proper Logger instance (e.g., a private static final Logger logger =
LoggerFactory.getLogger(StoreMatchingRegexValueInAVariableOccurrence.class) or
equivalent) so logging is consistent with other platform variants.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7b6561a6-3de8-4e1d-a476-8819bb9d767f
📒 Files selected for processing (15)
validate_data_with_regex_pattern/pom.xmlvalidate_data_with_regex_pattern/src/main/java/com/testsigma/addons/android/StoreMatchingRegexCountValue.javavalidate_data_with_regex_pattern/src/main/java/com/testsigma/addons/android/StoreMatchingRegexValueInAVariableOccurrence.javavalidate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/RegExPatternMatch.javavalidate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexCountValue.javavalidate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariable.javavalidate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariableOccurrence.javavalidate_data_with_regex_pattern/src/main/java/com/testsigma/addons/ios/StoreMatchingRegexCountValue.javavalidate_data_with_regex_pattern/src/main/java/com/testsigma/addons/ios/StoreMatchingRegexValueInAVariableOccurrence.javavalidate_data_with_regex_pattern/src/main/java/com/testsigma/addons/mobile_web/StoreMatchingRegexCountValue.javavalidate_data_with_regex_pattern/src/main/java/com/testsigma/addons/mobile_web/StoreMatchingRegexValueInAVariableOccurrence.javavalidate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/RegExPatternMatch.javavalidate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/Regex.javavalidate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/StoreMatchingRegexCountValue.javavalidate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/StoreMatchingRegexValueInAVariableOccurrence.java
| logger.info("Test Data::"+testData.getValue()); | ||
| logger.info("RegEx Pattern::"+regExPattern.getValue()); |
There was a problem hiding this comment.
Do not log raw test payloads.
Line 34–35 logs raw input and regex values, which can leak sensitive test data.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/RegExPatternMatch.java`
around lines 34 - 35, In RegExPatternMatch, avoid logging raw test payloads from
testData.getValue() and regExPattern.getValue(); replace the two
logger.info(...) calls with logging that either omits the full values (log only
that values were received or their lengths/types) or logs redacted/masked
versions (e.g., replace characters with asterisks or call a sanitize/mask helper
like maskSensitive(value)) and/or lower-severity debug without actual contents;
update references to testData.getValue() and regExPattern.getValue() accordingly
to ensure no sensitive content is written to logs.
| } | ||
| catch(Exception e) { | ||
| logger.debug(e.getMessage()); | ||
| setErrorMessage("Failed to perform operation "+e.getMessage()+e.getCause()); | ||
| } | ||
|
|
||
| return result; |
There was a problem hiding this comment.
Critical bug: Method returns SUCCESS even when an exception occurs.
When an exception is caught, the error message is set but result remains Result.SUCCESS (set at line 44). The method then returns this success result, masking the failure.
🐛 Proposed fix
catch(Exception e) {
logger.debug(e.getMessage());
setErrorMessage("Failed to perform operation "+e.getMessage()+e.getCause());
+ return Result.FAILED;
}
-
- return result;
+ return Result.SUCCESS;
}Or alternatively, set result = Result.FAILED in the catch block.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariable.java`
around lines 59 - 65, The catch block in StoreMatchingRegexValueInAVariable
currently logs the exception and sets an error message but leaves the local
result variable as Result.SUCCESS, causing the method to incorrectly report
success; update the catch block in the method (where
logger.debug(e.getMessage()) and setErrorMessage(...) are called) to set result
= Result.FAILED (or return Result.FAILED) and include the exception details in
the log/error message so failures are propagated correctly.
| logger.info("Input data : " + inputData); | ||
| logger.info("Regex : " + regexValue); | ||
| logger.info("Runtime variable name : " + varName); | ||
|
|
There was a problem hiding this comment.
Avoid logging raw input/regex values.
Line 49–51 logs full payload data and can leak sensitive values in execution logs.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariableOccurrence.java`
around lines 49 - 52, The three logger.info lines in
StoreMatchingRegexValueInAVariableOccurrence that print inputData, regexValue,
and varName must not emit raw values; replace them with either no-op or
sanitized/masked logging (e.g., log only lengths, types, or a fixed placeholder)
and/or lower the level to debug if non-sensitive telemetry is required;
specifically update the references to inputData, regexValue, and varName so the
logger does not output actual payloads (mask values, log "REDACTED" or
value.length(), or remove the logs entirely).
| package com.testsigma.addons.web; | ||
|
|
||
| import com.testsigma.sdk.Result; | ||
| import org.apache.commons.lang3.exception.ExceptionUtils; | ||
|
|
||
| import java.util.regex.Matcher; | ||
| import java.util.regex.Pattern; | ||
|
|
||
| public class Regex | ||
| { | ||
| public static void main(String[] args) { | ||
| try { | ||
| Pattern pattern = Pattern.compile("^[A-Za-z]+$"); | ||
| Matcher matcher = pattern.matcher("HelloWorld"); | ||
| if (matcher.matches()) { | ||
| System.out.println("The input string matches the pattern."); | ||
| } else { | ||
| System.out.println("The input string does not match the pattern."); | ||
| } | ||
| } catch (Exception error) { | ||
| System.out.println("Exception occurred while executing the action::" + error.getMessage()); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
This appears to be test/debug code—consider removing.
This standalone main method class with hardcoded values doesn't integrate with the Testsigma addon framework and seems to serve no production purpose. If this was used for local testing, it should be removed or moved to the test directory.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/Regex.java`
around lines 1 - 24, The class Regex contains a standalone main method with
hardcoded test values (Pattern/Matcher usage) that is not part of the Testsigma
addon framework; remove the main method or relocate this test code to the test
sources (e.g., unit test class) so the production class Regex only contains
framework-relevant logic, ensure you delete the main(String[] args) method and
any test-only imports/usages (Pattern/Matcher test block) from the Regex class.
| logger.info("Input data : " + inputData); | ||
| logger.info("Regex : " + regexValue); | ||
| logger.info("Runtime variable name : " + varName); | ||
|
|
There was a problem hiding this comment.
Avoid logging raw input and regex content.
Line 44–46 logs full payloads. This can expose sensitive data in execution logs.
Proposed fix
- logger.info("Input data : " + inputData);
- logger.info("Regex : " + regexValue);
- logger.info("Runtime variable name : " + varName);
+ logger.info("Regex match count request received. inputLength=" + inputData.length()
+ + ", runtimeVariable=" + varName);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| logger.info("Input data : " + inputData); | |
| logger.info("Regex : " + regexValue); | |
| logger.info("Runtime variable name : " + varName); | |
| logger.info("Regex match count request received. inputLength=" + inputData.length() | |
| ", runtimeVariable=" + varName); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/StoreMatchingRegexCountValue.java`
around lines 44 - 47, The logger.info calls in StoreMatchingRegexCountValue that
print inputData and regexValue expose raw payloads; replace those direct logs
with non-sensitive summaries (e.g., log only varName, lengths, a hash or masked
version of inputData and regexValue, or a boolean indicating presence) and/or
remove them entirely; update the logging lines referencing logger.info,
inputData, regexValue and varName so they do not emit raw content but instead
emit safe metadata (lengths, truncated/masked strings, or hashes) to preserve
useful info without leaking sensitive data.
Publish this addon as PUBLIC
Addon Name: Validate data with regex pattern
Jarvis Link: https://jarvis.testsigma.com/ui/tenants/2817/addons
Jira : https://testsigma.atlassian.net/browse/CUS-11476
Added class to store the count matching regex
Summary by CodeRabbit
Release Notes
New Features
Improvements