2036 bugui agents showing sysmon collections incorrectly #2491
No reviewers
Labels
No labels
1week
2weeks
Failed compliance check
IP cameras
NATS
Possible security concern
Review effort 1/5
Review effort 2/5
Review effort 3/5
Review effort 4/5
Review effort 5/5
UI
aardvark
accessibility
amd64
api
arm64
auth
back-end
bgp
blog
bug
build
checkers
ci-cd
cleanup
cnpg
codex
core
dependencies
device-management
documentation
duplicate
dusk
ebpf
enhancement
eta 1d
eta 1hr
eta 3d
eta 3hr
feature
fieldsurvey
github_actions
go
good first issue
help wanted
invalid
javascript
k8s
log-collector
mapper
mtr
needs-triage
netflow
network-sweep
observability
oracle
otel
plug-in
proton
python
question
reddit
redhat
research
rperf
rperf-checker
rust
sdk
security
serviceradar-agent
serviceradar-agent-gateway
serviceradar-web
serviceradar-web-ng
siem
snmp
sysmon
topology
ubiquiti
wasm
wontfix
zen-engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
carverauto/serviceradar!2491
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2491/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from GitHub pull request.
Original GitHub pull request: #2037
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2037
Original created: 2025-12-01T02:29:35Z
Original updated: 2025-12-01T02:36:29Z
Original head: carverauto/serviceradar:2036-bugui-agents-showing-sysmon-collections-incorrectly
Original base: main
Original merged: 2025-12-01T02:36:26Z by @mfreeman451
User description
IMPORTANT: Please sign the Developer Certificate of Origin
Thank you for your contribution to ServiceRadar. Please note, when contributing, the developer must include
a DCO sign-off statement indicating the DCO acceptance in one commit message. Here
is an example DCO Signed-off-by line in a commit message:
Describe your changes
Issue ticket number and link
Code checklist before requesting a review
PR Type
Bug fix, Enhancement
Description
Fix phantom device creation from checker host IPs by detecting collector IPs
Add stable service device IDs for core services (datasvc, sync, mapper, otel, zen)
Implement heuristic detection of ephemeral Docker container IPs with collector hostnames
Add database migration to clean up existing phantom devices while preserving service devices
Diagram Walkthrough
File Walkthrough
3 files
Add collector IP detection to skip phantom devicesMigrate database to remove phantom devices with backupRollback migration to restore phantom devices from backup5 files
Add comprehensive tests for device filtering logicAdd tests for core service registrationAdd tests for core service device updatesFix flaky cache expiry test with eventual consistencyIncrease watch context timeout to reduce CI flakiness4 files
Refactor device registration to support core servicesAdd core service detection and registration logicAdd ServiceType constants for core servicesAdd CreateCoreServiceDeviceUpdate helper function1 files
Add Bazel build and image push targets3 files
Document design proposal for phantom device fixDefine requirements for service device IDs and checker filteringTrack implementation tasks and test coverageImported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2037#issuecomment-3594269806
Original created: 2025-12-01T02:30:12Z
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
Risky data deletion
Description: The cleanup migration deletes rows from unified_devices based on regex IP and hostname
heuristics, which risks unintended data loss if criteria are overly broad or metadata
fields vary; ensure execution only in controlled environments and with validated backups.
00000000000011_cleanup_phantom_devices.up.sql [12-62]
Referred Code
🎫 #2036
targets producing metrics.
only create devices for their targets (e.g., SNMP target 192.168.1.1).
inventory.
survive IP changes.
legitimate service devices.
and real targets still do, across agent/poller restarts and Docker/Kubernetes IP churn.
that service devices (serviceradar:*) are preserved.
Codebase context is not defined
Follow the guide to enable codebase context checks.
Generic: Meaningful Naming and Self-Documenting Code
Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting
Status: Passed
Generic: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation
Status: Passed
Generic: Secure Error Handling
Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.
Status: Passed
Generic: Secure Logging Practices
Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.
Status: Passed
Generic: Security-First Input Validation and Data Handling
Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities
Status: Passed
Generic: Comprehensive Audit Trails
Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.
Status:
Unstructured Logging: New debug logs for skipping device creation and registration paths lack explicit
user/action identifiers and structured audit context, which may be insufficient for
comprehensive audit trails.
Referred Code
Compliance status legend
🟢 - Fully Compliant🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2037#issuecomment-3594272422
Original created: 2025-12-01T02:31:31Z
PR Code Suggestions ✨
Explore these optional code suggestions:
Hardcoded Docker IP ranges are brittle
The hardcoded list of Docker IP ranges used for phantom device detection is
brittle. These ranges should be made configurable to support different container
runtime network configurations.
Examples:
pkg/core/devices.go [427-453]
pkg/db/cnpg/migrations/00000000000011_cleanup_phantom_devices.up.sql [18-25]
Solution Walkthrough:
Before:
After:
Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies that hardcoding Docker IP ranges in
isDockerBridgeIPis a brittle design choice that will fail in custom environments, and making it configurable would significantly improve the solution's robustness.Use robust network operators for IP matching
Replace the regex-based IP matching in the SQL migration with PostgreSQL's
inettype and
<<operator for a more robust and efficient query.pkg/db/cnpg/migrations/00000000000011_cleanup_phantom_devices.up.sql [18-25]
Suggestion importance[1-10]: 7
__
Why: The suggestion correctly points out that using regex for IP matching is brittle and proposes using PostgreSQL's native
inettype and network operators, which is more robust, correct, and performant.Improve performance by pre-parsing CIDRs
To improve performance and robustness, pre-parse the hardcoded CIDR strings in
an
init()function and panic on any parsing errors.pkg/core/devices.go [426-453]
Suggestion importance[1-10]: 5
__
Why: The suggestion correctly identifies an inefficiency and proposes a standard Go pattern to fix it, improving both performance and robustness by pre-parsing CIDRs in an
initfunction.