Web/elixir phoenix poc #2578
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!2578
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2578/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: #2139
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2139
Original created: 2025-12-15T17:15:37Z
Original updated: 2025-12-16T05:11:52Z
Original head: carverauto/serviceradar:web/elixir_phoenix_poc
Original base: staging
Original merged: 2025-12-16T05:11:48Z 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, Tests
Description
SRQL Query Engine Refactoring: Comprehensive refactor of the query engine to support typed SQL parameters (
BindParamenum) and visualization metadata generation, replacing the previous debug SQL patternNew Query Capabilities: Added support for time-series downsampling with configurable bucket sizes and aggregation functions (avg, min, max, sum, count), and read-only Cypher graph database queries with security validation
Visualization Metadata: Implemented
VizMetasystem providing column type information and visualization hints (timeseries, table) for query results across all entity typesParameter Binding Across All Entities: Refactored all entity-specific query modules (logs, OTEL metrics, interfaces, traces, CPU/memory/disk/process metrics, devices, services, events, etc.) to use typed parameter binding with validation
PostgreSQL TLS Authentication: Added client certificate and key support for mutual TLS authentication with PostgreSQL
Elixir Phoenix Integration: Created new Elixir NIF (Native Implemented Function) for SRQL query translation, behaviour module definition, and comprehensive Phoenix v1.8 web framework with LiveView components
Web UI Components: Implemented SRQL query interface with interactive builder, results table, auto-visualization, and query state management
User Authentication & Email: Added user authentication system with magic link login, email notifications via Swoosh, and user account management
Configuration & Infrastructure: Added embedded SRQL mode, PostgreSQL SSL certificate configuration, dynamic certificate SAN support, and Docker Compose updates for external database access
UI Framework: Integrated Tailwind CSS v4 with daisyUI themes, Heroicons, and topbar progress indicators
Documentation: Comprehensive Phoenix development guidelines covering authentication, JavaScript, CSS, testing, and best practices
Diagram Walkthrough
File Walkthrough
34 files
mod.rs
Refactor query engine to support typed parameters and visualizationmetadatarust/srql/src/query/mod.rs
BindParamenum for typed SQL parameter binding with support fortext, arrays, integers, booleans, floats, and timestamps
downsamplemodule andgraph_cyphermodule for new querycapabilities
entity-specific handlers
to_debug_sqlpattern withto_sql_and_paramsto return bothSQL and typed parameters
translate_requestpublic function that returns SQL, parameters,pagination metadata, and visualization hints
parameter reconciliation, and Diesel query introspection
metadata, downsampling, and graph cypher queries
viz.rs
Add visualization metadata generation for query resultsrust/srql/src/query/viz.rs
VizMetastruct containing column metadata and visualizationsuggestions
ColumnTypeandColumnSemanticenums to describe resultcolumns
VizKindenum supporting timeseries and table visualizationsmeta_for_planfunction that generates appropriatevisualization hints for each entity type
all supported entities
downsample.rs
Add time-series downsampling with bucketing and aggregationrust/srql/src/query/downsample.rs
count) with configurable bucket sizes
metric type
type-safe parameter binding
time_bucketfunction andproper placeholder rewriting
graph_cypher.rs
Add read-only Cypher graph query execution supportrust/srql/src/query/graph_cypher.rs
graph database
MERGE, SET, DELETE, etc.)
format with nodes and edges
literals and dollar-delimited strings
parser.rs
Add downsampling and graph cypher query parsing supportrust/srql/src/parser.rs
GraphCypherentity variant for graph database queriesDownsampleSpecstruct with bucket duration, aggregationfunction, and series field
DownsampleAggenum supporting avg, min, max, sum, and countoperations
bucket,agg, andseriesquery parameters withvalidation
parse_bucket_secondsfunction supporting duration suffixes (s,m, h, d) with maximum bounds
optional strings
logs.rs
Refactor logs query to return typed SQL parametersrust/srql/src/query/logs.rs
to_sql_and_paramsfunction returning typedBindParamvectorsinstead of debug SQL
collect_filter_paramsto extract parameters from filterconditions
bind_param_from_statsconversion for statistics queryresults
otel_metrics.rs
Refactor OTEL metrics query to return typed SQL parametersrust/srql/src/query/otel_metrics.rs
to_sql_and_paramsfunction with typed parameter collectioncollect_filter_paramsfor extracting parameters fromfilter conditions
bind count checking
interfaces.rs
Refactor interfaces query to return typed SQL parametersrust/srql/src/query/interfaces.rs
to_sql_and_paramsfunction with comprehensive parametercollection
collect_filter_paramssupporting text, integer, and textarray parameters
verification
traces.rs
Refactor traces query to return typed SQL parametersrust/srql/src/query/traces.rs
to_sql_and_paramsfunction with typed parameter collectioncollect_filter_paramssupporting text and integer listparameters
collect_i32_listfor parsing integer arrays fromfilters
validation
cpu_metrics.rs
Refactor CPU metrics query to return typed SQL parametersrust/srql/src/query/cpu_metrics.rs
to_sql_and_paramsfunction with typed parameter collectioncollect_filter_paramssupporting text, integer, and floatparameters
bind_param_from_statsconversion for statistics query resultsvalidation
pollers.rs
Refactor pollers query to return typed SQL parametersrust/srql/src/query/pollers.rs
to_sql_and_paramsfunction with typed parameter collectioncollect_filter_paramssupporting text and booleanparameters
parse_boolfunction to module level for reusabilityvalidation
db.rs
Add client certificate TLS authentication supportrust/srql/src/db.rs
load_client_certsfunction to parse certificate chainsfrom PEM files
load_client_keyfunction to parse private keys from PEMfiles
build_client_configfunction to construct Rustls clientconfiguration with optional mutual TLS
PgConnectionManager::newto accept client certificate and keypaths
process_metrics.rs
Refactor process metrics query to return typed SQL parametersrust/srql/src/query/process_metrics.rs
to_sql_and_paramsfunction with typed parameter collectioncollect_filter_paramssupporting text, integer, and floatparameters
validation
timeseries_metrics.rs
Refactor timeseries metrics query to return typed SQL parametersrust/srql/src/query/timeseries_metrics.rs
to_sql_and_paramsfunction with typed parameter collectioncollect_filter_paramssupporting text, integer, and floatparameters
validation
behaviour.ex
Add Elixir SRQL behaviour module definitionweb-ng/lib/serviceradar_web_ng/srql/behaviour.ex
srql_responsetype as a mapquery_requestcallback accepting a map and returning successor error tuple
devices.rs
Add parameterized SQL generation for device queriesrust/srql/src/query/devices.rs
BindParamimport to support parameterized query generationto_sql_and_params()function to generate SQL with bindparameters
collect_text_params()andcollect_filter_params()helperfunctions for parameter collection
collected parameters
disk_metrics.rs
Add parameterized SQL generation for disk metricsrust/srql/src/query/disk_metrics.rs
BindParamimport for parameterized queriesto_sql_and_params()function with time range and filterparameter handling
collect_text_params()andcollect_filter_params()for parameterextraction
downsamplefieldmemory_metrics.rs
Add parameterized SQL generation for memory metricsrust/srql/src/query/memory_metrics.rs
BindParamimport for parameterized query supportto_sql_and_params()function with parameter collectionlogic
collect_text_params()andcollect_filter_params()helperfunctions
downsamplefielddevice_updates.rs
Add parameterized SQL generation for device updatesrust/srql/src/query/device_updates.rs
BindParamimport for parameterized query generationto_sql_and_params()function with filter and time rangehandling
collect_text_params()andcollect_filter_params()for parametercollection
services.rs
Add parameterized SQL generation for services queriesrust/srql/src/query/services.rs
BindParamimport for parameterized query supportto_sql_and_params()function with parameter collectioncollect_text_params()andcollect_filter_params()helperfunctions
downsamplefieldevents.rs
Add parameterized SQL generation for events queriesrust/srql/src/query/events.rs
BindParamimport for parameterized queriesto_sql_and_params()function with parameter extractionlogic
collect_text_params()andcollect_filter_params()for parameterhandling
trace_summaries.rs
Add parameterized SQL generation for trace summariesrust/srql/src/query/trace_summaries.rs
BindParamimport for parameterized query supportto_sql_and_params()function that converts query binds toBindParambind_param_from_query()helper function to convertSqlBindValueto
BindParamand timestamps
config.rs
Add PostgreSQL SSL certificate configuration and embedded moderust/srql/src/config.rs
pg_ssl_certandpg_ssl_keyconfiguration fields for PostgreSQLclient certificates
PGSSLCERTandPGSSLKEYenvironment variables
embedded()constructor method for creating in-memoryconfigurations
defaults
lib.rs
Add Elixir NIF for SRQL query translationweb-ng/native/srql_nif/src/lib.rs
integration
translate()function to convert SRQL queries to SQL withparameters
parameters
device_graph.rs
Add parameterized SQL generation for device graphrust/srql/src/query/device_graph.rs
BindParamimport for parameterized query supportto_sql_and_params()function that extracts parameters fromquery plan
collector_owned_only, include_topology
lib.rs
Export public API and add embedded mode supportrust/srql/src/lib.rs
QueryDirection,QueryEngine,QueryRequest,QueryResponse,TranslateRequest,TranslateResponseEmbeddedSrqlstruct for embedded mode usageEmbeddedSrql::new()constructor that initializes databasepool and query engine
app.js
Add Phoenix LiveView application initializationweb-ng/assets/js/app.js
integration
heroicons.js
Add Heroicons Tailwind CSS pluginweb-ng/assets/vendor/heroicons.js
(20px), micro (16px)
hero-*page_controller.ex
Add page controller with authentication redirectweb-ng/lib/serviceradar_web_ng_web/controllers/page_controller.ex
home()action that redirects authenticated users todashboard
home.html.heex
Phoenix framework landing page with community linksweb-ng/lib/serviceradar_web_ng_web/controllers/page_html/home.html.heex
SVG background
changelog
and Fly.io deployment
srql_components.ex
SRQL query interface components with builder and visualizationweb-ng/lib/serviceradar_web_ng_web/components/srql_components.ex
functionality
value formatting
categories chart types
filters, downsampling, and filter management
builder.ex
SRQL query builder with parsing and state managementweb-ng/lib/serviceradar_web_ng_web/srql/builder.ex
validation logic
query strings
bucket, aggregation, and filters
configurations against entity catalog
page.ex
SRQL page state and event handling logicweb-ng/lib/serviceradar_web_ng_web/srql/page.ex
result handling
filter management
SRQL responses
normalization
user_notifier.ex
User email notification system with Swoosh integrationweb-ng/lib/serviceradar_web_ng/accounts/user_notifier.ex
notifications
and email update instructions
unconfirmed users
1 files
harness.rs
Update test harness for SSL certificate configurationrust/srql/tests/support/harness.rs
pg_ssl_certandpg_ssl_keyfields
Nonefor test environment3 files
generate-certs.sh
Add dynamic certificate SAN support and workstation certdocker/compose/generate-certs.sh
when
CNPG_CERT_EXTRA_IPSis setworkstationcertificate for external developerconnections
docker-compose.yml
Add CNPG public port and certificate configurationdocker-compose.yml
CNPG_CERT_EXTRA_IPSenvironment variable to cert-generatorservice
127.0.0.1:5455)
app.css
Tailwind CSS v4 configuration with daisyUI themesweb-ng/assets/css/app.css
directives
configurations using OKLCH color values
(
phx-click-loading,phx-submit-loading,phx-change-loading)proper layout composition
2 files
daisyui-theme.js
Add daisyUI theme vendor libraryweb-ng/assets/vendor/daisyui-theme.js
luxury, etc.)
topbar.js
Add topbar progress bar vendor libraryweb-ng/assets/vendor/topbar.js
styling
indicators
1 files
AGENTS.md
Complete Phoenix v1.8 development guidelines and best practicesweb-ng/AGENTS.md
development
live_sessionpatternsand custom components
practices and patterns
101 files
Imported GitHub PR comment.
Original author: @gitguardian[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2139#issuecomment-3656760663
Original created: 2025-12-15T17:15:51Z
⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.
Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.
🔎 Detected hardcoded secret in your pull request
d4ee01d332🛠 Guidelines to remediate hardcoded secrets
To avoid such incidents in the future consider
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2139#issuecomment-3656764606
Original created: 2025-12-15T17:16:52Z
You are nearing your monthly Qodo Merge usage quota. For more information, please visit here.
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
Cypher validation bypass
Description: The read-only enforcement for user-supplied Cypher relies on a simple keyword token check
and may be bypassable with Cypher/AGE-specific syntax (e.g., comments, alternative
procedure/function invocations, or non-keyword mutation constructs), potentially allowing
unintended graph writes or other unsafe operations if the validator misses a mutation
pattern.
graph_cypher.rs [104-126]
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: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation
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 context: The new query paths (
downsampleandgraph_cypher) andtranslate_requestreturn results/SQLwithout any visible audit logging of who executed the action and the outcome, which may be
handled elsewhere but is not verifiable from this diff.
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:
User-facing errors: The new Cypher validation returns specific rejection reasons (e.g., which keyword was
found) that may be user-facing depending on API layers not shown, so exposure risk cannot
be confirmed from this diff alone.
Referred Code
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:
Logs may leak: The new
diesel_sqlhelper logserror = ?errwhich could include SQL fragments or othersensitive context depending on Diesel error content, requiring confirmation/redaction
review.
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:
Cypher safety scope: Although
ensure_read_onlyblocks many mutation keywords and;, confirming full protectionagainst Cypher/SQL injection and graph-side privilege escalation requires reviewing the
surrounding API/authz layers and the missing diffs.
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/2139#issuecomment-3656769847
Original created: 2025-12-15T17:18:12Z
You are nearing your monthly Qodo Merge usage quota. For more information, please visit here.
PR Code Suggestions ✨
Explore these optional code suggestions:
Manage dependencies with a package manager
Instead of committing the
daisyui.jsfile directly, manage it as a dependencyusing a package manager like
npmoryarn. This improves maintainability,security, and reduces repository size.
web-ng/assets/vendor/daisyui.js [1-24]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 9
__
Why: The suggestion correctly identifies that vendoring a large third-party library is an anti-pattern and proposes the standard best practice of using a package manager, which significantly improves project maintainability and security.
Improve TLS error message clarity
Improve the TLS client configuration error message to reference the client
certificate and key paths instead of the root certificate path, making it more
accurate for debugging.
rust/srql/src/db.rs [125-144]
Suggestion importance[1-10]: 4
__
Why: The suggestion proposes a minor improvement to an error message for better debuggability. While the change is valid and makes the error context more precise, it has a low impact on functionality or correctness.
Use a valid dummy database URL
Replace the hardcoded dummy database URL in the
translateNIF with asyntactically valid PostgreSQL connection string to improve robustness against
future changes in configuration parsing.
web-ng/native/srql_nif/src/lib.rs [32]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 3
__
Why: The suggestion correctly points out that a hardcoded, invalid URL could be brittle. While the current code works, using a syntactically valid dummy URL is a good practice for future-proofing, though it has a low immediate impact.
Improve Cypher query security validation
Improve the Cypher query security validation to prevent false positives by using
a regular expression that correctly ignores keywords within string literals and
comments.
rust/srql/src/query/graph_cypher.rs [104-126]
Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies that the current validation logic can lead to false positives by incorrectly rejecting queries with forbidden keywords inside string literals. This is a security-related improvement that enhances the correctness and robustness of the Cypher query validation.
Improve duration parsing logic
Refactor the
parse_bucket_secondsfunction to more robustly separate the numericvalue from the unit suffix, correctly handling inputs with missing or invalid
units.
rust/srql/src/parser.rs [245-285]
Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies a flaw in the parsing logic for bucket durations, where inputs without a unit suffix are mishandled. The proposed change makes the parsing more robust and provides clearer error messages for invalid or missing units, improving the function's correctness.
Fix incorrect filter parameter collection
Use the
collect_text_paramshelper function to handle filter parametercollection for text fields, ensuring correct behavior for various operators and
preventing panics with list-based filters.
rust/srql/src/query/devices.rs [249-252]
Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies that the current implementation would panic on list-based filters and proposes using the
collect_text_paramshelper function, which provides proper error handling and improves code reuse.Improve boolean parsing for filters
Refactor the boolean parsing for
availableandis_availablefilters to use theparse_boolutility for better consistency and to support more truthy values.rust/srql/src/query/device_updates.rs [198-203]
Suggestion importance[1-10]: 6
__
Why: The suggestion correctly identifies inconsistent and limited boolean parsing, and its proposed change to use the
parse_boolfunction aligns with other parts of the codebase, improving robustness and maintainability.