-
Notifications
You must be signed in to change notification settings - Fork 16
feat/CUS-8160-Added Store Device Screen Dimensions addon for Android & iOS #245
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/CUS-8160-Added Store Device Screen Dimensions addon for Android & iOS #245
Conversation
WalkthroughAdds a new add-on module that captures device screen dimensions on Android and iOS, stores them as "widthxheight" in a runtime variable, includes Maven build configuration, and adds an SDK properties file with an API key. Changes
Sequence Diagram(s)sequenceDiagram
participant Runner as Test Runner
participant Action as StoreDeviceScreenDimensions
participant Driver as MobileDriver (Android/iOS)
participant Runtime as RuntimeDataStore
Runner->>Action: invoke execute(variableName)
Action->>Driver: manage().window().getSize()
Driver-->>Action: Size(width,height)
Action->>Action: format "{width}x{height}"
Action->>Runtime: set(variableName, formattedDimensions)
Runtime-->>Action: ack
Action-->>Runner: Result.SUCCESS (message)
Note right of Action #DDEBF7: on exception -> set FAILED,\nrecord error + stack trace
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (3)
store_device_screen_dimensions/src/main/java/com/testsigma/addons/android/StoreDeviceScreenDimensions.java (1)
32-56: LGTM: Solid implementation with good error handling.The execute method correctly:
- Retrieves window dimensions via AndroidDriver
- Formats as "widthxheight"
- Stores in runtime variable
- Provides clear success/error messages
- Catches and logs exceptions appropriately
Optional: Remove unnecessary
NoSuchElementExceptiondeclaration.The method signature declares
throws NoSuchElementException, but this exception is already a runtime exception and doesn't need explicit declaration. The catch block already handles all exceptions viacatch (Exception e).-public Result execute() throws NoSuchElementException { +public Result execute() {If you apply this change, also remove the unused import on line 5.
store_device_screen_dimensions/src/main/java/com/testsigma/addons/ios/StoreDeviceScreenDimensions.java (2)
15-54: Consider extracting common logic to reduce duplication.The Android and iOS implementations are nearly identical (95%+ code duplication). The only differences are:
- The driver type cast (AndroidDriver vs IOSDriver)
- The base class (AndroidAction vs IOSAction)
- The applicationType annotation
Consider creating a shared base class or utility method to eliminate duplication:
protected Result executeStoreScreenDimensions(WebDriver driver, String driverType) { logger.info("Starting to fetch " + driverType + " device screen dimensions..."); Result result = Result.SUCCESS; try { Dimension size = driver.manage().window().getSize(); logger.info("Size is: " + size.width + "x" + size.height); String dimensions = size.getWidth() + "x" + size.getHeight(); runtimeData.setKey(variableName.getValue().toString()); runtimeData.setValue(dimensions); setSuccessMessage("Successfully stored device dimensions '" + dimensions + "' in runtime variable: " + runtimeData.getKey()); logger.info("Device dimensions: " + dimensions); } catch (Exception e) { result = Result.FAILED; String errorMsg = "Failed to retrieve device dimensions: "; setErrorMessage(errorMsg + ExceptionUtils.getMessage(e)); logger.warn(errorMsg + ExceptionUtils.getStackTrace(e)); } return result; }Then each platform-specific class would simply call:
return executeStoreScreenDimensions(this.driver, "iOS"); // or "Android"This improves maintainability and reduces the risk of copy-paste errors like the one on line 31.
30-30: Optional: Remove unnecessary exception declaration.Same as the Android version -
NoSuchElementExceptionis a runtime exception and doesn't need explicit declaration.-public Result execute() throws NoSuchElementException { +public Result execute() {If you apply this change, also remove the unused import on line 13.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
store_device_screen_dimensions/pom.xml(1 hunks)store_device_screen_dimensions/src/main/java/com/testsigma/addons/android/StoreDeviceScreenDimensions.java(1 hunks)store_device_screen_dimensions/src/main/java/com/testsigma/addons/ios/StoreDeviceScreenDimensions.java(1 hunks)store_device_screen_dimensions/src/main/resources/testsigma-sdk.properties(1 hunks)
🔇 Additional comments (2)
store_device_screen_dimensions/src/main/java/com/testsigma/addons/android/StoreDeviceScreenDimensions.java (1)
17-22: LGTM: Clean action annotation and class structure.The
@Actionannotation provides clear, descriptive text and specifies the correct application type for Android.store_device_screen_dimensions/pom.xml (1)
59-63: I'll perform a web search to verify if there are any publicly reported security vulnerabilities for Jackson 2.13.0:No critical security vulnerabilities found for jackson-annotations 2.13.0.
Jackson-databind versions before 2.13.0 were vulnerable to a denial of service via large depth of nested objects, but 2.13.0 itself addressed this. Jackson-annotations 2.13.0 had no changes since 2.12 and is a minimal annotations-only package with lower attack surface compared to jackson-databind. The GitHub Security Advisory search and web research found no published CVEs specific to jackson-annotations 2.13.0. This version is acceptable for use.
| <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.
🧩 Analysis chain
Verify TestNG version for security vulnerabilities.
TestNG 6.14.3 was released in 2018 and is significantly outdated. Older versions may contain security vulnerabilities or compatibility issues with newer Java versions.
🏁 Script executed:
#!/bin/bash
# Check for security advisories for TestNG version 6.14.3
gh api graphql -f query='
{
securityVulnerabilities(first: 10, ecosystem: MAVEN, package: "org.testng:testng") {
nodes {
advisory {
summary
severity
publishedAt
}
vulnerableVersionRange
firstPatchedVersion {
identifier
}
}
}
}'Length of output: 469
Upgrade TestNG to 7.5.1 or later to address HIGH severity Path Traversal vulnerability.
TestNG 6.14.3 is vulnerable to a Path Traversal security issue (CVE severity: HIGH, published 2022-11-19). The vulnerability affects TestNG versions >= 6.13, < 7.5.1, with patches available in version 7.5.1. Update the dependency to version 7.5.1 or newer.
🤖 Prompt for AI Agents
In store_device_screen_dimensions/pom.xml around lines 42 to 46, the project
depends on TestNG 6.14.3 which is vulnerable; update the <version> for the
org.testng:testng dependency to 7.5.1 (or a later compatible 7.x) in the pom,
run a full build (mvn -U clean install) and re-run tests to ensure
compatibility, and if any test failures occur adjust test code or test-suite
XMLs to match TestNG 7.x behavior.
...ce_screen_dimensions/src/main/java/com/testsigma/addons/ios/StoreDeviceScreenDimensions.java
Outdated
Show resolved
Hide resolved
| @@ -0,0 +1 @@ | |||
| testsigma-sdk.api.key=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyMjMyMmM2Ni04NWYzLWIyN2UtN2FiOS0zM2U2M2Q4OWM1MGIiLCJ1bmlxdWVJZCI6IjU1NDkiLCJpZGVudGl0eUFjY291bnRVVUlkIjoiMzUifQ.qXL117SB2sZhSEDz9IQ7a9zZn3pz8RPdFh3EItAKtL5EYlgHMJZxOBdl3OWNy3sJrbI_E3gsWoaoRlXz5X8n9Q 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.
CRITICAL SECURITY ISSUE: Hardcoded API key in public repository.
This file contains a JWT token that will be exposed when the addon is published publicly. The token contains sensitive information including user identifiers (uniqueId: 5549, identityAccountUUId: 35). Hardcoded credentials in source code pose severe security risks:
- Anyone with repository access can extract and misuse the API key
- The token cannot be easily rotated without code changes
- This violates security best practices and could lead to unauthorized access
Recommended solutions:
-
Remove this file entirely and load the API key from environment variables:
String apiKey = System.getenv("TESTSIGMA_SDK_API_KEY");
-
Use a configuration management system that keeps credentials outside source control
-
Document in README that users must provide their own API key via environment variable or secure configuration
-
Immediately rotate this exposed token as it's now visible in the PR
🤖 Prompt for AI Agents
In store_device_screen_dimensions/src/main/resources/testsigma-sdk.properties
around line 1 there is a hardcoded JWT API key which must be removed
immediately; delete the file or remove the secret value from source, replace
usage with loading the API key from a secure source such as an environment
variable (e.g. TESTSIGMA_SDK_API_KEY) or a secrets/config management system, add
the properties file to .gitignore if needed and update code/config to fail fast
with a clear error when the env var is missing, update the README with
instructions for providing the API key, and ensure the exposed token is rotated
immediately outside this PR.
Publish this addon as public
Addon Name: Store Device Screen Dimensions
Jarvis Link: https://jarvis.testsigma.com/ui/tenants/2817/addons
Jira : https://testsigma.atlassian.net/browse/CUS-8160
Added Store Device Screen Dimensions addon for Android & iOS
Summary by CodeRabbit
New Features
Chores