nsmcp::SystemLogPeers object method assessmentFields (public)

 nsmcp::SystemLogPeers[i] assessmentFields candidate sequences available \
    [ scope ]

Defined in /usr/local/ns/tcl/nsmcp/log-summary.tcl

Classify observed behavior using bounded same-peer access context.

Parameters:
candidate (required)
One exact peer and its warning samples.
sequences (required)
Nearby access records in sample order.
available (required)
Whether the access correlation completed.
scope (optional, defaults to "nearby-warning-window")
Returns:
Typed JSON fields with behavior, confidence and evidence limits.

Testcases:
No testcase defined.
Source code:
set samples [dict get $candidate samples]
set kinds [lsort -unique [lmap sample $samples {dict get $sample kind}]]
set statuses {}; set paths {}; set agents {}; set sensitivePaths {}; set sensitiveRecords 0
set records 0; set misses 0; set clipped 0
foreach sequence $sequences {
    if {[dict get $sequence returnedRecords]==0} {incr misses}
    if {[dict get $sequence recordsTruncated]} {incr clipped}
    foreach row [dict get $sequence records] {
        incr records
        lappend statuses [dict get $row status]
        if {[dict get $row path] ne {}} {
            set path [dict get $row path]
            lappend paths $path
            set lower [string tolower [lindex [split $path ?] 0]]
            if {[regexp {(^|/)\.env($|[./_-])|(^|/)\.aws/credentials($|/)|(^|/)\.git/config($|/)|(^|/)phpinfo\.php$} $lower]} {
                lappend sensitivePaths $path
                incr sensitiveRecords
            }
        }
        if {[dict get $row userAgent] ne {}} {lappend agents [dict get $row userAgent]}
    }
}
set kindFields {}
set kindIndex 0
foreach kind $kinds {lappend kindFields $kindIndex string $kind; incr kindIndex}
set successful 0; set unavailable 0
foreach status $statuses {
    if {$status>=200 && $status<400} {incr successful}
    if {$status==503} {incr unavailable}
}
set distinctPaths [llength [lsort -unique $paths]]
set distinctSensitivePaths [llength [lsort -unique $sensitivePaths]]
set distinctAgents [llength [lsort -unique $agents]]
set behavior undetermined; set confidence insufficient
if {$available && $distinctSensitivePaths>=2} {
    set behavior sensitive-file-probing; set confidence moderate
} elseif {$available && [llength $kinds]>=2 && "tls-on-http" in $kinds && "http2-preface" in $kinds} {
    set behavior protocol-probing; set confidence moderate
} elseif {$available && (($distinctPaths>=3 && $records>=4 && $distinctAgents>=2)
    || ($distinctPaths>=5 && $records>=6))} {
    set behavior multi-path-activity; set confidence moderate
}
set pathFields {}
set pathIndex 0
foreach path [lrange [lsort -unique $paths] 0 7] {
    lappend pathFields $pathIndex string $path
    incr pathIndex
}
set sensitiveFields {}
set sensitiveIndex 0
foreach path [lrange [lsort -unique $sensitivePaths] 0 7] {
    lappend sensitiveFields $sensitiveIndex string $path
    incr sensitiveIndex
}
return [list peer string [dict get $candidate peer] behavior string $behavior confidence string $confidence  evidenceScope string $scope  warningRecords number [dict get $candidate count] sampledWarnings number [llength $samples]  omittedWarnings number [expr {[dict get $candidate count]-[llength $samples]}]  warningKinds array $kindFields  nearbyRecords number $records nearbySuccessfulResponses number $successful  nearby503Responses number $unavailable nearbyDistinctPaths number $distinctPaths  nearbyPathExamples array $pathFields  sensitiveFileRequestRecords number $sensitiveRecords  distinctSensitiveFilePaths number $distinctSensitivePaths  sensitiveFilePathExamples array $sensitiveFields  nearbyDistinctUserAgentClaims number $distinctAgents missingContextSamples number $misses  truncatedContextSamples number $clipped  assessmentAvailable boolean $available  limitations string {Behavior is a heuristic candidate from at most two warning times and bounded committed access records, not a client or operator identity. Sensitive-file probing describes requests for conventional secret or diagnostic paths; it does not establish access to such files or hostile intent by one identified client. Same peer does not establish one TCP connection. User-Agent values are claims. Query strings are not retained; activity outside the bounded history is invisible. Missing access data or truncated context reduces confidence.}]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: