adding missing files #2677
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!2677
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2677/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: #2315
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2315
Original created: 2026-01-15T05:36:03Z
Original updated: 2026-01-15T05:37:53Z
Original head: carverauto/serviceradar:chore/missing-files
Original base: staging
Original merged: 2026-01-15T05:36:09Z 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
Implement device creation and CSV import functionality via Ash
Add device update capability with proper error handling
Support device UID generation and duplicate detection
Include tag parsing and device actor building helpers
Diagram Walkthrough
File Walkthrough
index.ex
Device creation and CSV import implementationweb-ng/lib/serviceradar_web_ng_web/live/device_live/index.ex
Scopealias for tenant and user context managementimport_devices/2function to handle CSV device importswith duplicate detection
save_devicehandler with actual device creationvia Ash
normalization, and error formatting
create_single_device/3to create devices with validationand duplicate checking
show.ex
Device update functionality with Ash integrationweb-ng/lib/serviceradar_web_ng_web/live/device_live/show.ex
Devicealias for device resource accessupdate_device/3function to update device attributes viaAsh
save_devicehandler with actual device updatelogic
build_device_actor/1to construct actor context for Ashoperations
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2315#issuecomment-3752979886
Original created: 2026-01-15T05:36:38Z
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
Authorization bypass
Description: The new
build_device_actor/1falls back to a"system"actor withrole: :adminwhen no useris present, which could enable unintended privileged device creation/import if
current_scopeis ever missing/mis-set or reachable in an unauthenticated context.index.ex [2098-2115]
Referred Code
Privilege escalation
Description: The new
build_device_actor/1falls back to a"system"actor withrole: :adminwhen no useris present, which could enable unintended privileged device updates if
current_scopecanbe absent/mis-set or the LiveView is accessible without a fully authenticated scope.
show.ex [2318-2336]
Referred Code
Potential XSS
Description: User-controlled fields (
device.hostname/device.ipand errorinspect(reason)) areinterpolated into flash messages, which could become an XSS vector if any downstream
rendering uses raw/unsafe HTML for flashes or error output.
index.ex [224-250]
Referred Code
🎫 No ticket provided
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 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:
Missing audit logging: New critical actions (CSV import/device create) are performed without any explicit audit
log entry containing user/tenant context and outcome.
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:
Error details exposed: User-facing flash messages include
inspect(reason)/inspect(error)which can exposeinternal implementation or backend details to end users.
Referred Code
Generic: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation
Status:
Missing input validation: External inputs from forms/CSV are used to create devices without explicit
validation/sanitization (e.g., IP format, required fields), relying on downstream behavior
that is not visible in this diff.
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:
Unvalidated user input: Device update accepts and persists user-provided fields (including
ipandtags) withoutexplicit validation/sanitization in the LiveView layer, and authorization enforcement
depends on Ash policies not shown in this diff.
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/2315#issuecomment-3752982092
Original created: 2026-01-15T05:37:53Z
PR Code Suggestions ✨
Explore these optional code suggestions:
Centralize device logic into a context
Refactor the code by moving device management business logic from Phoenix
LiveView modules (
index.ex,show.ex) into a dedicated context module. This willcentralize operations like device creation, updates, and data normalization,
eliminating code duplication and improving separation of concerns.
Examples:
web-ng/lib/serviceradar_web_ng_web/live/device_live/index.ex [1943-2141]
web-ng/lib/serviceradar_web_ng_web/live/device_live/show.ex [2284-2371]
Solution Walkthrough:
Before:
After:
Suggestion importance[1-10]: 9
__
Why: The suggestion correctly identifies significant business logic and duplicated helper functions (
build_device_actor, error formatters) placed within LiveView modules, and moving this to a dedicated context module is a crucial architectural improvement for maintainability and code reuse.Avoid race condition in device creation
Refactor
create_single_deviceto directly attempt device creation and handleunique constraint errors, avoiding a potential race condition from the current
check-then-act pattern.
web-ng/lib/serviceradar_web_ng_web/live/device_live/index.ex [2013-2049]
Suggestion importance[1-10]: 9
__
Why: The suggestion correctly identifies a potential race condition in the device creation logic and proposes a more robust "act-then-handle" pattern, which is a critical improvement for system reliability in a concurrent environment.
Handle not-found error explicitly
In
update_device, explicitly match onAsh.Error.Query.NotFoundwhen fetching thedevice and return a distinct
{:error, :not_found}tuple for better errorhandling.
web-ng/lib/serviceradar_web_ng_web/live/device_live/show.ex [2312-2313]
Suggestion importance[1-10]: 7
__
Why: The suggestion correctly proposes to explicitly handle the
NotFounderror, which improves error handling and allows the caller to provide more specific feedback to the user.Simplify device update logic
Refactor
update_deviceto update the device directly using itsdevice_uidwithAsh.Changeset.for_update/4, removing the redundant initial database fetch.web-ng/lib/serviceradar_web_ng_web/live/device_live/show.ex [2285-2316]
Suggestion importance[1-10]: 6
__
Why: This is a good suggestion that improves performance by removing a redundant database query and simplifies the code to be more idiomatic with the Ash framework.