Skip to content

Conversation

@ManojTestsigma
Copy link
Contributor

@ManojTestsigma ManojTestsigma commented Jan 6, 2026

please review this addon and publish as PUBLIC

Addon name : ExcelActions_cloud
Addon accont: https://jarvis.testsigma.com/ui/tenants/2817/addons
Jira: https://testsigma.atlassian.net/browse/CUS-9936

fix

Added 2 new NLP's to check if the sheet name is present in excel file

Summary by CodeRabbit

  • New Features

    • Added capability to verify a sheet name exists at a specific index position in Excel files.
    • Added capability to verify a sheet name exists anywhere in Excel files.
    • Both features support local file paths and remote files via HTTP/HTTPS URLs.
  • Chores

    • Version bump to 1.0.20.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 6, 2026

📝 Walkthrough

Walkthrough

This pull request introduces two new WebAction classes for Excel sheet verification (VerifySheetNameAtIndex and VerifySheetNameExists) that support local file paths and HTTP/HTTPS URLs, and bumps the project version from 1.0.19 to 1.0.20. Both classes integrate with Apache POI for workbook validation.

Changes

Cohort / File(s) Summary
Version Update
excelActions_cloud/pom.xml
Bumps Maven project version from 1.0.19 to 1.0.20
Excel Sheet Verification Actions
excelActions_cloud/src/main/java/com/testsigma/addons/web/VerifySheetNameAtIndex.java, excelActions_cloud/src/main/java/com/testsigma/addons/web/VerifySheetNameExists.java
Two new WebAction classes: VerifySheetNameAtIndex validates that a sheet exists at a specific 0-based index; VerifySheetNameExists validates sheet name existence. Both support local files and URL downloads, handle exceptions (NumberFormatException, IOException), use try-with-resources for file I/O, and return detailed success/failure messages with sheet counts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • Ganesh-Testsigma
  • vigneshtestsigma

Poem

🐰 Hop, hop! Excel sheets now verified with glee,
By index or by name, the truth we shall see,
Local files or URLs from afar they come,
POI and TestSigma dance—validation is done! 📊✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding 2 new NLPs to verify sheet name presence in Excel files, which aligns with the implementation of VerifySheetNameAtIndex and VerifySheetNameExists classes.
✨ Finishing touches
  • 📝 Generate docstrings

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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

🤖 Fix all issues with AI Agents
In
@excelActions_cloud/src/main/java/com/testsigma/addons/web/VerifySheetNameAtIndex.java:
- Around line 107-138: getExcelFile and downloadFile are duplicated in
VerifySheetNameAtIndex (and VerifySheetNameExists); extract them into a shared
utility (e.g., ExcelFileUtils) and replace the local implementations with calls
to ExcelFileUtils.getExcelFile(filePath, logger) (and
ExcelFileUtils.downloadFile if needed). Move the logic from the private methods
getExcelFile and downloadFile into public static methods in ExcelFileUtils
(accepting Logger), update both action classes to call the utility, and remove
the duplicated private methods from VerifySheetNameAtIndex and
VerifySheetNameExists.
- Around line 124-138: The downloadFile method in VerifySheetNameAtIndex has the
same SSRF and resource issues as VerifySheetNameExists; replace its raw
URL.openStream usage with a secure downloader: validate and whitelist the URL
scheme/host (or disallow private IPs), use HttpURLConnection (or a shared
utility method) with connection and read timeouts, check/limit Content-Length
and enforce a maximum streamed byte limit while copying, ensure
try-with-resources and deleteOnExit or explicit temp-file cleanup on failure,
and factor the logic into a shared utility (e.g.,
SecureFileDownloader.downloadFile) so both VerifySheetNameAtIndex and
VerifySheetNameExists reuse the hardened implementation.

In
@excelActions_cloud/src/main/java/com/testsigma/addons/web/VerifySheetNameExists.java:
- Around line 113-127: The downloadFile method has multiple security and
robustness issues; update downloadFile to: validate the input URL scheme (only
allow http/https), resolve and reject hosts that map to
local/private/loopback/CIDR ranges to mitigate SSRF, and enforce a maximum
allowed content size before streaming (check Content-Length and abort if too
large or use a streaming counter and abort at limit). Replace direct
url.openStream() with an HTTP client configured with connect/read timeouts and
redirect limits, validate the Content-Type against allowed Excel MIME types, and
handle missing filename safely (fallback to a generated name instead of relying
on Paths.get(url.getPath()).getFileName()). Ensure tempFile is deleted on
failures and document caller responsibility to delete it on success (use
try-with-resources and finally cleanup), and throw clear exceptions when
validation or download limits are violated; reference symbols: downloadFile,
fileName, tempFile, logger.info.
🧹 Nitpick comments (1)
excelActions_cloud/src/main/java/com/testsigma/addons/web/VerifySheetNameExists.java (1)

96-108: Add file extension validation.

The method should verify that the file has a valid Excel extension (.xlsx or .xls) before attempting to open it. This would provide clearer error messages when users provide incorrect file types.

🔎 Proposed enhancement
 private File getExcelFile(String filePath) throws IOException {
     if (filePath.startsWith("http://") || filePath.startsWith("https://")) {
         logger.info("Downloading file from URL: " + filePath);
         return downloadFile(filePath);
     } else {
         logger.info("Using local file: " + filePath);
         File file = new File(filePath);
         if (!file.exists()) {
             throw new IOException("File not found: " + filePath);
         }
+        String lowerPath = filePath.toLowerCase();
+        if (!lowerPath.endsWith(".xlsx") && !lowerPath.endsWith(".xls")) {
+            throw new IOException("Invalid file type. Expected .xlsx or .xls file: " + filePath);
+        }
         return file;
     }
 }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03547c9 and 99ff3e1.

📒 Files selected for processing (3)
  • excelActions_cloud/pom.xml
  • excelActions_cloud/src/main/java/com/testsigma/addons/web/VerifySheetNameAtIndex.java
  • excelActions_cloud/src/main/java/com/testsigma/addons/web/VerifySheetNameExists.java
🔇 Additional comments (3)
excelActions_cloud/pom.xml (1)

9-9: LGTM!

The version bump to 1.0.20 is appropriate for adding new NLP actions.

excelActions_cloud/src/main/java/com/testsigma/addons/web/VerifySheetNameExists.java (1)

35-91: LGTM with minor inefficiency note.

The execute method correctly uses try-with-resources for proper resource management and handles exceptions appropriately. The iteration logic at lines 57-64 continues checking all sheets even after finding a match, which is slightly inefficient but allows comprehensive logging.

excelActions_cloud/src/main/java/com/testsigma/addons/web/VerifySheetNameAtIndex.java (1)

36-102: Excellent implementation with proper validation.

The execute method demonstrates good defensive programming with index range validation (lines 58-65) and appropriate exception handling for NumberFormatException (lines 89-93). The error messages are clear and helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants