@@ -12,6 +12,7 @@ import (
12
12
"strconv"
13
13
"strings"
14
14
15
+ "golang.org/x/vulndb/cmd/vulnreport/log"
15
16
"golang.org/x/vulndb/internal/cveclient"
16
17
"golang.org/x/vulndb/internal/cveschema5"
17
18
"golang.org/x/vulndb/internal/derrors"
@@ -51,11 +52,11 @@ func create(ctx context.Context, issueNumber int, cfg *createCfg) (err error) {
51
52
return err
52
53
}
53
54
54
- outlog . Println (filename )
55
+ log . Out (filename )
55
56
56
57
xrefs := xref (filename , r , cfg .existingByFile )
57
58
if len (xrefs ) != 0 {
58
- infolog . Printf ("found cross-references:\n %s" , xrefs )
59
+ log . Infof ("found cross-references:\n %s" , xrefs )
59
60
}
60
61
61
62
return nil
@@ -75,21 +76,21 @@ func createExcluded(ctx context.Context, cfg *createCfg) (err error) {
75
76
if err != nil {
76
77
return err
77
78
}
78
- infolog . Printf ("found %d issues with label %s\n " , len (tempIssues ), label )
79
+ log . Infof ("found %d issues with label %s\n " , len (tempIssues ), label )
79
80
isses = append (isses , tempIssues ... )
80
81
}
81
82
82
83
var created []string
83
84
for _ , iss := range isses {
84
85
// Don't create a report for an issue that already has a report.
85
86
if _ , ok := cfg .existingByIssue [iss .Number ]; ok {
86
- infolog . Printf ("skipped issue %d which already has a report\n " , iss .Number )
87
+ log . Infof ("skipped issue %d which already has a report\n " , iss .Number )
87
88
continue
88
89
}
89
90
90
91
r , err := createReport (ctx , cfg , iss )
91
92
if err != nil {
92
- errlog . Printf ("skipped issue %d: %v\n " , iss .Number , err )
93
+ log . Errf ("skipped issue %d: %v\n " , iss .Number , err )
93
94
continue
94
95
}
95
96
@@ -103,11 +104,11 @@ func createExcluded(ctx context.Context, cfg *createCfg) (err error) {
103
104
104
105
skipped := len (isses ) - len (created )
105
106
if skipped > 0 {
106
- infolog . Printf ("skipped %d issue(s)\n " , skipped )
107
+ log . Infof ("skipped %d issue(s)\n " , skipped )
107
108
}
108
109
109
110
if len (created ) == 0 {
110
- infolog . Printf ("no files to commit, exiting" )
111
+ log . Infof ("no files to commit, exiting" )
111
112
return nil
112
113
}
113
114
@@ -219,13 +220,13 @@ func createReport(ctx context.Context, cfg *createCfg, iss *issues.Issue) (r *re
219
220
220
221
aliases := allAliases (ctx , parsed .aliases , cfg .ghsaClient )
221
222
if alias , ok := pickBestAlias (aliases , * preferCVE ); ok {
222
- infolog . Printf ("creating report %s based on %s (picked from [%s])" , parsed .id , alias , strings .Join (aliases , ", " ))
223
+ log . Infof ("creating report %s based on %s (picked from [%s])" , parsed .id , alias , strings .Join (aliases , ", " ))
223
224
r , err = reportFromAlias (ctx , parsed .id , parsed .modulePath , alias , cfg )
224
225
if err != nil {
225
226
return nil , err
226
227
}
227
228
} else {
228
- infolog . Printf ("no alias found, creating basic report for %s" , parsed .id )
229
+ log . Infof ("no alias found, creating basic report for %s" , parsed .id )
229
230
r = & report.Report {
230
231
ID : parsed .id ,
231
232
Modules : []* report.Module {
@@ -258,11 +259,11 @@ func createReport(ctx context.Context, cfg *createCfg, iss *issues.Issue) (r *re
258
259
if cfg .aiClient != nil {
259
260
suggestions , err := suggest (ctx , cfg .aiClient , r , 1 )
260
261
if err != nil {
261
- warnlog . Printf ("failed to get AI-generated suggestions for %s: %v\n " , r .ID , err )
262
+ log . Warnf ("failed to get AI-generated suggestions for %s: %v\n " , r .ID , err )
262
263
} else if len (suggestions ) == 0 {
263
- warnlog . Printf ("failed to get AI-generated suggestions for %s (none generated)\n " , r .ID )
264
+ log . Warnf ("failed to get AI-generated suggestions for %s (none generated)\n " , r .ID )
264
265
} else {
265
- infolog . Printf ("applying AI-generated suggestion for %s" , r .ID )
266
+ log . Infof ("applying AI-generated suggestion for %s" , r .ID )
266
267
applySuggestion (r , suggestions [0 ])
267
268
}
268
269
}
@@ -313,7 +314,7 @@ func parseGithubIssue(iss *issues.Issue, pc *proxy.Client, allowClosed bool) (*p
313
314
}
314
315
315
316
if len (parsed .aliases ) == 0 {
316
- infolog . Printf ("%q has no CVE or GHSA IDs\n " , iss .Title )
317
+ log . Infof ("%q has no CVE or GHSA IDs\n " , iss .Title )
317
318
}
318
319
319
320
return parsed , nil
@@ -373,13 +374,13 @@ func reportFromAlias(ctx context.Context, id, modulePath, alias string, cfg *cre
373
374
if err != nil {
374
375
// If a CVE is not found, it is most likely a CVE we reserved but haven't
375
376
// published yet.
376
- infolog . Printf ("no published record found for %s, creating basic report" , alias )
377
+ log . Infof ("no published record found for %s, creating basic report" , alias )
377
378
return basicReport (id , modulePath ), nil
378
379
}
379
380
return report .CVE5ToReport (cve , id , modulePath , cfg .proxyClient ), nil
380
381
}
381
382
382
- infolog . Printf ("alias %s is not a CVE or GHSA, creating basic report" , alias )
383
+ log . Infof ("alias %s is not a CVE or GHSA, creating basic report" , alias )
383
384
return basicReport (id , modulePath ), nil
384
385
}
385
386
0 commit comments