nsmcp::SystemLogSummary object method heading (public)

 nsmcp::SystemLogSummary[i] heading text

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

Normalize a warning heading and extract known classification fields. Keep request values and page titles out of known group keys.

Parameters:
text (required)

Testcases:
No testcase defined.
Source code:
set heading [lindex [split $text \n] 0]
regsub {^\[[^\]]+\]\[[^\]]+\]\[[^\]]+\][ \t]+[A-Za-z]+:[ \t]*} $heading {} heading
set common {suppressedOccurrences 0}
# Strip only recognized trailing suppression annotations. Preserve the
# original redacted example; reported omissions never inflate record totals.
foreach expression {
    {[ \t]+\(([0-9]{1,18}) additional messages suppressed(?: since previous log|; see [^\r\n]+)?\)[ \t]*$}
    {, suppressed ([0-9]{1,18}) repeated notices since last notice[ \t]*$}
} {
    if {[regexp -- $expression $heading -> count]} {
        scan $count %lld count
        dict set common suppressedOccurrences $count
        regsub -- $expression $heading {} heading
        break
    }
}
# Match the fixed emitter prefix before testing arbitrary warning text.
if {[regexp -nocase {^(?:Ns_ConnLocation:[ \t]+)?ignore (?:invalid or )?untrusted host header field:[ \t]*(.*)$} $heading -> detail]} {
    set host {}
    # Older warnings may append a whitelist suggestion after the value.
    regexp {^'([^']*)'(?:\.[ \t]+Consider adding this value to 'whitelistedHosts' in the section 'ns/server/[^']+/acs' of your configuration file)?[ \t]*$} $detail -> host
    return [dict merge $common [dict create category message parameter {}  pattern {Host validation: untrusted Host header ignored} hostValue $host]]
}
set parameter {}
foreach expression {
    {duplicate(?:d)?[ \t]+(?:form[ \t]+)?(?:parameter|variable)[ \t:]+["'<]?([A-Za-z0-9_%.-]+)}
    {duplicate(?:d)?[ \t]+["']?([A-Za-z0-9_%.-]+)["']?[ \t]+parameter}
    {supplied[ \t]+(?:two|multiple|[0-9]+)[ \t]+values for[ \t]+["']?([A-Za-z0-9_%.-]+)}
    {more than one value for[ \t]+["']?([A-Za-z0-9_%.-]+)}
} {
    if {[regexp -nocase -- $expression $heading -> parameter]} {
        break
    }
}
if {$parameter ne ""} {
    catch {
        set parameter [ns_urldecode $parameter]
    }
    if {[regexp {^[A-Za-z_][A-Za-z0-9_.:-]{0,63}$} $parameter]} {
        return [dict merge $common [dict create category duplicate-parameter parameter $parameter pattern {Duplicate parameter}]]
    }
}
set procedure {}
set documentation false
foreach expression {
    {^api_add_to_proc_doc:[ \t]+no proc_doc available for[ \t]+(.+)$}
    {^(?:.*:[ \t]+)?missing procedure documentation for[ \t]+(.+)$}
    {^(?:.*:[ \t]+)?no documentation for proc(?:edure)?[ \t]+(.+)$}
} {
    if {[regexp -nocase -- $expression $heading -> procedure]} {
        set documentation true
        set procedure [string trim $procedure]
        break
    }
}
if {$documentation || [regexp -nocase {^.*(?:missing procedure documentation|no documentation for proc)} $heading]} {
    return [dict merge $common [dict create category missing-procedure-documentation parameter {}  procedure $procedure pattern {API documentation: missing procedure documentation}]]
}
if {[regexp {^sched id ([0-9]+): job started late by ([0-9]+(?:\.[0-9]+)?) sec \(flags ([A-Z|]+|none), interval ([0-9]+(?:\.[0-9]+)?) sec\)} $heading -> id delay flags interval]} {
    set interval [expr {double($interval)}]
    set timings [dict create nominalLatenessSeconds [expr {double($delay)}]]
    foreach {label field} {
        wait-return-late waitReturnLatenessSeconds
        explicit-mutex-acquisition explicitMutexAcquisitionSeconds
        dispatch-delay dispatchDelaySeconds
    } {
        if {[regexp -- [format {%s ([0-9]+(?:\.[0-9]+)?)s} $label] $heading -> value]} {
            dict set timings $field [expr {double($value)}]
        }
    }
    if {[regexp {last-nonthread-id -?[0-9]+ duration ([0-9]+(?:\.[0-9]+)?)s} $heading -> value]} {
        dict set timings lastNonThreadedSeconds [expr {double($value)}]
    }
    return [dict merge $common [dict create category scheduler-lateness parameter {}  pattern "Scheduler job $id started late (flags $flags, interval ${interval}s)"  scheduler [dict create jobId $id flags $flags intervalSeconds $interval] timings $timings]]
}
if {[regexp -nocase {^last log entry for this thread was repeated ([0-9]{1,18}) times$} $heading -> count]} {
    return [dict merge $common [dict create category log-repeat-marker parameter {} pattern {Last log entry for this thread was repeated <n> times} repeats $count]]
}
# Normalize known message templates, not arbitrary quoted application text.
# Original redacted examples retain the varying procedure/path/request data.
foreach {expression pattern} {
    {^api_proc_documentation: received invalid proc_name <[^>]*>, try to sanitize$} {API documentation: invalid procedure name; sanitization attempted}
    {^invalid API proc name .+$} {API documentation: invalid procedure name}
    {^rp_sources_filter: file ".*" does not exists trying to serve as a normal request$} {Missing resource: rp_sources_filter fallback to normal request}
    {^REQ BUFFER(?::|[ \t])} {HTTP parser: request-buffer diagnostic}
    {^someone tried to sneak in an untrusted referrer } {Host validation: untrusted referrer rejected}
    {^.*x-forwarded-for.*localhost} {Host validation: invalid x-forwarded-for localhost}
    {^.*(?:unbounded create-entry wait|unbounded.*wait.*create.entry)} {Cache: unbounded create-entry wait}
    {^.*vhostcertificates.*(?:missing|does not exist|not.*directory)} {Certificate configuration: virtual-host directory unavailable}
    {^.*(?:missing procedure documentation|no documentation for proc)} {API documentation: procedure documentation unavailable}
} {
    if {[regexp -nocase -- $expression $heading]} {
        return [dict merge $common [dict create category message parameter {} pattern $pattern]]
    }
}
set pattern [string range $heading 0 511]
regsub -all {0x[0-9A-Fa-f]+} $pattern {<hex>} pattern
regsub -all {\m[0-9]+\M} $pattern {<n>} pattern
return [dict merge $common [dict create category message parameter {} pattern $pattern]]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: