Skip to content
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

Revert "fix:[NEXT-455] Vulnerability for multiple asset types for a plugin" #2358

Merged

Conversation

rnithinpaladin
Copy link
Collaborator

@rnithinpaladin rnithinpaladin commented Feb 5, 2025

Reverts #2357

Summary by CodeRabbit

  • Chores

    • Updated an underlying library dependency to enhance overall stability.
  • Refactor

    • Streamlined the vulnerability data processing workflow with consolidated logic and improved error handling and logging.

Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

Walkthrough

The changes update an S3 dependency version and refactor vulnerability upload logic. In the pom.xml, the aws-java-sdk-s3 version is downgraded from 1.12.263 to 1.12.261. In the VulnerabilityAssociationManager class, the uploadVulnerabilityInfo method now directly retrieves an S3 object using GetObjectRequest, streamlines error handling, and consolidates operations by integrating the upload logic into one method while removing the redundant uploadEntity method.

Changes

File(s) Change Summary
jobs/pacman-data-shipper/pom.xml Downgraded aws-java-sdk-s3 dependency version from 1.12.263 to 1.12.261.
jobs/pacman-data-shipper/src/main/java/.../VulnerabilityAssociationManager.java Refactored uploadVulnerabilityInfo: direct S3 object retrieval via GetObjectRequest, streamlined error handling, consolidated upload logic, and removed uploadEntity.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Client
    participant Manager as VulnerabilityAssociationManager
    participant S3 as AWS S3
    participant Indexer as Indexing Service

    Caller->>Manager: uploadVulnerabilityInfo(filePrefix)
    Manager->>S3: GetObjectRequest(DATA_PATH, filePrefix)
    S3-->>Manager: Return object data
    Manager->>Manager: Process and validate object content
    Manager->>Indexer: Create index (if missing) & upload vulnerabilities
    Manager->>Indexer: Delete outdated documents
    Manager-->>Caller: Return processing result
Loading

Suggested Reviewers

  • ershad-paladin

Poem

Hoppity, hoppity, here I come to code,
A rabbit with changes on the upload road.
Dependencies trimmed, flows rearranged,
My little heart hops at how it's been changed.
In every line, a playful delight 🐰!

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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: 1

🧹 Nitpick comments (1)
jobs/pacman-data-shipper/src/main/java/com/tmobile/cso/pacman/datashipper/entity/VulnerabilityAssociationManager.java (1)

75-77: Consider handling partial upload or rollback scenarios.
While logging and deleting old documents appear correct, consider adding exception handling around the ES upload and delete calls to ensure partial failures do not silently degrade data quality.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e47803c and eb09f7b.

📒 Files selected for processing (2)
  • jobs/pacman-data-shipper/pom.xml (1 hunks)
  • jobs/pacman-data-shipper/src/main/java/com/tmobile/cso/pacman/datashipper/entity/VulnerabilityAssociationManager.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Shipper-Build
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: SonarCloud-Build
  • GitHub Check: Analyze (java)
🔇 Additional comments (5)
jobs/pacman-data-shipper/src/main/java/com/tmobile/cso/pacman/datashipper/entity/VulnerabilityAssociationManager.java (4)

6-7: Imports look appropriate.
The newly added imports for GetObjectRequest and S3Object align with the revised logic of directly retrieving S3 objects.


61-63: Check for empty lists in addition to null checks.
If entities is found but empty ([]), the subsequent flow still attempts normal processing. Consider verifying and logging empty lists as well for a more precise status update.


65-69: Index setup logic is straightforward.
Creating the index if it doesn’t exist is consistent with ensuring the data store is properly initialized. No concerns here.


70-74: Parallel stream map updates.
Removing closedDate from each object and adding _loaddate in a parallel stream is likely safe given each map is distinct. Ensure there is no shared-object concurrency risk.

jobs/pacman-data-shipper/pom.xml (1)

15-15: Confirm downgrade implications.
Downgrading from aws-java-sdk-s3 version 1.12.263 to 1.12.261 might forfeit bug fixes or features. Verify known issues and security advisories before finalizing.

Comment on lines +53 to +60
S3Object entitiesData = s3Client.getObject(new GetObjectRequest(BUCKET_NAME, DATA_PATH + "/" + filePrefix + ".data"));
try (BufferedReader reader = new BufferedReader(new InputStreamReader(entitiesData.getObjectContent()))) {
entities = objectMapper.readValue(reader.lines().collect(Collectors.joining("\n")), new TypeReference<List<Map<String, Object>>>() {
});
} catch (Exception e) {
LOGGER.info("{} data is empty", filePrefix);
continue;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Refine exception handling for clarity and troubleshooting.
Currently, all exceptions are logged as “data is empty”, which could mask parsing errors or S3 access issues. Consider logging the actual exception message or handling specific exceptions (e.g., file not found vs. parsing failure) to improve debuggability.

Proposed change:

 try (BufferedReader reader = new BufferedReader(new InputStreamReader(entitiesData.getObjectContent()))) {
     entities = objectMapper.readValue(reader.lines().collect(Collectors.joining("\n")),
         new TypeReference<List<Map<String, Object>>>() {});
-} catch (Exception e) {
-    LOGGER.info("{} data is empty", filePrefix);
+} catch (IOException e) {
+    LOGGER.error("Error reading/parsing data for file prefix {}: {}", filePrefix, e.getMessage());
     continue;
 }
📝 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.

Suggested change
S3Object entitiesData = s3Client.getObject(new GetObjectRequest(BUCKET_NAME, DATA_PATH + "/" + filePrefix + ".data"));
try (BufferedReader reader = new BufferedReader(new InputStreamReader(entitiesData.getObjectContent()))) {
entities = objectMapper.readValue(reader.lines().collect(Collectors.joining("\n")), new TypeReference<List<Map<String, Object>>>() {
});
} catch (Exception e) {
LOGGER.info("{} data is empty", filePrefix);
continue;
}
S3Object entitiesData = s3Client.getObject(new GetObjectRequest(BUCKET_NAME, DATA_PATH + "/" + filePrefix + ".data"));
try (BufferedReader reader = new BufferedReader(new InputStreamReader(entitiesData.getObjectContent()))) {
entities = objectMapper.readValue(reader.lines().collect(Collectors.joining("\n")), new TypeReference<List<Map<String, Object>>>() {
});
} catch (IOException e) {
LOGGER.error("Error reading/parsing data for file prefix {}: {}", filePrefix, e.getMessage());
continue;
}

@rnithinpaladin rnithinpaladin merged commit 92fdc6a into master Feb 5, 2025
58 checks passed
@rnithinpaladin rnithinpaladin deleted the revert-2357-fix/multiple-vulnerability-files branch February 5, 2025 10:08
Copy link

sonarqubecloud bot commented Feb 5, 2025

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.

2 participants