-
Notifications
You must be signed in to change notification settings - Fork 16
feat/TE-29332-Added all ready present class to other applications #214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat/TE-29332-Added all ready present class to other applications #214
Conversation
WalkthroughAdds a new Maven module "store_string_lengths_split_by_a_delimiter" and multiple platform-specific actions (REST API, Web, Android, iOS, Mobile Web, Windows) that split an input string by a delimiter, count segments, store the count in runtime data, and include a testsigma-sdk properties file. Changes
Sequence Diagram(s)sequenceDiagram
actor User as Test author
participant Runtime as Test runtime
participant Action as SplitString Action
participant RunTimeData as RunTimeData store
User->>Runtime: Provide inputs (testdata, delimeter, variable)
Runtime->>Action: execute()
rect rgba(220,235,245,0.6)
Action->>Action: parts = testdata.split(delimeter)
Action->>Action: count = parts.length
Action->>RunTimeData: set(variable, String.valueOf(count))
Note right of Action: log inputs & result
end
Action-->>Runtime: Result.SUCCESS (with message)
alt Exception
Action->>Action: catch(Exception)
Action-->>Runtime: Result.FAILED (error message)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 OSV Scanner (2.1.0)Error: Cloning the repository previously failed. Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 12
♻️ Duplicate comments (1)
store_string_lengths_split_by_a_delimiter/pom.xml (1)
47-58: Align Selenium and Appium versions as requested by reviewerPer prior feedback, please bump Selenium and Appium versions (and keep them compatible).
Apply this diff:
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> - <version>4.14.1</version> + <version>4.33.0</version> </dependency> <!-- https://mvnrepository.com/artifact/io.appium/java-client --> <dependency> <groupId>io.appium</groupId> <artifactId>java-client</artifactId> - <version>9.0.0</version> + <version>9.4.0</version> </dependency>Please confirm these work with the Testsigma SDK version you’re using.
🧹 Nitpick comments (27)
store_string_lengths_split_by_a_delimiter/pom.xml (2)
16-21: Modernize dependency versions (JUnit, Lombok) — optionalCurrent JUnit (5.8.0-M1) is a 2021 milestone; Lombok 1.18.30 is fine but could be bumped. Not critical if this module doesn’t run tests here.
Apply this diff to properties:
- <junit.jupiter.version>5.8.0-M1</junit.jupiter.version> - <lombok.version>1.18.30</lombok.version> + <junit.jupiter.version>5.10.3</junit.jupiter.version> + <lombok.version>1.18.34</lombok.version>Also consider updating Jackson annotations to 2.17.x to align with typical transitive ecosystems:
- <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-annotations</artifactId> - <version>2.13.0</version> - </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + <version>2.17.2</version> + </dependency>
71-100: Avoid shading test dependencies into the runtime artifactYou’re shading everything without exclusions, which can bloat the addon jar with test frameworks. If TestNG/JUnit are test-scoped (or removed), this is less of an issue. Otherwise, exclude them from shading.
Example (only if test deps are not test-scoped):
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.2.4</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> + <configuration> + <filters> + <filter> + <artifact>org.testng:testng</artifact> + <excludes> + <exclude>**</exclude> + </excludes> + </filter> + <filter> + <artifact>org.junit.jupiter:junit-jupiter-api</artifact> + <excludes> + <exclude>**</exclude> + </excludes> + </filter> + </filters> + </configuration> </execution> </executions> </plugin>store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/API/MyFirstWebAction.java (2)
1-1: Package name casing “API” is unconventional; prefer lowercase packagesJava packages are idiomatically lowercase. Consider renaming package com.testsigma.addons.API to com.testsigma.addons.api for consistency with web/windows packages.
This is a breaking change; if out of scope for this PR, you can defer. I can help generate a follow-up refactor PR if you want.
13-18: Fix spelling in user-facing text: “delimeter” → “delimiter”The action text/description are user-visible. Correct the typo while keeping the @testdata reference unchanged for backward compatibility.
-@Action(actionText = "Split the string testdata by delimeter and store the count of string into a runtime variable", - description = "This addon will Split the string testdata by delimeter and store the count of string into a runtime variable", +@Action(actionText = "Split the string testdata by delimiter and store the count of string into a runtime variable", + description = "This addon will split the string testdata by delimiter and store the count of string into a runtime variable", applicationType = ApplicationType.REST_API, useCustomScreenshot = false)store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/windows/SplitStringAction.java (1)
13-17: Fix spelling in user-facing text: “delimeter” → “delimiter”Adjust action text/description; keep the @testdata reference as-is to avoid breaking consumers.
-@Action(actionText = "Split the string testdata by delimeter and store the count of string into a runtime variable", - description = "This addon will Split the string testdata by delimeter and store the count of string into a runtime variable", +@Action(actionText = "Split the string testdata by delimiter and store the count of string into a runtime variable", + description = "This addon will split the string testdata by delimiter and store the count of string into a runtime variable", applicationType = ApplicationType.WINDOWS, useCustomScreenshot = false)store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/web/MyFirstWebAction.java (3)
13-18: Fix spelling in user-facing text: “delimeter” → “delimiter”Same nit in web action.
-@Action(actionText = "Split the string testdata by delimeter and store the count of string into a runtime variable", - description = "This addon will Split the string testdata by delimeter and store the count of string into a runtime variable", +@Action(actionText = "Split the string testdata by delimiter and store the count of string into a runtime variable", + description = "This addon will split the string testdata by delimiter and store the count of string into a runtime variable", applicationType = ApplicationType.WEB, useCustomScreenshot = false)
18-18: Class naming consistency across platformsWindows uses SplitStringAction; web/API use MyFirstWebAction. Consider renaming for consistency (e.g., SplitStringAction) unless external references rely on current names.
If you’d like, I can generate a follow-up change that unifies the names and updates the action metadata accordingly.
1-64: Reduce code duplication with a shared utilityThe three platform actions share identical core logic. You can extract it to a small shared helper to reduce duplication and drift.
Example new class (outside current diff):
package com.testsigma.addons.common; import java.util.regex.Pattern; public final class SplitStringUtils { private SplitStringUtils() {} public static int count(String input, String delimiter, boolean includeTrailingEmpty) { if (input == null || delimiter == null) return 0; return input.split(Pattern.quote(delimiter), includeTrailingEmpty ? -1 : 0).length; } }Then call SplitStringUtils.count(...) in each execute(), keeping platform-specific parts (logging, messages, RunTimeData) in place.
store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/android/SplitStringAction.java (7)
52-54: Reduce sensitive data in logs and success message; keep it succinct.Currently logs echo the full input string. Prefer logging the variable name and count only.
Apply this diff:
- logger.info("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res); - setSuccessMessage("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res); + logger.info("Stored segment count {} into runtime variable '{}'", res, runtimeVar.getValue()); + setSuccessMessage(String.format("Stored segment count %d into runtime variable '%s'", res, String.valueOf(runtimeVar.getValue())));
58-60: Improve exception logging and message formatting.Prefer structured logging and simpler error text.
Apply this diff:
- logger.warn("Exception while executing action - "+ ExceptionUtils.getStackTrace(e)); - setErrorMessage("Operation failed , the error message is ::::"+ExceptionUtils.getMessage(e)); + logger.warn("Exception while executing action", e); + setErrorMessage("Operation failed: " + ExceptionUtils.getMessage(e));
14-17: Typo and grammar in @action text.“delimeter” → “delimiter”; tighten phrasing. Keeping TestData key unchanged for compatibility.
Apply this diff:
-@Action(actionText = "Split the string testdata by delimeter and store the count of string into a runtime variable", - description = "This addon will Split the string testdata by delimeter and store the count of string into a runtime variable", +@Action(actionText = "Split the string testdata by delimiter and store the segment count into a runtime variable", + description = "This addon splits the string testdata by a delimiter and stores the segment count into a runtime variable", applicationType = ApplicationType.ANDROID, useCustomScreenshot = false)
40-43: Avoid concatenation and toString() on potentially null values.Use parameterized logging and String.valueOf to sidestep NPEs and reduce allocations.
Apply this diff:
- logger.debug("testdata => " + testData1.getValue().toString()); - logger.debug("delimeter => " + testData2.getValue().toString()); - logger.debug("Runtime_Variable => " + runtimeVar.getValue().toString()); + logger.debug("testdata => {}", testData1.getValue()); + logger.debug("delimeter => {}", testData2.getValue()); + logger.debug("Runtime_Variable => {}", runtimeVar.getValue());
11-11: Remove unused import.NoSuchElementException isn’t thrown; drop the import.
Apply this diff:
-import org.openqa.selenium.NoSuchElementException;
33-34: Simplify method signature by removing throws clause.The method doesn’t throw NoSuchElementException.
Apply this diff:
- public Result execute() throws NoSuchElementException + public Result execute()
18-64: Reduce duplication across platform actions.All platform classes replicate identical split/count/store logic. Extract the computation and validation into a shared utility (e.g., com.testsigma.addons.common.StringSplitUtils.segmentCount(String, String)) and call it from each action. This improves maintainability and ensures consistent behavior.
If you’d like, I can sketch a small utility class and update all actions accordingly.
store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/ios/SplitStringAction.java (6)
52-54: Avoid logging full input; log only what’s necessary.Apply this diff:
- logger.info("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res); - setSuccessMessage("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res); + logger.info("Stored segment count {} into runtime variable '{}'", res, runtimeVar.getValue()); + setSuccessMessage(String.format("Stored segment count %d into runtime variable '%s'", res, String.valueOf(runtimeVar.getValue())));
58-60: Use structured exception logging; tighten message.Apply this diff:
- logger.warn("Exception while executing action - "+ ExceptionUtils.getStackTrace(e)); - setErrorMessage("Operation failed , the error message is ::::"+ExceptionUtils.getMessage(e)); + logger.warn("Exception while executing action", e); + setErrorMessage("Operation failed: " + ExceptionUtils.getMessage(e));
14-17: Fix typos/grammar in @action text.Align wording and correct “delimeter”.
Apply this diff:
-@Action(actionText = "Split the string testdata by delimeter and store the count of string into a runtime variable", - description = "This addon will Split the string testdata by delimeter and store the count of string into a runtime variable", +@Action(actionText = "Split the string testdata by delimiter and store the segment count into a runtime variable", + description = "This addon splits the string testdata by a delimiter and stores the segment count into a runtime variable", applicationType = ApplicationType.IOS, useCustomScreenshot = false)
40-43: Prefer parameterized logging and null-safe value conversion.Apply this diff:
- logger.debug("testdata => " + testData1.getValue().toString()); - logger.debug("delimeter => " + testData2.getValue().toString()); - logger.debug("Runtime_Variable => " + runtimeVar.getValue().toString()); + logger.debug("testdata => {}", testData1.getValue()); + logger.debug("delimeter => {}", testData2.getValue()); + logger.debug("Runtime_Variable => {}", runtimeVar.getValue());
11-11: Remove unused import.NoSuchElementException isn’t thrown.
Apply this diff:
-import org.openqa.selenium.NoSuchElementException;
33-34: Drop unnecessary throws clause.Apply this diff:
- public Result execute() throws NoSuchElementException + public Result execute()store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/mobileweb/SplitStringAction.java (6)
52-54: Limit sensitive data in logs; simplify success message.Apply this diff:
- logger.info("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res); - setSuccessMessage("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res); + logger.info("Stored segment count {} into runtime variable '{}'", res, runtimeVar.getValue()); + setSuccessMessage(String.format("Stored segment count %d into runtime variable '%s'", res, String.valueOf(runtimeVar.getValue())));
58-60: Structured exception logging and clearer message.Apply this diff:
- logger.warn("Exception while executing action - "+ ExceptionUtils.getStackTrace(e)); - setErrorMessage("Operation failed , the error message is ::::"+ExceptionUtils.getMessage(e)); + logger.warn("Exception while executing action", e); + setErrorMessage("Operation failed: " + ExceptionUtils.getMessage(e));
14-17: Correct typos/grammar in @action text.Apply this diff:
-@Action(actionText = "Split the string testdata by delimeter and store the count of string into a runtime variable", - description = "This addon will Split the string testdata by delimeter and store the count of string into a runtime variable", +@Action(actionText = "Split the string testdata by delimiter and store the segment count into a runtime variable", + description = "This addon splits the string testdata by a delimiter and stores the segment count into a runtime variable", applicationType = ApplicationType.MOBILE_WEB, useCustomScreenshot = false)
40-43: Prefer parameterized logging and null-safe conversion.Apply this diff:
- logger.debug("testdata => " + testData1.getValue().toString()); - logger.debug("delimeter => " + testData2.getValue().toString()); - logger.debug("Runtime_Variable => " + runtimeVar.getValue().toString()); + logger.debug("testdata => {}", testData1.getValue()); + logger.debug("delimeter => {}", testData2.getValue()); + logger.debug("Runtime_Variable => {}", runtimeVar.getValue());
11-11: Remove unused import.NoSuchElementException isn’t thrown.
Apply this diff:
-import org.openqa.selenium.NoSuchElementException;
33-34: Remove unnecessary throws clause.Apply this diff:
- public Result execute() throws NoSuchElementException + public Result execute()
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (8)
store_string_lengths_split_by_a_delimiter/pom.xml(1 hunks)store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/API/MyFirstWebAction.java(1 hunks)store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/android/SplitStringAction.java(1 hunks)store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/ios/SplitStringAction.java(1 hunks)store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/mobileweb/SplitStringAction.java(1 hunks)store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/web/MyFirstWebAction.java(1 hunks)store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/windows/SplitStringAction.java(1 hunks)store_string_lengths_split_by_a_delimiter/src/main/resources/testsigma-sdk.properties(1 hunks)
🧰 Additional context used
🪛 Gitleaks (8.27.2)
store_string_lengths_split_by_a_delimiter/src/main/resources/testsigma-sdk.properties
1-1: Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.
(jwt)
🪛 OSV Scanner (2.1.0)
store_string_lengths_split_by_a_delimiter/pom.xml
[HIGH] 1-1: org.json:json 20160810: json stack overflow vulnerability
[HIGH] 1-1: org.json:json 20160810: Java: DoS Vulnerability in JSON-JAVA
[HIGH] 1-1: org.testng:testng 6.14.3: TestNG is vulnerable to Path Traversal
🔇 Additional comments (6)
store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/android/SplitStringAction.java (2)
23-24: Confirm the TestData reference name “delimeter” is intentional.If other platforms already shipped with this misspelling, keeping it may be required for cross-platform parity. Otherwise, consider migrating to “delimiter” with a compatibility note.
14-17: Module naming vs. behavior check.The module name suggests “Store String Lengths Split by a Delimiter,” but the action stores only the count of segments, not lengths of each segment. Confirm that “count” is the intended behavior, or adjust naming/descriptions accordingly.
store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/ios/SplitStringAction.java (2)
23-24: Confirm “delimeter” TestData ref is deliberate.Keep as-is if required for parity with previously shipped actions; otherwise consider “delimiter”.
14-17: Behavior vs. module name.Module name mentions “Lengths” but the action stores only the count. Confirm intended behavior or adjust naming.
store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/mobileweb/SplitStringAction.java (2)
23-24: Verify “delimeter” TestData reference is intentional.Change only if compatibility is not a concern.
14-17: Behavior vs. module name.Module mentions “Lengths” but the code stores only the count. Please confirm or update naming.
| <dependency> | ||
| <groupId>org.testng</groupId> | ||
| <artifactId>testng</artifactId> | ||
| <version>6.14.3</version> | ||
| </dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Upgrade and scope TestNG to mitigate known vulnerability
TestNG 6.14.3 has a known high-severity vulnerability (path traversal). Either remove it or bump to a safe version and mark as test scope.
Apply this diff:
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <version>6.14.3</version>
- </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>7.10.2</version>
+ <scope>test</scope>
+ </dependency>If you don’t use TestNG at all (you already have JUnit Jupiter), consider removing it entirely.
🤖 Prompt for AI Agents
In store_string_lengths_split_by_a_delimiter/pom.xml around lines 42 to 46, the
TestNG dependency (6.14.3) has a known path traversal vulnerability; either
remove the dependency entirely if unused (you already have JUnit Jupiter), or
update it to a supported, non-vulnerable release and scope it to test;
specifically replace version 6.14.3 with a modern safe version (e.g., 7.x
series) and add a test scope entry so TestNG is not included in production
artifacts.
| String ABS = testData1.getValue().toString(); | ||
| String[] strings = ABS.split(testData2.getValue().toString()); | ||
| int res = strings.length; | ||
| logger.info("res " + res); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delimiter treated as regex and trailing empty segments lost (functional bug).
String.split treats the delimiter as a regex and drops trailing empty segments by default. This will miscount for delimiters like ".", "|", "*", or inputs ending with the delimiter (e.g., "a,b,"). Quote the delimiter and use limit -1 to preserve trailing empties.
Apply this diff:
- String ABS = testData1.getValue().toString();
- String[] strings = ABS.split(testData2.getValue().toString());
- int res = strings.length;
- logger.info("res " + res);
+ String input = String.valueOf(testData1.getValue());
+ String delimiter = String.valueOf(testData2.getValue());
+ if (delimiter.isEmpty()) {
+ setErrorMessage("Delimiter cannot be empty");
+ return Result.FAILED;
+ }
+ String[] strings = input.split(java.util.regex.Pattern.quote(delimiter), -1);
+ int res = strings.length;
+ logger.debug("segmentCount = {}", res);Add this import outside the selected range:
import java.util.regex.Pattern;🤖 Prompt for AI Agents
In
store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/android/SplitStringAction.java
around lines 44 to 47, the current use of String.split treats the delimiter as a
regex and drops trailing empty segments; replace the split call to use
Pattern.quote on testData2.getValue().toString() and pass a limit of -1 to
preserve trailing empty segments (i.e., split(Pattern.quote(delim), -1)); also
add the import statement import java.util.regex.Pattern; at the top of the file.
| runTimeData.setKey(runtimeVar.getValue().toString()); | ||
| runTimeData.setValue(String.valueOf(res)); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Validate runtime variable name before storing.
Avoid writing with a null/blank key. Fail fast with a clear error message.
Apply this diff:
+ if (runtimeVar.getValue() == null || runtimeVar.getValue().toString().isBlank()) {
+ setErrorMessage("Runtime variable name is required");
+ return Result.FAILED;
+ }
runTimeData.setKey(runtimeVar.getValue().toString());
runTimeData.setValue(String.valueOf(res));🤖 Prompt for AI Agents
In
store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/android/SplitStringAction.java
around lines 49 to 51, the code sets the runtime variable key without validating
runtimeVar.getValue(), which can be null or blank; update the method to validate
runtimeVar and its value before calling runTimeData.setKey(...): if runtimeVar
is null or runtimeVar.getValue() is null/empty/blank, fail fast by throwing an
appropriate ActionFailedException (or set the action result/state to failed with
a clear error message) instead of writing the key, otherwise proceed to setKey
and setValue as before. Ensure the error message clearly states the runtime
variable name is null/blank and include any context needed for debugging.
| import com.testsigma.sdk.ApplicationType; | ||
| import com.testsigma.sdk.RestApiAction; | ||
| import com.testsigma.sdk.Result; | ||
| import com.testsigma.sdk.annotation.Action; | ||
| import com.testsigma.sdk.annotation.RunTimeData; | ||
| import com.testsigma.sdk.annotation.TestData; | ||
| import lombok.Data; | ||
| import org.apache.commons.lang3.exception.ExceptionUtils; | ||
| import org.openqa.selenium.NoSuchElementException; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add Pattern import for safe splitting by literal delimiter
We’ll use Pattern.quote to avoid regex pitfalls in String.split.
import com.testsigma.sdk.annotation.TestData;
import lombok.Data;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.openqa.selenium.NoSuchElementException;
+import java.util.regex.Pattern;📝 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.
| import com.testsigma.sdk.ApplicationType; | |
| import com.testsigma.sdk.RestApiAction; | |
| import com.testsigma.sdk.Result; | |
| import com.testsigma.sdk.annotation.Action; | |
| import com.testsigma.sdk.annotation.RunTimeData; | |
| import com.testsigma.sdk.annotation.TestData; | |
| import lombok.Data; | |
| import org.apache.commons.lang3.exception.ExceptionUtils; | |
| import org.openqa.selenium.NoSuchElementException; | |
| import com.testsigma.sdk.ApplicationType; | |
| import com.testsigma.sdk.RestApiAction; | |
| import com.testsigma.sdk.Result; | |
| import com.testsigma.sdk.annotation.Action; | |
| import com.testsigma.sdk.annotation.RunTimeData; | |
| import com.testsigma.sdk.annotation.TestData; | |
| import lombok.Data; | |
| import org.apache.commons.lang3.exception.ExceptionUtils; | |
| import org.openqa.selenium.NoSuchElementException; | |
| import java.util.regex.Pattern; |
🤖 Prompt for AI Agents
In
store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/API/MyFirstWebAction.java
around lines 3 to 12, add an import for java.util.regex.Pattern and update any
String.split(delimiter) calls to use String.split(Pattern.quote(delimiter)) so
the delimiter is treated as a literal (preventing regex meta-character issues);
ensure the new import is added at the top with the other imports and replace
occurrences of split(...) accordingly.
| @Override | ||
| public Result execute() throws NoSuchElementException | ||
| { | ||
| logger.info("Initiating execution"); | ||
| Result result = Result.SUCCESS; | ||
|
|
||
| try | ||
| { | ||
| logger.debug("testdata => " + testData1.getValue().toString()); | ||
| logger.debug("delimeter => " + testData2.getValue().toString()); | ||
| logger.debug("Runtime_Variable => " + runtimeVar.getValue().toString()); | ||
|
|
||
| String ABS = testData1.getValue().toString(); | ||
| String[] strings = ABS.split(testData2.getValue().toString()); | ||
| int res = strings.length; | ||
| logger.info("res " + res); | ||
|
|
||
| runTimeData.setKey(runtimeVar.getValue().toString()); | ||
| runTimeData.setValue(String.valueOf(res)); | ||
|
|
||
| logger.info("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res); | ||
| setSuccessMessage("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res); | ||
|
|
||
| } | ||
| catch(Exception e) | ||
| { | ||
| logger.warn("Exception while executing action - "+ ExceptionUtils.getStackTrace(e)); | ||
| setErrorMessage("Operation failed , the error message is ::::"+ExceptionUtils.getMessage(e)); | ||
| result = Result.FAILED; | ||
| } | ||
| return result; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
❓ Verification inconclusive
Use literal delimiter (not regex), handle null/blank inputs, and tighten logging/messages
Current code uses String.split(delimiter) which treats delimiter as regex, leading to wrong counts for inputs like “a.b” with “.” as delimiter. Also, potential NPEs if any TestData is null.
Apply this diff to harden execute():
@Override
public Result execute() throws NoSuchElementException
{
logger.info("Initiating execution");
Result result = Result.SUCCESS;
try
{
- logger.debug("testdata => " + testData1.getValue().toString());
- logger.debug("delimeter => " + testData2.getValue().toString());
- logger.debug("Runtime_Variable => " + runtimeVar.getValue().toString());
-
- String ABS = testData1.getValue().toString();
- String[] strings = ABS.split(testData2.getValue().toString());
- int res = strings.length;
- logger.info("res " + res);
-
- runTimeData.setKey(runtimeVar.getValue().toString());
- runTimeData.setValue(String.valueOf(res));
-
- logger.info("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res);
- setSuccessMessage("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res);
+ if (testData1 == null || testData1.getValue() == null) {
+ setErrorMessage("Input 'testdata' is required");
+ return Result.FAILED;
+ }
+ if (testData2 == null || testData2.getValue() == null) {
+ setErrorMessage("Input 'delimeter' is required");
+ return Result.FAILED;
+ }
+ if (runtimeVar == null || runtimeVar.getValue() == null || runtimeVar.getValue().toString().trim().isEmpty()) {
+ setErrorMessage("Input 'variable' (runtime variable name) is required and cannot be blank");
+ return Result.FAILED;
+ }
+
+ final String input = testData1.getValue().toString();
+ final String delimiter = testData2.getValue().toString();
+ final String variableName = runtimeVar.getValue().toString().trim();
+
+ logger.debug("testdata => {}", input);
+ logger.debug("delimiter => {}", delimiter);
+ logger.debug("runtime variable => {}", variableName);
+
+ // Use literal delimiter and include trailing empty strings for intuitive counts
+ final String[] parts = input.split(Pattern.quote(delimiter), -1);
+ final int count = parts.length;
+ logger.debug("count => {}", count);
+
+ runTimeData.setKey(variableName);
+ runTimeData.setValue(String.valueOf(count));
+
+ setSuccessMessage(String.format("Stored count %d for the given string into runtime variable '%s'", count, variableName));
}
catch(Exception e)
{
- logger.warn("Exception while executing action - "+ ExceptionUtils.getStackTrace(e));
- setErrorMessage("Operation failed , the error message is ::::"+ExceptionUtils.getMessage(e));
+ logger.warn("Exception while executing action - {}", ExceptionUtils.getStackTrace(e));
+ setErrorMessage("Operation failed: " + ExceptionUtils.getMessage(e));
result = Result.FAILED;
}
return result;
}Notes:
- Pattern.quote ensures “.”, “|”, “$”, etc. are treated literally.
- split(..., -1) counts trailing empty segments (e.g., “a,” with “,”). If you prefer to ignore trailing empties, change -1 to 0.
Do you want trailing empty segments to be counted or ignored? I can adjust accordingly.
Hardening input validation, literal delimiter handling, and tightening logs
File: store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/API/MyFirstWebAction.java (around lines 32–63)
Key changes needed:
- Add
import java.util.regex.Pattern; - Null/blank checks for
testData1,testData2, andruntimeVarto avoid NPEs and surface clear error messages - Treat the delimiter as a literal (not regex) and decide on trailing‐empty behavior via
split(Pattern.quote(delimiter), -1) - Switch to parameterized logging (
logger.debug("…{}", var)) and concise exception logging
Apply the following diff:
+ import java.util.regex.Pattern;
// … other imports …
import org.apache.commons.lang3.exception.ExceptionUtils;
@Override
public Result execute() throws NoSuchElementException
{
logger.info("Initiating execution");
Result result = Result.SUCCESS;
try
{
- logger.debug("testdata => " + testData1.getValue().toString());
- logger.debug("delimeter => " + testData2.getValue().toString());
- logger.debug("Runtime_Variable => " + runtimeVar.getValue().toString());
-
- String ABS = testData1.getValue().toString();
- String[] strings = ABS.split(testData2.getValue().toString());
- int res = strings.length;
- logger.info("res " + res);
-
- runTimeData.setKey(runtimeVar.getValue().toString());
- runTimeData.setValue(String.valueOf(res));
-
- logger.info("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res);
- setSuccessMessage("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res);
+ if (testData1 == null || testData1.getValue() == null) {
+ setErrorMessage("Input 'testdata' is required");
+ return Result.FAILED;
+ }
+ if (testData2 == null || testData2.getValue() == null) {
+ setErrorMessage("Input 'delimiter' is required");
+ return Result.FAILED;
+ }
+ if (runtimeVar == null || runtimeVar.getValue() == null || runtimeVar.getValue().toString().trim().isEmpty()) {
+ setErrorMessage("Runtime variable name cannot be blank");
+ return Result.FAILED;
+ }
+
+ final String input = testData1.getValue().toString();
+ final String delimiter = testData2.getValue().toString();
+ final String variableName = runtimeVar.getValue().toString().trim();
+
+ logger.debug("testdata => {}", input);
+ logger.debug("delimiter => {}", delimiter);
+ logger.debug("runtime variable => {}", variableName);
+
+ // Use literal delimiter; -1 retains trailing empty segments
+ final String[] parts = input.split(Pattern.quote(delimiter), -1);
+ final int count = parts.length;
+ logger.debug("count => {}", count);
+
+ runTimeData.setKey(variableName);
+ runTimeData.setValue(String.valueOf(count));
+
+ setSuccessMessage(String.format(
+ "Stored count %d for the given string into runtime variable '%s'",
+ count, variableName));
}
catch(Exception e)
{
- logger.warn("Exception while executing action - "+ ExceptionUtils.getStackTrace(e));
- setErrorMessage("Operation failed , the error message is ::::"+ExceptionUtils.getMessage(e));
+ logger.warn("Exception while executing action", e);
+ setErrorMessage("Operation failed: " + ExceptionUtils.getMessage(e));
result = Result.FAILED;
}
return result;
}Notes:
- Ensure you add
import java.util.regex.Pattern;at the top. - Verify whether you want to count trailing empty segments (
split(..., -1)) or ignore them (split(..., 0)). I can update the code accordingly.
📝 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.
| @Override | |
| public Result execute() throws NoSuchElementException | |
| { | |
| logger.info("Initiating execution"); | |
| Result result = Result.SUCCESS; | |
| try | |
| { | |
| logger.debug("testdata => " + testData1.getValue().toString()); | |
| logger.debug("delimeter => " + testData2.getValue().toString()); | |
| logger.debug("Runtime_Variable => " + runtimeVar.getValue().toString()); | |
| String ABS = testData1.getValue().toString(); | |
| String[] strings = ABS.split(testData2.getValue().toString()); | |
| int res = strings.length; | |
| logger.info("res " + res); | |
| runTimeData.setKey(runtimeVar.getValue().toString()); | |
| runTimeData.setValue(String.valueOf(res)); | |
| logger.info("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res); | |
| setSuccessMessage("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res); | |
| } | |
| catch(Exception e) | |
| { | |
| logger.warn("Exception while executing action - "+ ExceptionUtils.getStackTrace(e)); | |
| setErrorMessage("Operation failed , the error message is ::::"+ExceptionUtils.getMessage(e)); | |
| result = Result.FAILED; | |
| } | |
| return result; | |
| } | |
| import java.util.regex.Pattern; | |
| // … other imports … | |
| import org.apache.commons.lang3.exception.ExceptionUtils; | |
| @Override | |
| public Result execute() throws NoSuchElementException | |
| { | |
| logger.info("Initiating execution"); | |
| Result result = Result.SUCCESS; | |
| try | |
| { | |
| if (testData1 == null || testData1.getValue() == null) { | |
| setErrorMessage("Input 'testdata' is required"); | |
| return Result.FAILED; | |
| } | |
| if (testData2 == null || testData2.getValue() == null) { | |
| setErrorMessage("Input 'delimiter' is required"); | |
| return Result.FAILED; | |
| } | |
| if (runtimeVar == null | |
| || runtimeVar.getValue() == null | |
| || runtimeVar.getValue().toString().trim().isEmpty()) { | |
| setErrorMessage("Runtime variable name cannot be blank"); | |
| return Result.FAILED; | |
| } | |
| final String input = testData1.getValue().toString(); | |
| final String delimiter = testData2.getValue().toString(); | |
| final String variableName = runtimeVar.getValue().toString().trim(); | |
| logger.debug("testdata => {}", input); | |
| logger.debug("delimiter => {}", delimiter); | |
| logger.debug("runtime variable => {}", variableName); | |
| // Use literal delimiter; -1 retains trailing empty segments | |
| final String[] parts = input.split(Pattern.quote(delimiter), -1); | |
| final int count = parts.length; | |
| logger.debug("count => {}", count); | |
| runTimeData.setKey(variableName); | |
| runTimeData.setValue(String.valueOf(count)); | |
| setSuccessMessage(String.format( | |
| "Stored count %d for the given string into runtime variable '%s'", | |
| count, variableName)); | |
| } | |
| catch(Exception e) | |
| { | |
| logger.warn("Exception while executing action", e); | |
| setErrorMessage("Operation failed: " + ExceptionUtils.getMessage(e)); | |
| result = Result.FAILED; | |
| } | |
| return result; | |
| } |
🤖 Prompt for AI Agents
In
store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/API/MyFirstWebAction.java
around lines 32 to 63, add import java.util.regex.Pattern; then validate inputs
(testData1, testData2, runtimeVar and their getValue() results) and throw/return
a clear FAILED result with setErrorMessage if any are null/blank to avoid NPEs;
treat the delimiter as a literal by using split(Pattern.quote(delimiter), -1)
(or use 0 if you intend to ignore trailing empty segments) to control
trailing-empty behavior; change concatenated logs to parameterized logging
(e.g., logger.debug("testdata => {}", testData1.getValue())) and replace
stack-trace heavy logging with concise exception logging (logger.warn("Exception
while executing action", e)) and ensure runTimeData key/value are set only after
validation succeeds.
| String ABS = testData1.getValue().toString(); | ||
| String[] strings = ABS.split(testData2.getValue().toString()); | ||
| int res = strings.length; | ||
| logger.info("res " + res); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delimiter treated as regex and trailing empty segments lost (functional bug).
Quote the delimiter and use limit -1 to preserve trailing empties; otherwise counts will be wrong in common cases.
Apply this diff:
- String ABS = testData1.getValue().toString();
- String[] strings = ABS.split(testData2.getValue().toString());
- int res = strings.length;
- logger.info("res " + res);
+ String input = String.valueOf(testData1.getValue());
+ String delimiter = String.valueOf(testData2.getValue());
+ if (delimiter.isEmpty()) {
+ setErrorMessage("Delimiter cannot be empty");
+ return Result.FAILED;
+ }
+ String[] strings = input.split(java.util.regex.Pattern.quote(delimiter), -1);
+ int res = strings.length;
+ logger.debug("segmentCount = {}", res);Add this import outside the selected range:
import java.util.regex.Pattern;🤖 Prompt for AI Agents
In
store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/mobileweb/SplitStringAction.java
around lines 44 to 47, the delimiter is passed directly to String.split (treated
as a regex) and trailing empty segments are dropped; change the split call to
use Pattern.quote(testData2.getValue().toString()) and pass a limit of -1 to
preserve trailing empty elements (i.e., strings =
ABS.split(Pattern.quote(delimiter), -1)); also add import
java.util.regex.Pattern at the top of the file.
| runTimeData.setKey(runtimeVar.getValue().toString()); | ||
| runTimeData.setValue(String.valueOf(res)); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Validate runtime variable name before storing.
Apply this diff:
+ if (runtimeVar.getValue() == null || runtimeVar.getValue().toString().isBlank()) {
+ setErrorMessage("Runtime variable name is required");
+ return Result.FAILED;
+ }
runTimeData.setKey(runtimeVar.getValue().toString());
runTimeData.setValue(String.valueOf(res));📝 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.
| runTimeData.setKey(runtimeVar.getValue().toString()); | |
| runTimeData.setValue(String.valueOf(res)); | |
| if (runtimeVar.getValue() == null || runtimeVar.getValue().toString().isBlank()) { | |
| setErrorMessage("Runtime variable name is required"); | |
| return Result.FAILED; | |
| } | |
| runTimeData.setKey(runtimeVar.getValue().toString()); | |
| runTimeData.setValue(String.valueOf(res)); |
🤖 Prompt for AI Agents
In
store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/mobileweb/SplitStringAction.java
around lines 49-51, validate the runtime variable name before calling
runTimeData.setKey(...) by ensuring runtimeVar is not null,
runtimeVar.getValue() is not null/empty after trimming, and matches your allowed
variable-name pattern (for example: starts with a letter or underscore and
contains only letters, digits, or underscores); if invalid, log or throw a clear
exception and do not set the key, otherwise use the trimmed valid name and set
the value as String.valueOf(res).
| @Override | ||
| public Result execute() throws NoSuchElementException | ||
| { | ||
| logger.info("Initiating execution"); | ||
| Result result = Result.SUCCESS; | ||
|
|
||
| try | ||
| { | ||
| logger.debug("testdata => " + testData1.getValue().toString()); | ||
| logger.debug("delimeter => " + testData2.getValue().toString()); | ||
| logger.debug("Runtime_Variable => " + runtimeVar.getValue().toString()); | ||
|
|
||
| String ABS = testData1.getValue().toString(); | ||
| String[] strings = ABS.split(testData2.getValue().toString()); | ||
| int res = strings.length; | ||
| logger.info("res " + res); | ||
|
|
||
| runTimeData.setKey(runtimeVar.getValue().toString()); | ||
| runTimeData.setValue(String.valueOf(res)); | ||
|
|
||
| logger.info("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res); | ||
| setSuccessMessage("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res); | ||
|
|
||
| } | ||
| catch(Exception e) | ||
| { | ||
| logger.warn("Exception while executing action - "+ ExceptionUtils.getStackTrace(e)); | ||
| setErrorMessage("Operation failed , the error message is ::::"+ExceptionUtils.getMessage(e)); | ||
| result = Result.FAILED; | ||
| } | ||
| return result; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use literal delimiter and add input validation; improve logging/messages
Mirror the hardened logic as suggested for API/Windows actions.
@Override
public Result execute() throws NoSuchElementException
{
logger.info("Initiating execution");
Result result = Result.SUCCESS;
try
{
- logger.debug("testdata => " + testData1.getValue().toString());
- logger.debug("delimeter => " + testData2.getValue().toString());
- logger.debug("Runtime_Variable => " + runtimeVar.getValue().toString());
-
- String ABS = testData1.getValue().toString();
- String[] strings = ABS.split(testData2.getValue().toString());
- int res = strings.length;
- logger.info("res " + res);
-
- runTimeData.setKey(runtimeVar.getValue().toString());
- runTimeData.setValue(String.valueOf(res));
-
- logger.info("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res);
- setSuccessMessage("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res);
+ if (testData1 == null || testData1.getValue() == null) {
+ setErrorMessage("Input 'testdata' is required");
+ return Result.FAILED;
+ }
+ if (testData2 == null || testData2.getValue() == null) {
+ setErrorMessage("Input 'delimeter' is required");
+ return Result.FAILED;
+ }
+ if (runtimeVar == null || runtimeVar.getValue() == null || runtimeVar.getValue().toString().trim().isEmpty()) {
+ setErrorMessage("Input 'variable' (runtime variable name) is required and cannot be blank");
+ return Result.FAILED;
+ }
+
+ final String input = testData1.getValue().toString();
+ final String delimiter = testData2.getValue().toString();
+ final String variableName = runtimeVar.getValue().toString().trim();
+
+ logger.debug("testdata => {}", input);
+ logger.debug("delimiter => {}", delimiter);
+ logger.debug("runtime variable => {}", variableName);
+
+ final String[] parts = input.split(java.util.regex.Pattern.quote(delimiter), -1);
+ final int count = parts.length;
+ logger.debug("count => {}", count);
+
+ runTimeData.setKey(variableName);
+ runTimeData.setValue(String.valueOf(count));
+
+ setSuccessMessage(String.format("Stored count %d into runtime variable '%s'", count, variableName));
}
catch(Exception e)
{
- logger.warn("Exception while executing action - "+ ExceptionUtils.getStackTrace(e));
- setErrorMessage("Operation failed , the error message is ::::"+ExceptionUtils.getMessage(e));
+ logger.warn("Exception while executing action - {}", ExceptionUtils.getStackTrace(e));
+ setErrorMessage("Operation failed: " + ExceptionUtils.getMessage(e));
result = Result.FAILED;
}
return result;
}📝 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.
| @Override | |
| public Result execute() throws NoSuchElementException | |
| { | |
| logger.info("Initiating execution"); | |
| Result result = Result.SUCCESS; | |
| try | |
| { | |
| logger.debug("testdata => " + testData1.getValue().toString()); | |
| logger.debug("delimeter => " + testData2.getValue().toString()); | |
| logger.debug("Runtime_Variable => " + runtimeVar.getValue().toString()); | |
| String ABS = testData1.getValue().toString(); | |
| String[] strings = ABS.split(testData2.getValue().toString()); | |
| int res = strings.length; | |
| logger.info("res " + res); | |
| runTimeData.setKey(runtimeVar.getValue().toString()); | |
| runTimeData.setValue(String.valueOf(res)); | |
| logger.info("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res); | |
| setSuccessMessage("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res); | |
| } | |
| catch(Exception e) | |
| { | |
| logger.warn("Exception while executing action - "+ ExceptionUtils.getStackTrace(e)); | |
| setErrorMessage("Operation failed , the error message is ::::"+ExceptionUtils.getMessage(e)); | |
| result = Result.FAILED; | |
| } | |
| return result; | |
| } | |
| @Override | |
| public Result execute() throws NoSuchElementException | |
| { | |
| logger.info("Initiating execution"); | |
| Result result = Result.SUCCESS; | |
| try | |
| { | |
| if (testData1 == null || testData1.getValue() == null) { | |
| setErrorMessage("Input 'testdata' is required"); | |
| return Result.FAILED; | |
| } | |
| if (testData2 == null || testData2.getValue() == null) { | |
| setErrorMessage("Input 'delimeter' is required"); | |
| return Result.FAILED; | |
| } | |
| if (runtimeVar == null | |
| || runtimeVar.getValue() == null | |
| || runtimeVar.getValue().toString().trim().isEmpty()) { | |
| setErrorMessage("Input 'variable' (runtime variable name) is required and cannot be blank"); | |
| return Result.FAILED; | |
| } | |
| final String input = testData1.getValue().toString(); | |
| final String delimiter = testData2.getValue().toString(); | |
| final String variableName = runtimeVar.getValue().toString().trim(); | |
| logger.debug("testdata => {}", input); | |
| logger.debug("delimiter => {}", delimiter); | |
| logger.debug("runtime variable => {}", variableName); | |
| final String[] parts = input.split(java.util.regex.Pattern.quote(delimiter), -1); | |
| final int count = parts.length; | |
| logger.debug("count => {}", count); | |
| runTimeData.setKey(variableName); | |
| runTimeData.setValue(String.valueOf(count)); | |
| setSuccessMessage( | |
| String.format("Stored count %d into runtime variable '%s'", count, variableName) | |
| ); | |
| } | |
| catch (Exception e) | |
| { | |
| logger.warn("Exception while executing action - {}", ExceptionUtils.getStackTrace(e)); | |
| setErrorMessage("Operation failed: " + ExceptionUtils.getMessage(e)); | |
| result = Result.FAILED; | |
| } | |
| return result; | |
| } |
🤖 Prompt for AI Agents
In
store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/web/MyFirstWebAction.java
around lines 32 to 63, the code uses testData2.getValue().toString() directly as
a regex delimiter, lacks null/empty input validation, and logs raw toString()
calls; update to validate that testData1, testData2 and runtimeVar values are
non-null and non-empty (return Result.FAILED with a clear error message if
invalid), trim inputs, compute the split using a literal delimiter by quoting it
(e.g., use Pattern.quote(delimiter)) so it is not treated as a regex, only set
runTimeData key/value after successful computation, and improve logging messages
to safely include values (avoid invoking toString() on possible nulls and log
sanitized/trimmed values) and include contextual info on failures.
| @Override | ||
| public Result execute() throws NoSuchElementException | ||
| { | ||
| logger.info("Initiating execution"); | ||
| Result result = Result.SUCCESS; | ||
|
|
||
| try | ||
| { | ||
| logger.debug("testdata => " + testData1.getValue().toString()); | ||
| logger.debug("delimeter => " + testData2.getValue().toString()); | ||
| logger.debug("Runtime_Variable => " + runtimeVar.getValue().toString()); | ||
|
|
||
| String ABS = testData1.getValue().toString(); | ||
| String[] strings = ABS.split(testData2.getValue().toString()); | ||
| int res = strings.length; | ||
| logger.info("res " + res); | ||
|
|
||
| runTimeData.setKey(runtimeVar.getValue().toString()); | ||
| runTimeData.setValue(String.valueOf(res)); | ||
|
|
||
| logger.info("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res); | ||
| setSuccessMessage("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res); | ||
|
|
||
| } | ||
| catch(Exception e) | ||
| { | ||
| logger.warn("Exception while executing action - "+ ExceptionUtils.getStackTrace(e)); | ||
| setErrorMessage("Operation failed , the error message is ::::"+ExceptionUtils.getMessage(e)); | ||
| result = Result.FAILED; | ||
| } | ||
| return result; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use literal delimiter and add input validation; improve logging/messages
Same issues as the API variant: regex split and potential nulls.
@Override
public Result execute() throws NoSuchElementException
{
logger.info("Initiating execution");
Result result = Result.SUCCESS;
try
{
- logger.debug("testdata => " + testData1.getValue().toString());
- logger.debug("delimeter => " + testData2.getValue().toString());
- logger.debug("Runtime_Variable => " + runtimeVar.getValue().toString());
-
- String ABS = testData1.getValue().toString();
- String[] strings = ABS.split(testData2.getValue().toString());
- int res = strings.length;
- logger.info("res " + res);
-
- runTimeData.setKey(runtimeVar.getValue().toString());
- runTimeData.setValue(String.valueOf(res));
-
- logger.info("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res);
- setSuccessMessage("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res);
+ if (testData1 == null || testData1.getValue() == null) {
+ setErrorMessage("Input 'testdata' is required");
+ return Result.FAILED;
+ }
+ if (testData2 == null || testData2.getValue() == null) {
+ setErrorMessage("Input 'delimeter' is required");
+ return Result.FAILED;
+ }
+ if (runtimeVar == null || runtimeVar.getValue() == null || runtimeVar.getValue().toString().trim().isEmpty()) {
+ setErrorMessage("Input 'variable' (runtime variable name) is required and cannot be blank");
+ return Result.FAILED;
+ }
+
+ final String input = testData1.getValue().toString();
+ final String delimiter = testData2.getValue().toString();
+ final String variableName = runtimeVar.getValue().toString().trim();
+
+ logger.debug("testdata => {}", input);
+ logger.debug("delimiter => {}", delimiter);
+ logger.debug("runtime variable => {}", variableName);
+
+ final String[] parts = input.split(java.util.regex.Pattern.quote(delimiter), -1);
+ final int count = parts.length;
+ logger.debug("count => {}", count);
+
+ runTimeData.setKey(variableName);
+ runTimeData.setValue(String.valueOf(count));
+
+ setSuccessMessage(String.format("Stored count %d into runtime variable '%s'", count, variableName));
}
catch(Exception e)
{
- logger.warn("Exception while executing action - "+ ExceptionUtils.getStackTrace(e));
- setErrorMessage("Operation failed , the error message is ::::"+ExceptionUtils.getMessage(e));
+ logger.warn("Exception while executing action - {}", ExceptionUtils.getStackTrace(e));
+ setErrorMessage("Operation failed: " + ExceptionUtils.getMessage(e));
result = Result.FAILED;
}
return result;
}📝 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.
| @Override | |
| public Result execute() throws NoSuchElementException | |
| { | |
| logger.info("Initiating execution"); | |
| Result result = Result.SUCCESS; | |
| try | |
| { | |
| logger.debug("testdata => " + testData1.getValue().toString()); | |
| logger.debug("delimeter => " + testData2.getValue().toString()); | |
| logger.debug("Runtime_Variable => " + runtimeVar.getValue().toString()); | |
| String ABS = testData1.getValue().toString(); | |
| String[] strings = ABS.split(testData2.getValue().toString()); | |
| int res = strings.length; | |
| logger.info("res " + res); | |
| runTimeData.setKey(runtimeVar.getValue().toString()); | |
| runTimeData.setValue(String.valueOf(res)); | |
| logger.info("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res); | |
| setSuccessMessage("Successfully stored the count of the given string " + testData1.getValue().toString() + " into a runtime variable " + runtimeVar.getValue().toString() + " = " + res); | |
| } | |
| catch(Exception e) | |
| { | |
| logger.warn("Exception while executing action - "+ ExceptionUtils.getStackTrace(e)); | |
| setErrorMessage("Operation failed , the error message is ::::"+ExceptionUtils.getMessage(e)); | |
| result = Result.FAILED; | |
| } | |
| return result; | |
| } | |
| @Override | |
| public Result execute() throws NoSuchElementException | |
| { | |
| logger.info("Initiating execution"); | |
| Result result = Result.SUCCESS; | |
| try | |
| { | |
| if (testData1 == null || testData1.getValue() == null) { | |
| setErrorMessage("Input 'testdata' is required"); | |
| return Result.FAILED; | |
| } | |
| if (testData2 == null || testData2.getValue() == null) { | |
| setErrorMessage("Input 'delimiter' is required"); | |
| return Result.FAILED; | |
| } | |
| if (runtimeVar == null || runtimeVar.getValue() == null || runtimeVar.getValue().toString().trim().isEmpty()) { | |
| setErrorMessage("Input 'variable' (runtime variable name) is required and cannot be blank"); | |
| return Result.FAILED; | |
| } | |
| final String input = testData1.getValue().toString(); | |
| final String delimiter = testData2.getValue().toString(); | |
| final String variableName = runtimeVar.getValue().toString().trim(); | |
| logger.debug("testdata => {}", input); | |
| logger.debug("delimiter => {}", delimiter); | |
| logger.debug("runtime variable => {}", variableName); | |
| final String[] parts = input.split(java.util.regex.Pattern.quote(delimiter), -1); | |
| final int count = parts.length; | |
| logger.debug("count => {}", count); | |
| runTimeData.setKey(variableName); | |
| runTimeData.setValue(String.valueOf(count)); | |
| setSuccessMessage(String.format("Stored count %d into runtime variable '%s'", count, variableName)); | |
| } | |
| catch(Exception e) | |
| { | |
| logger.warn("Exception while executing action - {}", ExceptionUtils.getStackTrace(e)); | |
| setErrorMessage("Operation failed: " + ExceptionUtils.getMessage(e)); | |
| result = Result.FAILED; | |
| } | |
| return result; | |
| } |
🤖 Prompt for AI Agents
In
store_string_lengths_split_by_a_delimiter/src/main/java/com/testsigma/addons/windows/SplitStringAction.java
around lines 32 to 63, the code currently uses testData2.getValue() as a raw
regex in String.split and does not validate possible null/empty inputs, which
can cause unexpected splitting or NPEs; update the method to first null-check
and validate testData1, testData2 and runtimeVar (return FAILED with clear error
message if missing), retrieve their String values once into local vars, use
Pattern.quote(delimiter) when splitting to treat the delimiter as a literal,
compute and store the length only after validation, and improve logging/error
messages to include variable names and sanitized values (avoid calling
toString() on possibly null objects and log concise contextual messages).
| @@ -0,0 +1 @@ | |||
| testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI4MjhhM2FhZC1jOTI5LTE3YTUtNDJjMS03MTIyNDhkMGM5NmQiLCJ1bmlxdWVJZCI6IjMxNTQiLCJleHRlcm5hbFRlbmFudElkIjoiMjgxNyJ9.w4aK00OEPIs9qwvGzY9KE1BD3s8ogwHEXtRTB-5cxasIT-LpY4L228F4MLVqTfqaZK9QKqaIMO5VRQlVmZF3-A No newline at end of file | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Hardcoded JWT/API key committed — remove from repo, rotate immediately
A real-looking JWT/API key is committed to VCS. This is a severe secret leakage risk.
Apply one of the following immediate remediations:
- Preferable: delete the secret from the file and load it from environment/config at runtime. Commit only a placeholder or an .example file.
Suggested minimal change in this file (keeps runtime behavior via env var/property resolution):
-testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI4MjhhM2FhZC1jOTI5LTE3YTUtNDJjMS03MTIyNDhkMGM5NmQiLCJ1bmlxdWVJZCI6IjMxNTQiLCJleHRlcm5hbFRlbmFudElkIjoiMjgxNyJ9.w4aK00OEPIs9qwvGzY9KE1BD3s8ogwHEXtRTB-5cxasIT-LpY4L228F4MLVqTfqaZK9QKqaIMO5VRQlVmZF3-A
+testsigma-sdk.api.key=${TESTSIGMA_SDK_API_KEY}Follow-ups:
- Revoke/rotate the leaked key server-side.
- Add this path to .gitignore and consider committing a testsigma-sdk.properties.example with documentation.
- Scrub the secret from git history if this repo is public/shared.
To help you verify there are no other committed secrets:
If you want, I can draft a small README snippet and .gitignore updates for safe secret handling.
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Scanning for potential secrets…"
# Look for JWT-like tokens
rg -nP '[A-Za-z0-9-_]{10,}\.[A-Za-z0-9-_]{10,}\.[A-Za-z0-9-_]{10,}' -C2 || true
# Look for api.key keys
rg -nP 'api\.key\s*=' -C2 || true
# Common private key markers
rg -nP '-----BEGIN (RSA|DSA|EC|OPENSSH|PGP) PRIVATE KEY-----' -C2 || trueLength of output: 130138
Critical: Hardcoded JWT/API keys found in multiple testsigma-sdk.properties files — remove and rotate immediately
We’ve detected real-looking JWT/API keys committed across dozens of example modules (e.g.
• store_string_lengths_split_by_a_delimiter/src/main/resources/testsigma-sdk.properties
• verify_that_the_element_has_non-empty_value/src/main/resources/testsigma-sdk.properties
• …and many more under */src/main/resources/testsigma-sdk.properties).
Immediate steps required:
• Delete every hardcoded testsigma-sdk.api.key=… line from these .properties files.
• Replace with an environment‐driven placeholder, for example:
- testsigma-sdk.api.key=<hardcoded-jwt>
+ testsigma-sdk.api.key=${TESTSIGMA_SDK_API_KEY}• Add a .gitignore rule to prevent committing real credentials (e.g. **/testsigma-sdk.properties).
• Commit a testsigma-sdk.properties.example with only the placeholder and usage instructions.
• Revoke/rotate all leaked keys server-side and scrub them from VCS history if the repo is public/shared.
Please address across the entire repo before merging.
🧰 Tools
🪛 Gitleaks (8.27.2)
1-1: Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.
(jwt)
🤖 Prompt for AI Agents
In
store_string_lengths_split_by_a_delimiter/src/main/resources/testsigma-sdk.properties
around line 1, a hardcoded testsigma-sdk.api.key JWT is committed; remove the
hardcoded key line and replace it with a placeholder that reads the value from
the environment (e.g. reference a variable like ${TESTSIGMA_SDK_API_KEY} or
document env usage), add a repo .gitignore rule to prevent committing real
testsigma-sdk.properties (for example **/testsigma-sdk.properties), create and
commit a testsigma-sdk.properties.example containing only the placeholder and
brief usage instructions, and ensure leaked keys are rotated/revoked and removed
from history as part of the remediation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
store_string_lengths_split_by_a_delimiter/pom.xml (1)
42-46: Upgrade or remove TestNG; 6.14.3 is vulnerableThis dependency version has a known high-severity vulnerability. Either remove TestNG (you already use JUnit 5) or upgrade and scope to test.
Apply one of the following:
Option A — Remove entirely if unused:
- <dependency> - <groupId>org.testng</groupId> - <artifactId>testng</artifactId> - <version>6.14.3</version> - </dependency>Option B — Upgrade and scope to test:
<dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> - <version>6.14.3</version> + <version>7.10.2</version> + <scope>test</scope> </dependency>
🧹 Nitpick comments (4)
store_string_lengths_split_by_a_delimiter/pom.xml (4)
47-58: Confirm shading strategy for Selenium/Appium to avoid classpath conflictsYou’re shading the jar while keeping selenium-java (4.33.0) and appium java-client (9.4.0) on compile scope. If the runtime (agent) already provides these, shading them can bloat the artifact and risk version conflicts. If the addon must bundle them, consider class relocation; otherwise, mark as provided or exclude from shading.
Option A — If provided by the platform:
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>4.33.0</version> + <scope>provided</scope> </dependency> <dependency> <groupId>io.appium</groupId> <artifactId>java-client</artifactId> <version>9.4.0</version> + <scope>provided</scope> </dependency>Option B — Keep dependencies, but exclude from shading:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.2.4</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> + <configuration> + <artifactSet> + <excludes> + <exclude>org.seleniumhq.selenium:selenium-*</exclude> + <exclude>io.appium:java-client</exclude> + </excludes> + </artifactSet> + </configuration> </execution> </executions> </plugin>If you must include them, consider relocating to avoid clashes:
- Add rules for org.openqa.selenium and io.appium packages.
74-86: Tighten shading config: minimize jar and exclude test/compile-only libsCurrent shade config pulls everything in. Consider minimizing and excluding test-only and compile-only (lombok) artifacts.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.2.4</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> + <configuration> + <minimizeJar>true</minimizeJar> + <artifactSet> + <excludes> + <exclude>org.projectlombok:lombok</exclude> + <exclude>org.junit.jupiter:* </exclude> + <exclude>org.testng:testng</exclude> + </excludes> + </artifactSet> + </configuration> </execution> </executions> </plugin>
59-63: Revisit jackson-annotations pinning (2.13.0 is dated)Unless you directly use Jackson annotations, let the SDK manage this transitively, or bump to a modern compatible version to reduce CVE exposure.
Option A — Remove if unused:
- <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-annotations</artifactId> - <version>2.13.0</version> - </dependency>Option B — Upgrade (verify compatibility with testsigma SDK first):
- <version>2.13.0</version> + <version>2.17.2</version>
16-21: Unused property: testsigma.addon.maven.pluginThe property is defined but not referenced in plugins. Drop it or wire up the intended plugin.
<testsigma.sdk.version>1.2.13_cloud</testsigma.sdk.version> - <junit.jupiter.version>5.8.0-M1</junit.jupiter.version> - <testsigma.addon.maven.plugin>1.0.0</testsigma.addon.maven.plugin> + <junit.jupiter.version>5.11.4</junit.jupiter.version> <maven.source.plugin.version>3.2.1</maven.source.plugin.version>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
store_string_lengths_split_by_a_delimiter/pom.xml(1 hunks)
🔇 Additional comments (1)
store_string_lengths_split_by_a_delimiter/pom.xml (1)
49-57: Selenium/Appium versions match reviewer noteSelenium 4.33.0 and Appium 9.4.0 align with the prior review instruction.
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter-api</artifactId> | ||
| <version>${junit.jupiter.version}</version> | ||
| <scope>test</scope> | ||
| </dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use a stable JUnit 5 and include the engine (tests won’t run with API-only)
You’re pulling only junit-jupiter-api and an old pre-release (5.8.0-M1). Prefer a stable 5.x and include the engine or the aggregate artifact so tests can execute.
Minimal, safer change:
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <version>${junit.jupiter.version}</version>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <version>${junit.jupiter.version}</version>
+ <scope>test</scope>
+ </dependency>And bump to a stable JUnit 5 release:
- <junit.jupiter.version>5.8.0-M1</junit.jupiter.version>
+ <junit.jupiter.version>5.11.4</junit.jupiter.version>Also applies to: 16-16
🤖 Prompt for AI Agents
In store_string_lengths_split_by_a_delimiter/pom.xml around lines 37 to 41, the
POM currently depends only on the pre-release junit-jupiter-api (5.8.0-M1) which
won’t run tests; replace the API-only pre-release with a stable JUnit 5
aggregate or add the engine: update the junit.jupiter.version to a stable
release (e.g., 5.9.3) and either change the dependency to
org.junit.jupiter:junit-jupiter:${junit.jupiter.version} (the aggregate that
includes the engine) or add
org.junit.jupiter:junit-jupiter-engine:${junit.jupiter.version} with scope test;
also apply the same version bump at the other occurrence noted (line 16).
Addon Name: Store String Lengths Split by a Delimiter
Jarvis Link: https://jarvis.testsigma.com/ui/tenants/2817/addons
Jira : https://testsigma.atlassian.net/browse/TE-29332
Added all ready present class to other applications
Summary by CodeRabbit
New Features
Chores