-
Notifications
You must be signed in to change notification settings - Fork 648
feat: add CPE field to Service struct for Nmap service detection #1609
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
base: dev
Are you sure you want to change the base?
Conversation
Add CPEs field to port.Service struct to expose Common Platform Enumeration data from Nmap service detection. This enables consumers to access standardized vendor/product/version information parsed from CPE strings.
WalkthroughThe changes add CPE (Common Platform Enumeration) support by introducing a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. 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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
pkg/port/port.go (1)
35-52: LGTM! CPEs field addition follows existing patterns.The new
CPEsfield is properly structured with appropriate JSON tags. Theomitemptytag ensures the field is excluded from JSON output when empty, which is the right behavior for optional CPE data.Optional: Consider adding a documentation comment
While consistent with the existing undocumented fields, adding a brief comment explaining CPEs would improve clarity for future maintainers:
+ // CPEs contains Common Platform Enumeration identifiers for the detected service CPEs []string `json:"cpes,omitempty"`
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
pkg/port/port.gopkg/runner/nmap.go
🧰 Additional context used
🧬 Code graph analysis (1)
pkg/runner/nmap.go (1)
pkg/port/port.go (1)
Service(35-52)
🔇 Additional comments (2)
pkg/runner/nmap.go (2)
291-291: CPEs field assignment looks correct.The CPEs field is properly assigned with the converted CPE strings, and it's correctly positioned within the Service struct initialization alongside other service metadata fields.
269-274: The CPE conversion implementation is correct and well-optimized. The nmap library v3.0.6 supports theService.CPEsfield, and thenmap.CPEto string conversion pattern used here (line 273) is consistent with existing usage elsewhere in the codebase (line 171). The pre-allocation strategy is efficient and handles edge cases properly.
|
|
||
| // Convert service information if available | ||
| if nmapPort.Service.Name != "" { | ||
| // Convert CPEs from nmap.CPE to []string |
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.
| // Convert CPEs from nmap.CPE to []string |
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.