schema fixes, agent update #2636
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!2636
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2636/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: #2229
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2229
Original created: 2026-01-08T18:54:12Z
Original updated: 2026-01-08T20:46:37Z
Original head: carverauto/serviceradar:updates/tenant_schema_work
Original base: testing
Original merged: 2026-01-08T20:46:30Z 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
Enhancement
Description
Add automatic tenant discovery via cluster RPC when not configured
Refactor tenant configuration resolution with helper functions
Add tenant_id field to OCSF devices and agents tables
Update agent schema to include device_uid, host, port, spiffe_identity, status fields
Support multiple tenant ID environment variable sources
Diagram Walkthrough
File Walkthrough
config.ex
Add cluster RPC tenant discovery with fallbackelixir/serviceradar_agent_gateway/lib/serviceradar_agent_gateway/config.ex
sources unavailable
functions
SERVICERADAR_PLATFORM_TENANT_IDenvironment variable inaddition to
GATEWAY_TENANT_IDcluster discovery
agent_gateway_sync.ex
Add platform tenant info RPC endpointelixir/serviceradar_core/lib/serviceradar/edge/agent_gateway_sync.ex
get_platform_tenant_info/0function for RPC calls fromagent-gateway
agent.ex
Include tenant_id in agent upsertelixir/serviceradar_core/lib/serviceradar/infrastructure/agent.ex
20260108011004_add_ocsf_and_identity_tables.exs
Add tenant_id and enhance OCSF schemaelixir/serviceradar_core/priv/repo/tenant_migrations/20260108011004_add_ocsf_and_identity_tables.exs
ocsf_agents
ocsf_agents
docker-compose.yml
Document tenant auto-discovery configurationdocker-compose.yml
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2229#issuecomment-3725218613
Original created: 2026-01-08T18:55:16Z
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
Trusted RPC discovery
Description: The new cluster RPC tenant auto-discovery trusts the first connected node whose name
contains
"serviceradar_core"and then accepts whatevertenant_idit returns, so if anattacker can join the Erlang cluster (e.g., via leaked cookie/misconfigured distribution)
they could run a spoofed node and force the gateway to adopt an attacker-chosen tenant
context (cross-tenant mis-routing/data scoping impact).
config.ex [242-297]
Referred Code
🎫 No ticket provided
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: Meaningful Naming and Self-Documenting Code
Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting
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:
Unstructured sensitive logs: Newly added logs are plain-string (non-structured) and include tenant identifiers and
cluster node details, reducing auditability and potentially exposing sensitive
identifiers.
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 slug validation: The cluster-discovered
tenant_slugis returned and used without normalization/formatvalidation, allowing invalid values to flow into
nats_prefixand other tenant-scopedbehavior.
Referred Code
Generic: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation
Status:
Startup crash path: Tenant auto-discovery failure leads to a hard
raiseafter retries which may not providegraceful degradation or a fallback path depending on runtime expectations.
Referred Code
Generic: Secure Error Handling
Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.
Status:
Internal detail leakage: RPC failure logging includes
inspect(reason)and node names which could expose internalcluster details if logs are user-accessible.
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/2229#issuecomment-3725223177
Original created: 2026-01-08T18:56:33Z
PR Code Suggestions ✨
Explore these optional code suggestions:
Avoid blocking GenServer initialization during discovery
Refactor the
init/1function to perform tenant discovery asynchronously usinghandle_continue/2. This will prevent the GenServer from blocking and timing outduring initialization.
elixir/serviceradar_agent_gateway/lib/serviceradar_agent_gateway/config.ex [160-198]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 9
__
Why: The suggestion correctly identifies a critical issue where blocking in
init/1withProcess.sleep/1will cause supervisor timeouts, leading to a crash loop. The proposed asynchronous solution usinghandle_continue/2is the correct and idiomatic Elixir/OTP fix for this problem.Tighten core node detection
In
find_core_node/0, replace theString.contains?check with a stricter regex~r/^serviceradar_core(_elx)?@/to more accurately identify the core node andavoid false positives.
elixir/serviceradar_agent_gateway/lib/serviceradar_agent_gateway/config.ex [281-288]
Suggestion importance[1-10]: 5
__
Why: The suggestion improves the robustness of node discovery by using a more specific regex, preventing potential mismatches with other nodes that might contain
serviceradar_corein their name. This is a good practice for reliability.