@@ -105,13 +105,22 @@ func (c *creator) reportFromIssue(ctx context.Context, iss *issues.Issue) error
105
105
modulePath : modulePath (iss ),
106
106
aliases : aliases (iss ),
107
107
reviewStatus : reviewStatusOf (iss , c .reviewStatus ),
108
+ originalCVE : originalCVE (iss ),
108
109
})
109
110
if err != nil {
110
111
return err
111
112
}
112
113
return c .write (ctx , r )
113
114
}
114
115
116
+ func originalCVE (iss * issues.Issue ) string {
117
+ aliases := aliases (iss )
118
+ if iss .HasLabel (labelFirstParty ) && len (aliases ) == 1 && idstr .IsCVE (aliases [0 ]) {
119
+ return aliases [0 ]
120
+ }
121
+ return ""
122
+ }
123
+
115
124
func reviewStatusOf (iss * issues.Issue , reviewStatus report.ReviewStatus ) report.ReviewStatus {
116
125
d := defaultReviewStatus (iss )
117
126
// If a valid review status is provided, it overrides the priority label.
@@ -134,25 +143,33 @@ func defaultReviewStatus(iss *issues.Issue) report.ReviewStatus {
134
143
return report .Unreviewed
135
144
}
136
145
146
+ func (c * creator ) metaToSource (ctx context.Context , meta * reportMeta ) report.Source {
147
+ if cveID := meta .originalCVE ; cveID != "" {
148
+ log .Infof ("%s: creating original report for Go-CNA-assigned %s" , meta .id , cveID )
149
+ return report .OriginalCVE (cveID )
150
+ }
151
+
152
+ if src := c .sourceFromBestAlias (ctx , meta .aliases , * preferCVE ); src != nil {
153
+ log .Infof ("%s: picked %s as best source alias (from [%s])" , meta .id , src .SourceID (),
154
+ strings .Join (meta .aliases , ", " ))
155
+ return src
156
+ }
157
+
158
+ log .Infof ("%s: no suitable alias found, creating basic report" , meta .id )
159
+ return report .Original ()
160
+ }
161
+
137
162
func (c * creator ) reportFromMeta (ctx context.Context , meta * reportMeta ) (* yamlReport , error ) {
138
163
// Find the underlying module if the "module" provided is actually a package path.
139
164
if module , err := c .pc .FindModule (meta .modulePath ); err == nil { // no error
140
165
meta .modulePath = module
141
166
}
167
+ meta .aliases = c .allAliases (ctx , meta .aliases )
142
168
143
- var src report.Source
144
- aliases := c .allAliases (ctx , meta .aliases )
145
- src , ok := c .sourceFromBestAlias (ctx , aliases , * preferCVE )
146
- if ok {
147
- log .Infof ("%s: picked %s as best source alias (from [%s])" , meta .id , src .SourceID (), strings .Join (aliases , ", " ))
148
- } else {
149
- log .Infof ("%s: no suitable alias found, creating basic report" , meta .id )
150
- }
151
-
152
- raw := report .New (src , c .pc ,
169
+ raw := report .New (c .metaToSource (ctx , meta ), c .pc ,
153
170
report .WithGoID (meta .id ),
154
171
report .WithModulePath (meta .modulePath ),
155
- report .WithAliases (aliases ),
172
+ report .WithAliases (meta . aliases ),
156
173
report .WithReviewStatus (meta .reviewStatus ),
157
174
report .WithUnexcluded (meta .unexcluded ),
158
175
)
@@ -296,6 +313,7 @@ type reportMeta struct {
296
313
aliases []string
297
314
excluded , unexcluded report.ExcludedReason
298
315
reviewStatus report.ReviewStatus
316
+ originalCVE string
299
317
}
300
318
301
319
const todo = "TODO: "
@@ -348,9 +366,12 @@ func addTODOs(r *yamlReport) {
348
366
if len (r .Credits ) == 0 {
349
367
r .Credits = []string {todo + "who discovered/reported this vulnerability (optional)" }
350
368
}
351
- if len (r .CVEs ) == 0 {
369
+ if r . CVEMetadata == nil && len (r .CVEs ) == 0 {
352
370
r .CVEs = []string {todo + "CVE id(s) for this vulnerability" }
353
371
}
372
+ if r .CVEMetadata != nil && r .CVEMetadata .CWE == "" {
373
+ r .CVEMetadata .CWE = todo + "CWE ID"
374
+ }
354
375
addReferenceTODOs (r )
355
376
}
356
377
0 commit comments