Skip to content

Commit a3a7525

Browse files
authored
remove daysSinceLastScan as it is redundant with certifier interval (#2080)
* remove daysSinceLastScan as it is redundant with certifier interval Signed-off-by: pxp928 <[email protected]> * remove guacone certifier osv as --add-vuln-on-ingest=true is already being called Signed-off-by: pxp928 <[email protected]> --------- Signed-off-by: pxp928 <[email protected]>
1 parent c6b16de commit a3a7525

File tree

15 files changed

+70
-479
lines changed

15 files changed

+70
-479
lines changed

cmd/guaccollect/cmd/license.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ type cdOptions struct {
4545
interval time.Duration
4646
// enable/disable message publish to queue
4747
publishToQueue bool
48-
// days since the last vulnerability scan was run.
49-
// 0 means only run once
50-
daysSinceLastScan int
5148
// sets artificial latency on the certifier (default to nil)
5249
addedLatency *time.Duration
5350
// sets the batch size for pagination query for the certifier
@@ -81,7 +78,6 @@ you have access to read and write to the respective blob store.`,
8178
viper.GetString("interval"),
8279
viper.GetBool("service-poll"),
8380
viper.GetBool("publish-to-queue"),
84-
viper.GetInt("last-scan"),
8581
viper.GetString("certifier-latency"),
8682
viper.GetInt("certifier-batch-size"),
8783
)
@@ -102,7 +98,7 @@ you have access to read and write to the respective blob store.`,
10298
httpClient := http.Client{Transport: transport}
10399
gqlclient := graphql.NewClient(opts.graphqlEndpoint, &httpClient)
104100

105-
packageQueryFunc, err := getPackageQuery(gqlclient, opts.daysSinceLastScan, opts.batchSize, opts.addedLatency)
101+
packageQueryFunc, err := getPackageQuery(gqlclient, opts.batchSize, opts.addedLatency)
106102
if err != nil {
107103
logger.Errorf("error: %v", err)
108104
os.Exit(1)
@@ -120,7 +116,6 @@ func validateCDFlags(
120116
interval string,
121117
poll bool,
122118
pubToQueue bool,
123-
daysSince int,
124119
certifierLatencyStr string,
125120
batchSize int) (cdOptions, error) {
126121

@@ -138,7 +133,6 @@ func validateCDFlags(
138133
return opts, fmt.Errorf("failed to parser duration with error: %w", err)
139134
}
140135
opts.interval = i
141-
opts.daysSinceLastScan = daysSince
142136

143137
if certifierLatencyStr != "" {
144138
addedLatency, err := time.ParseDuration(certifierLatencyStr)
@@ -157,7 +151,7 @@ func validateCDFlags(
157151

158152
func init() {
159153
set, err := cli.BuildFlags([]string{"interval",
160-
"last-scan", "header-file", "certifier-latency",
154+
"header-file", "certifier-latency",
161155
"certifier-batch-size"})
162156
if err != nil {
163157
fmt.Fprintf(os.Stderr, "failed to setup flag: %v", err)

cmd/guaccollect/cmd/osv.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ type osvOptions struct {
5454
interval time.Duration
5555
// enable/disable message publish to queue
5656
publishToQueue bool
57-
// days since the last vulnerability scan was run.
58-
// 0 means only run once
59-
daysSinceLastScan int
6057
// sets artificial latency on the certifier (default to nil)
6158
addedLatency *time.Duration
6259
// sets the batch size for pagination query for the certifier
@@ -90,7 +87,6 @@ you have access to read and write to the respective blob store.`,
9087
viper.GetString("interval"),
9188
viper.GetBool("service-poll"),
9289
viper.GetBool("publish-to-queue"),
93-
viper.GetInt("last-scan"),
9490
viper.GetString("certifier-latency"),
9591
viper.GetInt("certifier-batch-size"),
9692
)
@@ -111,7 +107,7 @@ you have access to read and write to the respective blob store.`,
111107
httpClient := http.Client{Transport: transport}
112108
gqlclient := graphql.NewClient(opts.graphqlEndpoint, &httpClient)
113109

114-
packageQueryFunc, err := getPackageQuery(gqlclient, opts.daysSinceLastScan, opts.batchSize, opts.addedLatency)
110+
packageQueryFunc, err := getPackageQuery(gqlclient, opts.batchSize, opts.addedLatency)
115111
if err != nil {
116112
logger.Errorf("error: %v", err)
117113
os.Exit(1)
@@ -129,7 +125,6 @@ func validateOSVFlags(
129125
interval string,
130126
poll bool,
131127
pubToQueue bool,
132-
daysSince int,
133128
certifierLatencyStr string,
134129
batchSize int) (osvOptions, error) {
135130

@@ -147,7 +142,6 @@ func validateOSVFlags(
147142
return opts, fmt.Errorf("failed to parser duration with error: %w", err)
148143
}
149144
opts.interval = i
150-
opts.daysSinceLastScan = daysSince
151145

152146
if certifierLatencyStr != "" {
153147
addedLatency, err := time.ParseDuration(certifierLatencyStr)
@@ -170,9 +164,9 @@ func getCertifierPublish(ctx context.Context, blobStore *blob.BlobStore, pubsub
170164
}, nil
171165
}
172166

173-
func getPackageQuery(client graphql.Client, daysSinceLastScan int, batchSize int, addedLatency *time.Duration) (func() certifier.QueryComponents, error) {
167+
func getPackageQuery(client graphql.Client, batchSize int, addedLatency *time.Duration) (func() certifier.QueryComponents, error) {
174168
return func() certifier.QueryComponents {
175-
packageQuery := root_package.NewPackageQuery(client, daysSinceLastScan, batchSize, addedLatency)
169+
packageQuery := root_package.NewPackageQuery(client, batchSize, addedLatency)
176170
return packageQuery
177171
}, nil
178172
}
@@ -255,7 +249,7 @@ func initializeNATsandCertifier(ctx context.Context, blobAddr, pubsubAddr string
255249

256250
func init() {
257251
set, err := cli.BuildFlags([]string{"interval",
258-
"last-scan", "header-file", "certifier-latency",
252+
"header-file", "certifier-latency",
259253
"certifier-batch-size"})
260254
if err != nil {
261255
fmt.Fprintf(os.Stderr, "failed to setup flag: %v", err)

cmd/guaccollect/cmd/scorecard.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ type scorecardOptions struct {
4646
interval time.Duration
4747
// enable/disable message publish to queue
4848
publishToQueue bool
49-
// setting "daysSinceLastScan" to 0 does not check the timestamp on the scorecard that exist
50-
daysSinceLastScan int
5149
// sets artificial latency on the certifier (default to nil)
5250
addedLatency *time.Duration
5351
// sets the batch size for pagination query for the certifier
@@ -81,7 +79,6 @@ you have access to read and write to the respective blob store.`,
8179
viper.GetString("interval"),
8280
viper.GetBool("service-poll"),
8381
viper.GetBool("publish-to-queue"),
84-
viper.GetInt("last-scan"),
8582
viper.GetString("certifier-latency"),
8683
viper.GetInt("certifier-batch-size"),
8784
)
@@ -120,7 +117,7 @@ you have access to read and write to the respective blob store.`,
120117
httpClient := http.Client{Transport: transport}
121118
gqlclient := graphql.NewClient(opts.graphqlEndpoint, &httpClient)
122119

123-
query, err := sc.NewCertifier(gqlclient, opts.daysSinceLastScan, opts.batchSize, opts.addedLatency)
120+
query, err := sc.NewCertifier(gqlclient, opts.batchSize, opts.addedLatency)
124121
if err != nil {
125122
logger.Errorf("unable to create source query: %v\n", err)
126123
os.Exit(1)
@@ -138,7 +135,6 @@ func validateScorecardFlags(
138135
interval string,
139136
poll bool,
140137
pubToQueue bool,
141-
daysSince int,
142138
certifierLatencyStr string,
143139
batchSize int) (scorecardOptions, error) {
144140

@@ -156,7 +152,6 @@ func validateScorecardFlags(
156152
return opts, fmt.Errorf("failed to parser duration with error: %w", err)
157153
}
158154
opts.interval = i
159-
opts.daysSinceLastScan = daysSince
160155

161156
if certifierLatencyStr != "" {
162157
addedLatency, err := time.ParseDuration(certifierLatencyStr)
@@ -175,7 +170,7 @@ func validateScorecardFlags(
175170

176171
func init() {
177172
set, err := cli.BuildFlags([]string{"interval",
178-
"last-scan", "header-file", "certifier-latency",
173+
"header-file", "certifier-latency",
179174
"certifier-batch-size"})
180175
if err != nil {
181176
fmt.Fprintf(os.Stderr, "failed to setup flag: %v", err)

cmd/guacone/cmd/license.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ var cdCmd = &cobra.Command{
9696

9797
httpClient := http.Client{Transport: transport}
9898
gqlclient := graphql.NewClient(opts.graphqlEndpoint, &httpClient)
99-
packageQuery := root_package.NewPackageQuery(gqlclient, 0, opts.batchSize, opts.addedLatency)
99+
packageQuery := root_package.NewPackageQuery(gqlclient, opts.batchSize, opts.addedLatency)
100100

101101
totalNum := 0
102102
docChan := make(chan *processor.Document)

cmd/guacone/cmd/osv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ var osvCmd = &cobra.Command{
9696

9797
httpClient := http.Client{Transport: transport}
9898
gqlclient := graphql.NewClient(opts.graphqlEndpoint, &httpClient)
99-
packageQuery := root_package.NewPackageQuery(gqlclient, 0, opts.batchSize, opts.addedLatency)
99+
packageQuery := root_package.NewPackageQuery(gqlclient, opts.batchSize, opts.addedLatency)
100100

101101
totalNum := 0
102102
docChan := make(chan *processor.Document)

cmd/guacone/cmd/scorecard.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ var scorecardCmd = &cobra.Command{
112112
}
113113

114114
// scorecard certifier is the certifier that gets the scorecard data graphQL
115-
// setting "daysSinceLastScan" to 0 does not check the timestamp on the scorecard that exist
116-
query, err := sc.NewCertifier(gqlclient, 0, opts.batchSize, opts.addedLatency)
115+
query, err := sc.NewCertifier(gqlclient, opts.batchSize, opts.addedLatency)
117116

118117
if err != nil {
119118
fmt.Printf("unable to create scorecard certifier: %v\n", err)

container_files/guac/guac.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ use-csub: true
2222
poll: true
2323
# certifier interval
2424
interval: 20m
25-
# days since the last vulnerability scan was run. 0 means only run once
26-
last-scan: 0
25+
2726
# set the batch size for the package pagination query
2827
certifier-batch-size: 60000
2928
# add artificial latency to throttle the certifier

guac.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ blob-addr: file:///tmp/blobstore?no_tmp_dir=true
2626

2727
# certifier interval
2828
interval: 20m
29-
# days since the last vulnerability scan was run. 0 means only run once
30-
last-scan: 0
29+
3130
# set the batch size for the package pagination query
3231
certifier-batch-size: 60000
3332
# add artificial latency to throttle the certifier

internal/testing/cmd/pubsub_test/cmd/osv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func getCertifierPublish(ctx context.Context, blobStore *blob.BlobStore, pubsub
9292

9393
func getPackageQuery(client graphql.Client) (func() certifier.QueryComponents, error) {
9494
return func() certifier.QueryComponents {
95-
packageQuery := root_package.NewPackageQuery(client, 0, 60000, nil)
95+
packageQuery := root_package.NewPackageQuery(client, 60000, nil)
9696
return packageQuery
9797
}, nil
9898
}

internal/testing/e2e/e2e

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ for command in "${ingestion_commands[@]}"; do
148148
echo @@@@ Waiting
149149
sleep 60
150150

151-
go run ${GUAC_DIR}"/cmd/guacone" certifier osv -p=false
152-
153151
if [ $? -ne 0 ]; then
154152
echo "Error: Command '$command' failed" | tee -a "$LOG_FILE"
155153
exit 1

0 commit comments

Comments
 (0)