nsmcp::AccessAnalytics object method invalidRequestContextSQL (public)

 nsmcp::AccessAnalytics[i] invalidRequestContextSQL peerKey side

Defined in /usr/local/ns/tcl/nsmcp/log-peer-context.tcl

Build the bounded SQL query for one side of a warning timestamp.

Parameters:
peerKey (required)
Private peer digest as lowercase SHA-256 hex.
side (required)
Select requests before or at and after the warning.
Returns:
SQL with bind parameters for the time window.

Testcases:
No testcase defined.
Source code:
if {![regexp {^[0-9a-f]{64}$} $peerKey] || $side ni {before after}} {
    error "invalid warning context query"
}
if {$side eq "before"} {
    set condition {r.t>=:lo AND r.t<:at}
    set order DESC
    set limit 17
} else {
    set condition {r.t>=:at AND r.t>=:lo AND r.t<:hi}
    set order ASC
    set limit 6
}
# Only a validated SHA-256 hex literal enters SQL. Values use bindings.
return "SELECT r.t, r.status, substr(r.path,1,512) AS path,
    substr(r.method,1,32) AS method, substr(r.pool,1,128) AS pool,
    substr(r.source,1,32) AS source, substr(r.driver,1,128) AS driver,
    substr(r.label,1,1024) AS userAgent, r.clipped
    FROM main.rows r WHERE r.kind=0 AND $condition
    AND r.peer=X'$peerKey'
    AND EXISTS(SELECT 1 FROM main.files f WHERE f.fid=r.fid AND f.active=1)
    ORDER BY r.t $order LIMIT $limit"
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: