-
Notifications
You must be signed in to change notification settings - Fork 5
AIML-228: Add appID and appName to VulnLight record [STACKED] #28
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
Conversation
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.
Pull Request Overview
This PR adds appID and appName fields to the VulnLight record, enabling direct correlation of vulnerabilities to their owning applications without requiring additional API calls. This enhancement improves usability for AI agents and users working with application-specific vulnerability tools.
Key Changes:
- Added
appIDandappNamefields toVulnLightrecord with comprehensive JavaDoc - Updated
VulnerabilityMapperto safely extract application data from trace objects - Added
APPLICATIONexpand parameter to all vulnerability query operations inAssessService
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
VulnLight.java |
Added appID and appName fields with detailed JavaDoc documentation |
VulnerabilityMapper.java |
Added null-safe extraction of application ID and name from traces |
AssessService.java |
Added APPLICATION expand to vulnerability queries |
VulnerabilityMapperTest.java |
Added comprehensive unit tests for null and populated application cases |
AssessServiceIntegrationTest.java |
Enhanced integration tests to verify application fields |
CLAUDE.md |
Documentation updates for coding standards and AI workflow improvements |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/main/java/com/contrast/labs/ai/mcp/contrast/mapper/VulnerabilityMapper.java
Show resolved
Hide resolved
src/test/java/com/contrast/labs/ai/mcp/contrast/AssessServiceIntegrationTest.java
Show resolved
Hide resolved
fd0b642 to
8c62632
Compare
Enables correlation of vulnerabilities to their owning applications by including application identifiers in VulnLight objects returned by all vulnerability listing tools. Changes: - Add appID and appName fields to VulnLight record with JavaDoc - Update VulnerabilityMapper to extract application data from Trace - Add APPLICATION expand to all vulnerability query operations - Add unit tests for application field mapping (null and populated cases) - Add integration test assertions verifying appID/appName presence - All tests pass (250/250 unit + integration tests) Benefits: - Users can immediately identify which app owns each vulnerability - Eliminates need to query all apps to find vulnerability ownership - Simplifies testing and debugging of app-specific vulnerability tools - Backwards compatible (new fields only, none removed) Tools affected: - list_all_vulnerabilities - list_vulnerabilities - list_vulns_by_app_and_metadata - list_vulns_by_app_latest_session 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Documents the process for creating draft PRs that depend on unmerged PRs (stacked branches), including: - Identifying the base PR - Creating draft PR with proper configuration - Required warning message format - Verification steps - Example command Triggered by phrases like "ready for stacked PR" or "ready for draft review". 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Documents Java coding conventions for the project: - Prefer var for local variables when type is obvious - Use isEmpty() instead of size() comparisons for collections 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Document the complete workflow for promoting a draft stacked PR to ready-for-review after its base PR has been merged to main. Includes: - Prerequisites and validation steps - 10-step detailed workflow (verify, rebase, push, update, test) - Full example commands from AIML-224 experience - Common issues and troubleshooting guidance - User experience phrases: 'move stacked PR to ready', 'promote stacked PR', etc. This codifies the process used successfully for PR #25 (AIML-224).
Enhanced the workflow documentation to clarify stacked branch handling and ensure consistent high-quality PR descriptions: - Added Workflow Overview with decision tree and label definitions - Clarified stacked-branch label usage for branches based on PR branches - Created shared "Creating High-Quality PR Descriptions" section - Updated "Moving to Review" for standard PRs (pr-created + in-review labels) - Updated "Stacked PRs" workflow (pr-created label only, draft status) - Enhanced "Promoting Stacked PR" to add in-review label on promotion - Emphasized human review as bottleneck requiring effortless reviews Key improvements: - Consistent PR description quality across both workflows - Clear label lifecycle (pr-created vs in-review timing) - Stacked beads must depend on parent bead - Both workflows reference shared description format 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
d8dc3e3 to
62909a8
Compare
seschis
left a 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.
lgtm
Rebased onto main after #31 (AIML-226) merged.
Summary
This PR adds application identification fields (
appIDandappName) to vulnerability responses, eliminating the need for users to perform additional API calls to determine which application owns a vulnerability.Why
Problem: When listing vulnerabilities across an organization or filtering by various criteria, users received vulnerability data without any indication of which application each vulnerability belonged to. This forced users to either:
Impact: This created unnecessary complexity for AI agents and users trying to understand their security posture, especially when working with vulnerabilities across multiple applications.
What
Added two new fields to the
VulnLightrecord:appID: Application UUID that owns the vulnerabilityappName: Human-readable application display nameThese fields are now populated in all vulnerability listing tool responses:
list_all_vulnerabilities- Org-wide vulnerability querieslist_vulnerabilities- App-specific vulnerability querieslist_vulns_by_app_and_metadata- Session metadata filtered querieslist_vulns_by_app_latest_session- Latest session filtered queriesHow
Technical Approach:
appIDandappNamefields, including comprehensive JavaDocAPPLICATIONexpansion via the Contrast SDK'sTraceExpandValue.APPLICATIONenum:listVulnsByAppId()listVulnsInAppByNameAndSessionMetadata()getAllVulnerabilities()Design Decision: Used the SDK's native expansion mechanism rather than performing separate lookups, ensuring efficient single-request retrieval of application context.
Code Walkthrough
1. VulnLight Record Enhancement (VulnLight.java)
Added comprehensive JavaDoc explaining all fields, making the record self-documenting for API consumers.
2. VulnerabilityMapper Changes (VulnerabilityMapper.java:49-66)
Null-safe extraction ensures backward compatibility if APPLICATION expansion is missing from a query.
3. Service Layer Updates (AssessService.java)
Added
TraceExpandValue.APPLICATIONto all three vulnerability query methods:listVulnsByAppId()- Already had SESSION_METADATA and SERVER_ENVIRONMENTS expandlistVulnsInAppByNameAndSessionMetadata()- Added APPLICATION to SESSION_METADATA expandgetAllVulnerabilities()- Added APPLICATION to existing SERVER_ENVIRONMENTS and SESSION_METADATA expandThis ensures the SDK includes application objects in the trace responses.
Testing
Unit Tests (VulnerabilityMapperTest.java):
toVulnLight_BasicTrace_TransformsCorrectly- Updated to verify appID and appName extraction (lines 64-66, 90-91)toVulnLight_TraceWithNullApplication_HandlesGracefully- NEW test verifying null safety (lines 411-438)toVulnLight_TraceWithApplication_ExtractsAppData- NEW test verifying correct extraction (lines 440-475)Integration Tests (AssessServiceIntegrationTest.java):
testListAllVulnerabilities()to assert appID and appName are non-null and non-empty (lines 202-206)"App: My App (app-123)"(line 207)Test Results:
Manual Verification: Tested against live Contrast instance, confirmed appID and appName appear correctly in all vulnerability listing responses.
Benefits
Documentation Updates
Also includes comprehensive updates to
CLAUDE.md:var, useisEmpty())These documentation changes improve the development process for all contributors working with AI assistance.
Related: