Skip to content

Conversation

@b0bleet
Copy link

@b0bleet b0bleet commented Dec 27, 2025

Summary by CodeRabbit

Release Notes

  • New Features
    • Services discovered during network scans now include Common Platform Enumeration (CPE) identifiers when available from the underlying scan data. CPE information is automatically extracted and integrated into service metadata, enabling improved platform identification, better asset inventory management, and more accurate classification of detected services and systems.

✏️ Tip: You can customize this high-level summary in your review settings.

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.
@auto-assign auto-assign bot requested a review from dwisiswant0 December 27, 2025 10:40
@coderabbitai
Copy link

coderabbitai bot commented Dec 27, 2025

Walkthrough

The changes add CPE (Common Platform Enumeration) support by introducing a new CPEs field to the port Service structure and implementing CPE data propagation logic from nmap scan results to naabu port service information.

Changes

Cohort / File(s) Summary
CPE Field Addition
pkg/port/port.go
Added CPEs []string field with JSON tag json:"cpes,omitempty" to the Service struct to store Common Platform Enumeration identifiers.
CPE Propagation Logic
pkg/runner/nmap.go
Implemented CPE extraction and propagation during nmap result processing. When a port has an associated service name, CPE data from nmap is transferred to the naabu port's Service.CPEs field.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A rabbit hops through service ports with glee,
Collecting CPEs from nmap's spree,
Each platform enumerated, catalogued with care,
New fields and data flowing through the air,
Security scanning gets a little more fair! 🔍

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a CPE field to the Service struct for Nmap service detection, which aligns with the changeset modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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 CPEs field is properly structured with appropriate JSON tags. The omitempty tag 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

📥 Commits

Reviewing files that changed from the base of the PR and between e3349aa and 75df497.

📒 Files selected for processing (2)
  • pkg/port/port.go
  • pkg/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 the Service.CPEs field, and the nmap.CPE to 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Convert CPEs from nmap.CPE to []string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants