AIML-390: Add criticalVulnerabilities field to list_application_libraries response#79
Conversation
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
jason-at-contrast
left a comment
There was a problem hiding this comment.
this looks good, but question: if we are already there and have the vulns and are just counting.. wondering if we should just put medium/low counts in there as well? We do have a couple of customers that are concerned with medium as well (because of their current security posture). if you think it would slow this down tremendously, then naw.. but would it be faster than to have them prompt again for medium/low counts?
@jason-at-contrast The medium counts are not provided by teamserver. Only high and critical are, so we would need to manually count the results to add those other metrics. I can add that in, but i need another PR. This one is getting too big with other code review suggestions that I have already implemented. I'll create another story and add this later. I need to get this release out. The story for this is here: https://contrast.atlassian.net/browse/AIML-391 |
bba4026 to
5a256a9
Compare
949e49f to
6e6077b
Compare
TeamServer API returns critical_vulnerabilities in library response but the MCP server was not mapping this field. Users can now distinguish between CRITICAL and HIGH severity CVEs.
- Reorder fields in LibraryExtended: criticalVulnerabilities before highVulnerabilities to follow natural severity hierarchy (CRITICAL > HIGH) - Apply same ordering to AnonymousLibraryExtendedBuilder - Update test plan to document criticalVulnerabilities field - Fix test plan test cases 3.2 and 3.3 to verify both severity fields - Add criticalVulnerabilities to JSON examples in test plan appendix
5a256a9 to
9474acd
Compare
Rebased onto main after #78 merged.
Why This Change Exists
When using
list_application_libraries, users could seetotalVulnerabilitiesandhighVulnerabilitiescounts, but had no way to distinguish CRITICAL severity CVEs from HIGH severity CVEs. This matters because:criticalVulnerabilities, users had to manually count CRITICAL CVEs from the vulnerabilities arrayThe Problem:
{ "filename": "tomcat-embed-core-10.1.12.jar", "totalVulnerabilities": 16, "highVulnerabilities": 9, // No way to know how many are CRITICAL without parsing the array }TeamServer's API already returns
critical_vulnerabilities, but the MCP server wasn't mapping it.Approach We Chose
Add the missing
criticalVulnerabilitiesfield toLibraryExtendedwith proper Gson serialization annotation. This is a simple field mapping - no logic changes needed since TeamServer already provides the data.Outcome of this Change
Users can now immediately see CRITICAL vs HIGH severity distribution:
{ "filename": "tomcat-embed-core-10.1.12.jar", "totalVulnerabilities": 16, "criticalVulnerabilities": 4, // ← NEW: 4 CRITICAL CVEs "highVulnerabilities": 9, // Only HIGH, not CRITICAL }Verified with live data:
The Chain of Logic
1. Discovery: The Missing Field
Investigation of TeamServer's library API revealed it returns
critical_vulnerabilities:But
LibraryExtended.javaonly mappedtotalVulnerabilitiesandhighVulnerabilities.2. Scope Decision
Found 14+ unmapped fields (licenses, tags, versions_behind, etc.). Decision: Keep this PR focused on just
criticalVulnerabilities- the field users need most for security prioritization.3. Implementation: Field Addition
Added the field with
@SerializedNameto map from API's snake_case:Lombok's
@Dataauto-generates the getter/setter.4. Documentation Updates
Updated tool description so AI agents know the field exists, and clarified that
highVulnerabilitiescounts only HIGH (not CRITICAL+HIGH as might be assumed).What Changed
LibraryExtended.javacriticalVulnerabilitiesfield with@SerializedNameLibraryExtendedTest.javaAnonymousLibraryExtendedBuilder.javaAnonymousLibraryExtendedBuilderTest.javaListApplicationLibrariesTool.javalist-application-libraries-manual-test.mdKey code change:
Test Coverage
Unit Tests:
LibraryExtendedTest.criticalVulnerabilities_should_be_settable_and_gettable- verifies field worksAnonymousLibraryExtendedBuilderTest- 2 tests for builder supportIntegration Tests:
ListApplicationLibrariesToolIT- verifies field populated from live APIManual Tests (passed):
criticalVulnerabilitiesappears in responsecriticalVulnerabilities: 4highVulnerabilities: 9All 623 unit tests pass. Integration tests pass.