@@ -9,19 +9,19 @@ import (
9
9
"golang.org/x/vuln/vulncheck"
10
10
)
11
11
12
- // Summary is the govulncheck result.
12
+ // LegacySummary is the govulncheck result.
13
13
//
14
- // TODO(https://go.dev/issue/56042): replace Summary with Result
15
- type Summary struct {
14
+ // TODO(https://go.dev/issue/56042): replace LegacySummary with Result
15
+ type LegacySummary struct {
16
16
// Vulnerabilities affecting the analysis target binary or source code.
17
- Affecting []Vuln
17
+ Affecting []LegacyVuln
18
18
// Vulnerabilities that may be imported but the vulnerable symbols are
19
19
// not called. For binary analysis, this will be always empty.
20
- NonAffecting []Vuln
20
+ NonAffecting []LegacyVuln
21
21
}
22
22
23
- // Vuln represents a vulnerability relevant to a (module, package).
24
- type Vuln struct {
23
+ // LegacyVuln represents a vulnerability relevant to a (module, package).
24
+ type LegacyVuln struct {
25
25
OSV * osv.Entry
26
26
PkgPath string // Package path.
27
27
ModPath string // Module path.
@@ -30,33 +30,33 @@ type Vuln struct {
30
30
// Trace contains a call stack for each affecting symbol.
31
31
// For vulnerabilities found from binary analysis, and vulnerabilities
32
32
// that are reported as Unaffecting ones, this will be always empty.
33
- Trace []Trace
33
+ Trace []LegacyTrace
34
34
}
35
35
36
- // Trace represents a sample trace for a vulnerable symbol.
37
- type Trace struct {
38
- Symbol string // Name of the detected vulnerable function or method.
39
- Desc string // One-line description of the callstack.
40
- Stack []StackEntry // Call stack.
41
- Seen int // Number of similar call stacks.
36
+ // LegacyTrace represents a sample trace for a vulnerable symbol.
37
+ type LegacyTrace struct {
38
+ Symbol string // Name of the detected vulnerable function or method.
39
+ Desc string // One-line description of the callstack.
40
+ Stack []LegacyStackEntry // Call stack.
41
+ Seen int // Number of similar call stacks.
42
42
}
43
43
44
- // StackEntry represents a call stack entry.
45
- type StackEntry struct {
44
+ // LegacyStackEntry represents a call stack entry.
45
+ type LegacyStackEntry struct {
46
46
FuncName string // Function name is the function name, adjusted to remove pointer annotation.
47
47
CallSite string // Position of the call/reference site. It is one of the formats token.Pos.String() returns or empty if unknown.
48
48
}
49
49
50
50
// summary summarize the analysis result.
51
- func summary (ci * callInfo , unaffected []* vulncheck.Vuln ) Summary {
52
- var affecting , unaffecting []Vuln
51
+ func summary (ci * callInfo , unaffected []* vulncheck.Vuln ) LegacySummary {
52
+ var affecting , unaffecting []LegacyVuln
53
53
for _ , vg := range ci .vulnGroups {
54
54
// All the vulns in vg have the same PkgPath, ModPath and OSV.
55
55
// All have a non-zero CallSink.
56
56
v0 := vg [0 ]
57
57
stacks := summarizeCallStacks (vg , ci )
58
58
59
- affecting = append (affecting , Vuln {
59
+ affecting = append (affecting , LegacyVuln {
60
60
OSV : vg [0 ].OSV ,
61
61
PkgPath : v0 .PkgPath ,
62
62
ModPath : v0 .ModPath ,
@@ -66,36 +66,36 @@ func summary(ci *callInfo, unaffected []*vulncheck.Vuln) Summary {
66
66
})
67
67
}
68
68
for _ , vuln := range unaffected {
69
- unaffecting = append (unaffecting , Vuln {
69
+ unaffecting = append (unaffecting , LegacyVuln {
70
70
OSV : vuln .OSV ,
71
71
PkgPath : vuln .PkgPath ,
72
72
ModPath : vuln .ModPath ,
73
73
FoundIn : foundVersion (vuln .ModPath , ci ),
74
74
FixedIn : fixedVersion (vuln .ModPath , vuln .OSV .Affected ),
75
75
})
76
76
}
77
- return Summary {
77
+ return LegacySummary {
78
78
Affecting : affecting ,
79
79
NonAffecting : unaffecting ,
80
80
}
81
81
}
82
82
83
- func summarizeCallStacks (vg []* vulncheck.Vuln , ci * callInfo ) []Trace {
84
- cs := make ([]Trace , 0 , len (vg ))
83
+ func summarizeCallStacks (vg []* vulncheck.Vuln , ci * callInfo ) []LegacyTrace {
84
+ cs := make ([]LegacyTrace , 0 , len (vg ))
85
85
// report one full call stack for each vuln.
86
86
for _ , v := range vg {
87
87
css := ci .callStacks [v ]
88
88
if len (css ) == 0 {
89
89
continue
90
90
}
91
- stack := make ([]StackEntry , 0 , len (css ))
91
+ stack := make ([]LegacyStackEntry , 0 , len (css ))
92
92
for _ , e := range css [0 ] {
93
- stack = append (stack , StackEntry {
93
+ stack = append (stack , LegacyStackEntry {
94
94
FuncName : FuncName (e .Function ),
95
95
CallSite : FuncPos (e .Call ),
96
96
})
97
97
}
98
- cs = append (cs , Trace {
98
+ cs = append (cs , LegacyTrace {
99
99
Symbol : v .Symbol ,
100
100
Desc : SummarizeCallStack (css [0 ], ci .topPackages , v .PkgPath ),
101
101
Stack : stack ,
0 commit comments