You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Improve issue flagging in golang's standard library and ensure proper fix version is suggested [CF-1834] (#166)
* fix: Use 'DetectionPriority' flag to detect issues in golang's standard library [CF-1834]
* fix: Ensure proper comparison of semver versions [CF-1834]
* fix: Determine whether file is a go.mod file [CF-1834]
* fix: Expected update version in tests [CF-1834]
Copy file name to clipboardExpand all lines: docs/multiple-tests/pattern-vulnerability-medium/results.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@
29
29
<error
30
30
source="vulnerability_medium"
31
31
line="3"
32
-
message="Insecure dependency golang/[email protected] (CVE-2023-39326: golang: net/http/internal: Denial of Service (DoS) via Resource Consumption via HTTP requests) (update to 1.20.12)"
32
+
message="Insecure dependency golang/[email protected] (CVE-2023-39326: golang: net/http/internal: Denial of Service (DoS) via Resource Consumption via HTTP requests) (update to 1.21.5)"
Copy file name to clipboardExpand all lines: docs/multiple-tests/pattern-vulnerability/results.xml
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -67,19 +67,19 @@
67
67
<!-- stdlib -->
68
68
<error
69
69
source="vulnerability"
70
-
line="3"
70
+
line="5"
71
71
message="Insecure dependency golang/[email protected] (CVE-2023-45288: golang: net/http, x/net/http2: unlimited number of CONTINUATION frames causes DoS) (update to 1.21.9)"
72
72
severity="error"
73
73
/>
74
74
<error
75
75
source="vulnerability"
76
-
line="3"
76
+
line="5"
77
77
message="Insecure dependency golang/[email protected] (CVE-2024-24790: golang: net/netip: Unexpected behavior from Is methods for IPv4-mapped IPv6 addresses) (update to 1.21.11)"
78
78
severity="error"
79
79
/>
80
80
<error
81
81
source="vulnerability"
82
-
line="3"
82
+
line="5"
83
83
message="Insecure dependency golang/[email protected] (CVE-2024-34156: encoding/gob: golang: Calling Decoder.Decode on a message which contains deeply nested structures can cause a panic due to stack exhaustion) (update to 1.22.7)"
// Issues in go standard library are reported in package `stdlib` which does not literally exist in go.mod.
384
+
//
385
+
// Trivy uses `stdlib` to refer to the standard library defined in `toolchain` or `go` directives in go.mod.
386
+
// Trivy supposedly uses the minimum version between `toolchain` and `go` directives (see https://trivy.dev/v0.59/docs/coverage/language/golang/#gomod-stdlib)
387
+
// but in reality it ALWAYS uses the version defined in `toolchain` when it exists.
388
+
ifisGoModStdLib {
389
+
// If there is a `toolchain` directive use its line.
390
+
ifstrings.HasPrefix(lineText, "toolchain ") {
391
+
returnline
392
+
}
393
+
// Only use the `go` directive line after scanning the whole file and there is no `toolchain` directive
394
+
ifstrings.HasPrefix(lineText, "go ") {
395
+
goDirectiveLine=line
396
+
}
397
+
} elseifstrings.Contains(lineText, pkgName) {
383
398
returnline
384
399
}
385
400
line++
386
401
}
387
402
388
-
return0
403
+
returngoDirectiveLine
389
404
}
390
405
391
406
// Find the smallest version increment that fixes a vulnerabillity, assuming semantic version format.
392
407
// Doesn't support package managers that use a different versioning scheme. (like Ruby's `~>`)
393
408
// Otherwise, return the original versions list.
409
+
//
410
+
// The semver library we're using requires a `v` prefix for the version.
411
+
// Usually, Trivy prefixes `InstalledVersion` but not `FixedVersion`.
412
+
// For safety, we sanitize both values, by removing and adding a `v` prefix.
0 commit comments