fix(scanner): leave failed scanner results out of the merge

A scanner that returns a result with status error now counts as a failed
scanner, like one that returns an error. Its result no longer joins the
merge, and the manager counts it as an infrastructure failure or another
failure by its cause.

The merged status is error only when every applicable scanner failed.
The fail_closed setting then decides that case as before. One scanner
failing while another returns clean now reads clean.
This commit is contained in:
2026-11-23 18:06:54 +00:00
parent 8adb1e0c87
commit 3731ca05ce
7 changed files with 274 additions and 49 deletions
+21
View File
@@ -8,6 +8,7 @@ import (
"fmt"
"net"
"net/http"
"strings"
)
// ErrInfrastructure marks a failure of the scanning machinery (timeout,
@@ -44,3 +45,23 @@ func IsInfrastructure(err error) bool {
}
return false
}
// DetailInfrastructure is the scan-result detail key that marks an error result as infrastructure.
const DetailInfrastructure = "infrastructure_error"
// ErrorDetails builds the Details of a scan-error result.
func ErrorDetails(reason string, infra bool) map[string]interface{} {
return map[string]interface{}{"error": reason, DetailInfrastructure: infra}
}
var networkMarkers = []string{"ENOTFOUND", "ETIMEDOUT", "ECONNREFUSED", "ECONNRESET", "EAI_AGAIN", "i/o timeout", "no such host", "connection refused"}
// NetworkFailure reports whether a tool's output shows it could not reach the network.
func NetworkFailure(output string) bool {
for _, m := range networkMarkers {
if strings.Contains(output, m) {
return true
}
}
return false
}