1921 bugcore missing agent with ping metrics #2401
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!2401
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2401/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: #1923
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/1923
Original created: 2025-11-03T15:33:24Z
Original updated: 2025-11-05T03:31:01Z
Original head: carverauto/serviceradar:1921-bugcore-missing-agent-with-ping-metrics
Original base: main
Original merged: 2025-11-05T03:30:28Z 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 missing ICMP metrics for agents by implementing device canonicalization and fallback database queries
Add service device update buffering and batch processing to improve device registry synchronization
Enhance ICMP metric processing with canonical device resolution and metadata enrichment
Improve database connection pooling and add IP field to canonical cache snapshots
Diagram Walkthrough
File Walkthrough
2 files
Add ICMP metrics database fallback lookupEnhance ICMP metrics with canonical device resolution9 files
Store IP address in canonical cache snapshotsImplement service device update buffering and batch processingAdd service device updates flush and fix formattingStore IP in canonical snapshot for sweep identitiesInitialize service device buffer in server setupAdd service device buffer and mutex to server structIncrease database connection pool and timeout settingsAdd GetICMPMetricsForDevice interface methodImplement ICMP metrics query with device and collector IP matching3 files
Add tests for service device registration logicMock unified devices query in test setupAdd mock for GetICMPMetricsForDevice methodImported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/1923#issuecomment-3481150508
Original created: 2025-11-03T15:34:06Z
PR Compliance Guide 🔍
(Compliance updated until commit
github.com/carverauto/serviceradar@a2c9cda150)Below is a summary of compliance checks for this PR:
Device ID injection risk
Description: The
deviceIDis constructed from untrusted input (pingResult.DeviceIDor generated fromsourceIP) without validation, potentially allowing device ID spoofing or injection attacksif the input contains malicious characters.
metrics.go [546-565]
Referred Code
SQL injection via escapeLiteral
Description: The
escapeLiteralfunction is called to sanitize user input for SQL query construction,but the function implementation is not visible in the diff, creating potential SQL
injection risk if the escaping is insufficient.
unified_devices.go [285-289]
Referred Code
Boolean parsing ambiguity
Description: The
parseBoolQueryfunction accepts various string representations of boolean values butreturns
false, truefor unrecognized values, which could lead to unexpected behavior wheninvalid input is treated as
falserather than being rejected.server.go [2255-2268]
Referred Code
🎫 #1921
SPIFFE credentials
Codebase context is not defined
Follow the guide to enable codebase context checks.
Generic: Comprehensive Audit Trails
Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.
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: Meaningful Naming and Self-Documenting Code
Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting
Status:
Generic variable names: Variables like 'result', 'hits', 'misses',
'snapshot', 'record' use generic names that don't clearly express
their specific purpose in the context of device canonicalization and identity resolution.
Referred Code
Generic: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation
Status:
Missing error context: Error handling in
resolveCanonicalDeviceandfetchCanonicalSnapshotlacks context aboutwhich device or IP failed, making debugging difficult in production.
Referred Code
Generic: Security-First Input Validation and Data Handling
Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities
Status:
Missing IP validation: The
deviceIPparameter extracted from query string is not validated before being used indatabase queries, potentially allowing injection of malicious input.
Referred Code
Compliance status legend
🟢 - Fully Compliant🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label
Previous compliance checks
Compliance check up to commit 69686f1
Unbounded input size
Description: Device metadata from ICMP processing is directly included in JSON without strict
validation or size limits, potentially allowing large or unexpected strings (e.g., service
names) to inflate storage or logs and cause resource exhaustion.
metrics.go [741-756]
Referred Code
🎫 #1921
data.
consistent metrics and metadata.
results are processed.
agents.
tombstoned.
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: 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: Comprehensive Audit Trails
Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.
Status:
Fallback Query Logging: The new database fallback for ICMP metrics logs only count/device ID and warns on error,
but it is unclear if sufficient audit details (user/request context) are captured for this
critical action.
Referred Code
Generic: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation
Status:
DB Error Context: New ICMP metrics query adds helpful context but may miss validation of inputs (e.g., empty
deviceID/IP) and detailed logging of filter values on failure paths.
Referred Code
Generic: Security-First Input Validation and Data Handling
Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities
Status:
Input Validation: The new GetICMPMetricsForDevice uses parameterized queries but does not validate or
normalize deviceID/deviceIP inputs before query execution, which may lead to unexpected
query breadth.
Referred Code
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/1923#issuecomment-3481156264
Original created: 2025-11-03T15:35:28Z
PR Code Suggestions ✨
Explore these optional code suggestions:
Correct device ID resolution logic
Correct the device ID resolution logic for ICMP metrics to use the
targetHostIPinstead of the
sourceIP.pkg/core/metrics.go [546-556]
Suggestion importance[1-10]: 9
__
Why: This suggestion identifies a critical bug where ICMP metrics could be associated with the monitoring agent's IP (
sourceIP) instead of the target device's IP (targetHost), leading to incorrect data attribution.