2142 sql injection via unescaped device id in srql query construction #2581
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!2581
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2581/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: #2157
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2157
Original created: 2025-12-16T17:02:01Z
Original updated: 2025-12-16T18:01:27Z
Original head: carverauto/serviceradar:2142-sql-injection-via-unescaped-device_id-in-srql-query-construction
Original base: staging
Original merged: 2025-12-16T18:01:21Z 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, Tests
Description
SQL Injection Prevention via Parameterized Queries
Implemented comprehensive parameterized query support across Go and Rust codebase to prevent SQL injection vulnerabilities
Refactored SRQL query builders to use
$Nplaceholders instead of string interpolation for user-supplied valuesAdded
srqlBindBuilderutility for collecting and binding query parametersUpdated all MCP tools (devices, logs, events, sweeps, alerts) to use parameterized queries
Partition Scoping for Identity Engine
Enhanced identity resolution with partition-scoped cache keys (
<partition>:<type>:<value>)Added
strongIdentifierCacheKeyfunction for consistent cache key generationRefactored
batchLookupByStrongIdentifiersto group and process updates by partitionUpdated database interface to include partition parameter in lookups
Rust SRQL Engine Enhancements
Implemented
BindParamenum for parameterized query values (Text, TextArray, IntArray, Bool, Int, Float, Timestamptz)Refactored all entity query builders to return SQL and bind parameters as tuples
Added visualization metadata generation via
VizMetatypes for query resultsImplemented downsampling query support for time-series metrics with configurable aggregation
Added Apache AGE Cypher graph query execution with read-only validation
Exported public SRQL types and added
EmbeddedSrqlstruct for embedded engine usageAdded Elixir NIF module for SRQL query translation from web-ng
OTEL Metrics Improvements
Added
unitfield to OTEL metric models (Go and Rust) for storing measurement unitsCreated continuous aggregation view
otel_metrics_hourly_statsfor pre-computed hourly statisticsAdded hourly bucketing with 15-minute refresh policy for performance optimization
SNMP Service Deadlock Fix
Removed recursive RWMutex read locking in
Checkmethod to prevent deadlockAdded AST-based deadlock detection test to prevent regression
Web-ng Foundation
Added Phoenix LiveView application with JavaScript setup and custom hooks
Implemented SRQL query interface components with builder, results table, and auto-visualization
Added edge package onboarding token codec for secure token handling
Integrated Heroicons SVG icon library and daisyUI theme system with multiple color schemes
Added topbar progress bar library for UI feedback
Infrastructure & Configuration
Added PostgreSQL client certificate authentication support via
PGSSLCERTandPGSSLKEYenvironment variablesEnhanced certificate generation with
CNPG_CERT_EXTRA_IPSsupport and workstation client certificateUpdated Nginx entrypoint to route to web-ng service on port 4000
Added database schema migration for OTEL metrics unit column and aggregation view
Diagram Walkthrough
File Walkthrough
43 files
cnpg_observability.go
Refactor OTEL inserts to use parameterized queriespkg/db/cnpg_observability.go
$1,$2, etc. placeholders instead of string formattingotelLogsInsertSQL,otelMetricsInsertSQL,otelTracesInsertSQL)otelRowInserterinterface and concrete implementations toabstract row-specific logic
insertOTELRowsandinsertOTELhelper functionsunitfield to metrics insert queryidentity_engine.go
Add partition scoping to identity engine cache keyspkg/registry/identity_engine.go
::instead of:strongIdentifierCacheKeyfunction to normalize partition andbuild consistent cache keys
batchLookupByStrongIdentifiersto group updates bypartition and process each partition separately
groupUpdatesByPartition,collectStrongIdentifierSets,batchLookupIdentifierTypebatchLookupByStrongIdentifiersForPartitionto accept partitionparameter
builder.go
Update filter builders to use parameterized queriespkg/mcp/builder.go
FilterHandlerFuncandFilterBuilderinterface to acceptsrqlBindBuilderparameterGenericFilterBuilder.BuildFiltersto use parameterized bindsinstead of string formatting
iteration
binds.Bind()calls for filtervalues
server.go
Update MCP server to use parameterized queriespkg/mcp/server.go
executeGetDeviceto use parameterized query with$1placeholder
executeQueryEventsto build parameterized queries for timerange filters
executeSRQLQueryWithParamsmethod to dispatch toParameterizedQueryExecutorexecuteSRQLQueryto delegate toexecuteSRQLQueryWithParamswith empty params
tools_sweeps.go
Update sweep tools to use parameterized queriespkg/mcp/tools_sweeps.go
registerGetRecentSweepsToolto use parameterized query forpoller_idfilterregisterGetSweepSummaryToolto use parameterized query forpoller_idfilter$1placeholder andqueryParamsarray
cnpg_identity_engine.go
Add partition filtering to identity lookupspkg/db/cnpg_identity_engine.go
batchGetDeviceIDsByIdentifierSQLto filter bypartitioncolumnwith
$3parameterBatchGetDeviceIDsByIdentifierto accept and passpartitionparameter to query
tools_events.go
Update alerts tool to use parameterized queriespkg/mcp/tools_events.go
registerGetAlertsToolto use parameterized query forpoller_idfilter
$1placeholder andqueryParamsarray
tools_devices.go
Update device tools to use parameterized queriespkg/mcp/tools_devices.go
registerDeviceToolsto use parameterized query fordevice_idfilter
$1placeholder andqueryParamsarray
tools_logs.go
Update log tools to use parameterized queriespkg/mcp/tools_logs.go
registerLogToolsto use parameterized query forpoller_idfilter
$1placeholder andqueryParamsarray
interfaces.go
Update database interface for partition supportpkg/db/interfaces.go
BatchGetDeviceIDsByIdentifierinterface signature to includepartitionparameterbinds.go
Add SRQL parameter binding builder utilitypkg/mcp/binds.go
srqlBindBuilderstruct for collecting queryparameters
Bindmethod to append values and generate$Nplaceholdersotel.go
Add unit field to OTEL metric modelpkg/models/otel.go
Unitfield toOTELMetricRowstruct for measurement units (e.g.,"ms", "bytes")
mod.rs
Implement parameterized query support in Rust SRQL enginerust/srql/src/query/mod.rs
BindParamenum to represent parameterized query values (Text,TextArray, IntArray, Bool, Int, Float, Timestamptz)
translatemethod to use newtranslate_requestfunctionexecution
max_dollar_placeholder,reconcile_limit_offset_binds,diesel_sql,diesel_bind_countTranslateResponseto includeparamsasVec,pagination, andvizmetadatametadata, and graph cypher validation
viz.rs
Add visualization metadata generation for queriesrust/srql/src/query/viz.rs
VizMeta,ColumnMeta,ColumnType,ColumnSemantic, andVizSuggestiontypesmeta_for_planfunction to generate column and suggestionmetadata for all entity types
devices.rs
Implement parameterized queries for devices entityrust/srql/src/query/devices.rs
to_debug_sqltoto_sql_and_paramsreturning tuple of SQL andVecparse_stats_specandbuild_stats_queryfunctions
collect_filter_paramsto extract bind parameters fromdevice filters
clauses
interfaces.rs
Implement parameterized queries for interfaces entityrust/srql/src/query/interfaces.rs
to_debug_sqltoto_sql_and_paramsreturning tuple of SQL andVeccollect_filter_paramsto extract bind parameters frominterface filters
clauses
lib.rs
Export SRQL types and add embedded engine supportrust/srql/src/lib.rs
QueryDirection,QueryEngine,QueryRequest,QueryResponse,TranslateRequest,TranslateResponseEmbeddedSrqlstruct for embedded SRQL engine usageEmbeddedSrql::newconstructor to initialize query enginewith connection pool
downsample.rs
Add downsampling query support for time-series metricsrust/srql/src/query/downsample.rs
metrics with configurable bucket sizes and aggregation functions
across multiple metric entity types
with proper parameter escaping
?to PostgreSQL$Nformatservices.rs
Refactor services query to return SQL and parametersrust/srql/src/query/services.rs
to_debug_sqltoto_sql_and_paramsreturning both SQL andbind parameters
parse_stats_specandbuild_stats_queryfunctions
collect_filter_paramsto extract bind parameters fromfilters
parser.rs
Add downsampling and graph cypher query parsing supportrust/srql/src/parser.rs
GraphCypherentity type for graph database queriesDownsampleSpecandDownsampleAggtypes for downsamplingconfiguration
bucket,agg, andseriestokens for downsamplingqueries
as aliassyntax with validationgraph_cypher.rs
Add Apache AGE Cypher graph query supportrust/srql/src/query/graph_cypher.rs
PostgreSQL graph database
literals and dollar-quoted strings
traces.rs
Refactor traces query to return SQL and parametersrust/srql/src/query/traces.rs
to_debug_sqltoto_sql_and_paramsreturning SQL and bindparameters
collect_filter_paramsandcollect_i32_listfor parameterextraction
logs.rs
Refactor logs query to return SQL and parametersrust/srql/src/query/logs.rs
to_debug_sqltoto_sql_and_paramsreturning SQL and bindparameters
collect_filter_paramsfor parameter extraction from variousfilter types
cpu_metrics.rs
Refactor CPU metrics query to return SQL and parametersrust/srql/src/query/cpu_metrics.rs
to_debug_sqltoto_sql_and_paramsreturning SQL and bindparameters
collect_filter_paramsfor extracting numeric and text filterparameters
pollers.rs
Refactor pollers query to return SQL and parametersrust/srql/src/query/pollers.rs
to_debug_sqltoto_sql_and_paramsreturning SQL and bindparameters
collect_filter_paramsfor parameter extraction with booleansupport
otel_metrics.rs
Refactor OTEL metrics query to return SQL and parametersrust/srql/src/query/otel_metrics.rs
to_debug_sqltoto_sql_and_paramsreturning SQL and bindparameters
collect_filter_paramsfor extracting text and boolean filterparameters
db.rs
Add PostgreSQL client certificate authentication supportrust/srql/src/db.rs
PGSSLCERTandPGSSLKEYenvironment variablesbuild_client_config,load_client_certs, andload_client_keyfunctions for mutual TLSPgConnectionManager::newto accept optional client certificateand key paths
timeseries_metrics.rs
Refactor timeseries metrics query to return SQL and parametersrust/srql/src/query/timeseries_metrics.rs
to_debug_sqltoto_sql_and_paramsreturning SQL and bindparameters
collect_filter_paramsfor extracting numeric and text filterparameters
process_metrics.rs
Refactor process metrics query to return SQL and parametersrust/srql/src/query/process_metrics.rs
to_debug_sqltoto_sql_and_paramsreturning SQL and bindparameters
collect_filter_paramsfor extracting numeric and text filterparameters
disk_metrics.rs
Refactor disk metrics query to return SQL and parametersrust/srql/src/query/disk_metrics.rs
to_debug_sqltoto_sql_and_paramsreturning SQL and bindparameters
collect_filter_paramsfor extracting numeric and text filterparameters
memory_metrics.rs
Refactor memory metrics query to return SQL and parametersrust/srql/src/query/memory_metrics.rs
to_debug_sqltoto_sql_and_paramsreturning SQL and bindparameters
collect_filter_paramsfor extracting numeric and text filterparameters
device_updates.rs
Refactor device updates query to return SQL and parametersrust/srql/src/query/device_updates.rs
to_debug_sqltoto_sql_and_paramsreturning SQL and bindparameters
collect_filter_paramswith support for text and boolean filtersevents.rs
Refactor events query to return SQL and parametersrust/srql/src/query/events.rs
to_debug_sqltoto_sql_and_paramsreturning SQL and bindparameters
collect_filter_paramsfor extracting text and integer filterparameters
config.rs
Add PostgreSQL client certificate configurationrust/srql/src/config.rs
pg_ssl_certandpg_ssl_keyconfiguration fields for clientcertificate authentication
embeddedconstructor for creating test/embedded configurationsPGSSLCERTandPGSSLKEYenvironment variables
trace_summaries.rs
Refactor trace summaries query to return SQL and parametersrust/srql/src/query/trace_summaries.rs
to_debug_sqltoto_sql_and_paramsreturning SQL and bindparameters
bind_param_from_queryconversion function for parameter bindinglib.rs
Add Elixir NIF for SRQL query translationweb-ng/native/srql_nif/src/lib.rs
implementation
translatefunction callable from Elixir with query directionand mode support
actual database connection
device_graph.rs
Refactor device graph query to return SQL and parametersrust/srql/src/query/device_graph.rs
to_debug_sqltoto_sql_and_paramsreturning SQL and bindparameters
extract_paramsfunction to collect device graph query parametersmodels.rs
Add unit field to OTEL metric row modelrust/srql/src/models.rs
unitfield toOtelMetricRowstruct for storing metric unitinformation
into_jsonmethod to include theunitfield in JSON outputapp.js
Add Phoenix LiveView application JavaScript setupweb-ng/assets/js/app.js
and live view configuration
TimeseriesCharthook for interactive chart tooltipsand hover effects
including live reload
heroicons.js
Add Heroicons Tailwind CSS pluginweb-ng/assets/vendor/heroicons.js
automatic sizing
technique
onboarding_token.ex
Add edge package onboarding token codecweb-ng/lib/serviceradar_web_ng/edge/onboarding_token.ex
tokens
package ID, download token, and optional API URL
and content
srql_components.ex
Add SRQL query interface components and builderweb-ng/lib/serviceradar_web_ng_web/components/srql_components.ex
module with 818 lines
submit button
formatting
category-based charts with sparkline rendering
filters, downsampling options, filter management, sorting, and limit
controls
badges, booleans, JSON), URL parsing, ISO8601 date parsing, and
category label formatting
00000000000002_otel_metrics_unit_and_agg.up.sql
Add unit column and hourly metrics aggregation for performancepkg/db/cnpg/migrations/00000000000002_otel_metrics_unit_and_agg.up.sql
unitcolumn tootel_metricstable to store metric units (e.g.,"ms", "bytes", "1")
unitcolumn for efficient filteringotel_metrics_hourly_statswithhourly bucketing for pre-computed statistics
3-hour start offset and 1-hour end offset
service-based queries
spirerole and added documentationcomment
2 files
query_utils.go
Implement parameterized SRQL queries to prevent SQL injectionpkg/mcp/query_utils.go
ParameterizedQueryExecutorinterface for parameterized SRQLquery support
srqlBindBuilderhelper to collect bind parameters and generate$NplaceholdersbuildLogQuery,buildRecentLogsQuery,buildDevicesQuery) to return tuples of(query, params)user-supplied values (timestamps, IDs, filters)
executeSRQLdispatcher to route queries to parameterized orplain executor based on parameter count
service.go
Fix potential deadlock in SNMP service Check methodpkg/checker/snmp/service.go
s.mu.RLock()anddefer s.mu.RUnlock()fromCheckmethodavoided
GetStatusto acquire its own locks without deadlock risk6 files
parameterized_queries_test.go
Add tests for parameterized SRQL query bindingpkg/mcp/parameterized_queries_test.go
concatenated into SQL
payloads
ParameterizedQueryExecutorsupport
service_deadlock_test.go
Add deadlock detection test for SNMP servicepkg/checker/snmp/service_deadlock_test.go
Checkmethod does not holds.mu.RLock()while callingGetStatus()write-preferring semantics
registry_test.go
Update registry tests for partition parameterpkg/registry/registry_test.go
BatchGetDeviceIDsByIdentifiermock expectations to includepartitionparameterallowCanonicalizationQueries,TestProcessBatchDeviceUpdates_MergesSweepIntoCanonicalDevice, andothers
identity_engine_partition_test.go
Add partition scoping tests for identity enginepkg/registry/identity_engine_partition_test.go
different device IDs
batchLookupByStrongIdentifierscorrectly groups and processesupdates by partition
canon_simulation_test.go
Update DIRE simulation test for partition supportpkg/registry/canon_simulation_test.go
setupDIREMockDBto passpartitionparameter toBatchGetDeviceIDsByIdentifierstrongIdentifierCacheKeyfunction
UpsertDeviceIdentifiersmock to usestrongIdentifierCacheKeyfor consistency
harness.rs
Update test harness for SSL configurationrust/srql/tests/support/harness.rs
pg_ssl_certandpg_ssl_keyfields set to
None1 files
mock_db.go
Update mock to include partition parameterpkg/db/mock_db.go
BatchGetDeviceIDsByIdentifiermock signature to includepartitionparameter1 files
server_test.go
Fix test file formattingpkg/mcp/server_test.go
4 files
schema.rs
Add unit field to OTEL metrics schemarust/srql/src/schema.rs
unitfield tootel_metricstable schema withNullabletypegenerate-certs.sh
Enhance certificate generation with extra IPs and workstation certdocker/compose/generate-certs.sh
CNPG_CERT_EXTRA_IPSenvironment variable to includeadditional IPs in CNPG certificate SANs
missing
workstationclient certificate for externaldeveloper connections
entrypoint-nginx.sh
Update Nginx entrypoint for web-ng servicedocker/compose/entrypoint-nginx.sh
web-ngon port 4000 insteadof
webon port 3000coreservice on port 8090app.css
Add main application CSS with Tailwind and daisyUI configurationweb-ng/assets/css/app.css
imports
plugins
"light" (Phoenix-inspired) with complete color palettes and design
tokens
(
phx-click-loading,phx-submit-loading,phx-change-loading) and darkmode support
2 files
daisyui-theme.js
Add daisyUI theme plugin bundle with multiple color schemesweb-ng/assets/vendor/daisyui-theme.js
withOptionsplugin function(cyberpunk, acid, black, dark, light, luxury, dracula, retro, lofi,
valentine, nord, lemonade, garden, aqua, corporate, pastel, bumblebee,
coffee, silk, sunset, synthwave, dim, abyss, forest, night,
caramellatte, autumn, emerald, cupcake, cmyk, business, winter,
halloween, fantasy, wireframe)
topbar.js
Add topbar progress bar library for UI feedbackweb-ng/assets/vendor/topbar.js
effects, and auto-run behavior
config(),show(),progress(), andhide()101 files
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2157#issuecomment-3661535194
Original created: 2025-12-16T17:03:30Z
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:
No security concerns identified
No security vulnerabilities detected by AI analysis. Human verification advised for critical code.🎫 #2142
devices.getDeviceby stopping direct interpolation ofuser-supplied
device_idinto SRQL/SQL and using parameterized queries or proper escaping.executeGetDevicepath by stopping direct interpolationof user-supplied
DeviceIDinto the SRQL query and using parameterized queries or properescaping.
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 Error Handling
Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.
Status: Passed
Generic: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation
Status:
Swallowed DB error: The new
batchLookupIdentifierTypepath drops database lookup errors and silently returnsempty matches, removing actionable context for diagnosing identity resolution failures.
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 user query: The added code logs full SRQL query strings (which may embed user-supplied filters) and
therefore may leak sensitive user input into logs depending on deployment and log
retention.
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:
Raw filter injection: The query builders still append
params.Filterdirectly into the SRQLWHEREclause withoutbinding or validation, which may preserve an injection vector depending on the intended
trust model for
Filter.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/2157#issuecomment-3661542321
Original created: 2025-12-16T17:05:16Z
You are nearing your monthly Qodo Merge usage quota. For more information, please visit here.
PR Code Suggestions ✨
Explore these optional code suggestions:
Fix SQL injection in status filter
Fix an SQL injection vulnerability in
buildDevicesQueryby parameterizing theis_availablestatus filter instead of using string formatting.pkg/mcp/query_utils.go [162-208]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 9
__
Why: The suggestion correctly identifies a significant SQL injection vulnerability where a boolean-like string is interpolated directly into the query, which the PR's main goal was to prevent.
Rewrite query placeholders consistently
Apply the
rewrite_placeholdersfunction to theDEVICE_GRAPH_QUERYstring forconsistency with other query handling in the codebase.
rust/srql/src/query/device_graph.rs [30-37]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 7
__
Why: The suggestion correctly points out an inconsistency by not using
rewrite_placeholders, which is used elsewhere for similar queries, improving consistency and preventing potential future issues.Safely parse comma-separated environment variable
To prevent potential command injection, parse the comma-separated
CNPG_CERT_EXTRA_IPSenvironment variable into a shell array instead of usingechoandtr.docker/compose/generate-certs.sh [165-167]
Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies a potential command injection vulnerability from unsafe parsing of an environment variable and provides a robust, safer alternative.
Use query parameters for LIMIT
Parameterize the
LIMITclause inbuildRecentLogsQueryto prevent potentialperformance issues and maintain consistency with other query parameterization
changes.
pkg/mcp/query_utils.go [115-130]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies that the
LIMITclause is not parameterized, which is inconsistent with the PR's goal of preventing SQL injection and could lead to performance issues.Parameterize LIMIT clause
Parameterize the
LIMITclause inbuildLogQueryto prevent potential SQLinjection and performance issues by binding the limit value instead of using
string formatting.
pkg/mcp/query_utils.go [80-113]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 7
__
Why: The suggestion correctly points out that the
LIMITclause is not parameterized, which is inconsistent with the PR's goal and could lead to performance issues if a large value is passed.Parameterize bucket duration
In
build_sql, use a SQL placeholder forbucket_secsand bind it as a parameterinstead of using string formatting to prevent potential SQL injection.
rust/srql/src/query/downsample.rs [88-90]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies that
bucket_secsis interpolated into the SQL string and proposes using a bind parameter, which is a security best practice, even though the value is already validated.Limit dollar quote attempts
Add a maximum attempt count to the
dollar_quotefunction to prevent a potentialinfinite loop and return an error if it is exceeded.
rust/srql/src/query/graph_cypher.rs [59-76]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 6
__
Why: The suggestion correctly identifies a theoretical risk of an infinite loop and proposes a robust solution by adding a maximum attempt limit, improving the function's resilience.
Improve TLS error context
Improve the error context message in
build_client_configto reference the clientcertificate and key paths instead of the root certificate path for better
debugging.
rust/srql/src/db.rs [138-140]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 4
__
Why: The suggestion improves an error message to be more specific, which aids in debugging, although it is a minor improvement.