-
Notifications
You must be signed in to change notification settings - Fork 54
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
Revert "fix:[NEXT-455] Vulnerability for multiple asset types for a plugin" #2358
Conversation
…lugin (#…" This reverts commit e47803c.
WalkthroughThe changes update an S3 dependency version and refactor vulnerability upload logic. In the Changes
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
Suggested Reviewers
Poem
Tip 🌐 Web search-backed reviews and chat
✨ Finishing Touches
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
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: 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
📒 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 forGetObjectRequest
andS3Object
align with the revised logic of directly retrieving S3 objects.
61-63
: Check for empty lists in addition to null checks.
Ifentities
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.
RemovingclosedDate
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 fromaws-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.
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; | ||
} |
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
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.
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; | |
} |
Quality Gate passedIssues Measures |
Reverts #2357
Summary by CodeRabbit
Chores
Refactor