feat: add CPE field to Service struct for Nmap service detection#1609
feat: add CPE field to Service struct for Nmap service detection#1609ehsandeep merged 2 commits intoprojectdiscovery:devfrom
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.
WalkthroughAdded CPE support by introducing a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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.
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.
Co-authored-by: Nakul Bharti <knakul853@gmail.com>
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.