Skip to content

Commit 756a70c

Browse files
committed
chore: PR review comments
Updates based on the PR comments and regeneration of the docs
1 parent f4ddc68 commit 756a70c

File tree

9 files changed

+22
-21
lines changed

9 files changed

+22
-21
lines changed

docs/docs/references/configuration/cli/trivy_config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ trivy config [flags] DIR
1515
--check-namespaces strings Rego namespaces
1616
--checks-bundle-repository string OCI registry URL to retrieve checks bundle from (default "mirror.gcr.io/aquasec/trivy-checks:1")
1717
--cloud-api-url string API URL for Trivy Cloud platform (default "https://api.trivy.dev")
18-
--cloud-download-secret-config Download secret configurations from Trivy Cloud platform (default true)
1918
--cloud-server-scanning Use server-side image scanning in Trivy Cloud platform (default true)
2019
--cloud-token string Token used to athenticate with Trivy Cloud platform
2120
--cloud-trivy-server-url string Trivy Server URL for Trivy Cloud platform (default "https://scan.trivy.dev")
2221
--cloud-upload-results Upload results to Trivy Cloud platform (default true)
22+
--cloud-use-secret-config Use secret configurations from Trivy Cloud platform (default true)
2323
--compliance string compliance report to generate
2424
--config-check strings specify the paths to the Rego check files or to the directories containing them, applying config files
2525
--config-data strings specify paths from which data for the Rego checks will be recursively loaded

docs/docs/references/configuration/cli/trivy_filesystem.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ trivy filesystem [flags] PATH
2525
--check-namespaces strings Rego namespaces
2626
--checks-bundle-repository string OCI registry URL to retrieve checks bundle from (default "mirror.gcr.io/aquasec/trivy-checks:1")
2727
--cloud-api-url string API URL for Trivy Cloud platform (default "https://api.trivy.dev")
28-
--cloud-download-secret-config Download secret configurations from Trivy Cloud platform (default true)
2928
--cloud-server-scanning Use server-side image scanning in Trivy Cloud platform (default true)
3029
--cloud-token string Token used to athenticate with Trivy Cloud platform
3130
--cloud-trivy-server-url string Trivy Server URL for Trivy Cloud platform (default "https://scan.trivy.dev")
3231
--cloud-upload-results Upload results to Trivy Cloud platform (default true)
32+
--cloud-use-secret-config Use secret configurations from Trivy Cloud platform (default true)
3333
--compliance string compliance report to generate
3434
--config-check strings specify the paths to the Rego check files or to the directories containing them, applying config files
3535
--config-data strings specify paths from which data for the Rego checks will be recursively loaded

docs/docs/references/configuration/cli/trivy_image.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ trivy image [flags] IMAGE_NAME
3939
--check-namespaces strings Rego namespaces
4040
--checks-bundle-repository string OCI registry URL to retrieve checks bundle from (default "mirror.gcr.io/aquasec/trivy-checks:1")
4141
--cloud-api-url string API URL for Trivy Cloud platform (default "https://api.trivy.dev")
42-
--cloud-download-secret-config Download secret configurations from Trivy Cloud platform (default true)
4342
--cloud-server-scanning Use server-side image scanning in Trivy Cloud platform (default true)
4443
--cloud-token string Token used to athenticate with Trivy Cloud platform
4544
--cloud-trivy-server-url string Trivy Server URL for Trivy Cloud platform (default "https://scan.trivy.dev")
4645
--cloud-upload-results Upload results to Trivy Cloud platform (default true)
46+
--cloud-use-secret-config Use secret configurations from Trivy Cloud platform (default true)
4747
--compliance string compliance report to generate (built-in compliance's: docker-cis-1.6.0)
4848
--config-check strings specify the paths to the Rego check files or to the directories containing them, applying config files
4949
--config-data strings specify paths from which data for the Rego checks will be recursively loaded

docs/docs/references/configuration/cli/trivy_repository.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ trivy repository [flags] (REPO_PATH | REPO_URL)
2525
--check-namespaces strings Rego namespaces
2626
--checks-bundle-repository string OCI registry URL to retrieve checks bundle from (default "mirror.gcr.io/aquasec/trivy-checks:1")
2727
--cloud-api-url string API URL for Trivy Cloud platform (default "https://api.trivy.dev")
28-
--cloud-download-secret-config Download secret configurations from Trivy Cloud platform (default true)
2928
--cloud-server-scanning Use server-side image scanning in Trivy Cloud platform (default true)
3029
--cloud-token string Token used to athenticate with Trivy Cloud platform
3130
--cloud-trivy-server-url string Trivy Server URL for Trivy Cloud platform (default "https://scan.trivy.dev")
3231
--cloud-upload-results Upload results to Trivy Cloud platform (default true)
32+
--cloud-use-secret-config Use secret configurations from Trivy Cloud platform (default true)
3333
--commit string pass the commit hash to be scanned
3434
--config-check strings specify the paths to the Rego check files or to the directories containing them, applying config files
3535
--config-data strings specify paths from which data for the Rego checks will be recursively loaded

docs/docs/references/configuration/cli/trivy_rootfs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ trivy rootfs [flags] ROOTDIR
2828
--check-namespaces strings Rego namespaces
2929
--checks-bundle-repository string OCI registry URL to retrieve checks bundle from (default "mirror.gcr.io/aquasec/trivy-checks:1")
3030
--cloud-api-url string API URL for Trivy Cloud platform (default "https://api.trivy.dev")
31-
--cloud-download-secret-config Download secret configurations from Trivy Cloud platform (default true)
3231
--cloud-server-scanning Use server-side image scanning in Trivy Cloud platform (default true)
3332
--cloud-token string Token used to athenticate with Trivy Cloud platform
3433
--cloud-trivy-server-url string Trivy Server URL for Trivy Cloud platform (default "https://scan.trivy.dev")
3534
--cloud-upload-results Upload results to Trivy Cloud platform (default true)
35+
--cloud-use-secret-config Use secret configurations from Trivy Cloud platform (default true)
3636
--config-check strings specify the paths to the Rego check files or to the directories containing them, applying config files
3737
--config-data strings specify paths from which data for the Rego checks will be recursively loaded
3838
--config-file-schemas strings specify paths to JSON configuration file schemas to determine that a file matches some configuration and pass the schema to Rego checks for type checking

docs/docs/references/configuration/cli/trivy_vm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ trivy vm [flags] VM_IMAGE
2525
--cache-ttl duration cache TTL when using redis as cache backend
2626
--checks-bundle-repository string OCI registry URL to retrieve checks bundle from (default "mirror.gcr.io/aquasec/trivy-checks:1")
2727
--cloud-api-url string API URL for Trivy Cloud platform (default "https://api.trivy.dev")
28-
--cloud-download-secret-config Download secret configurations from Trivy Cloud platform (default true)
2928
--cloud-server-scanning Use server-side image scanning in Trivy Cloud platform (default true)
3029
--cloud-token string Token used to athenticate with Trivy Cloud platform
3130
--cloud-trivy-server-url string Trivy Server URL for Trivy Cloud platform (default "https://scan.trivy.dev")
3231
--cloud-upload-results Upload results to Trivy Cloud platform (default true)
32+
--cloud-use-secret-config Use secret configurations from Trivy Cloud platform (default true)
3333
--compliance string compliance report to generate
3434
--config-file-schemas strings specify paths to JSON configuration file schemas to determine that a file matches some configuration and pass the schema to Rego checks for type checking
3535
--custom-headers strings custom headers in client mode

pkg/cloud/hooks/report_hook_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func TestReportHook_PostReport(t *testing.T) {
213213

214214
if tt.errorContains != "" {
215215
require.Error(t, err)
216-
assert.Contains(t, err.Error(), tt.errorContains)
216+
require.ErrorContains(t, err, tt.errorContains)
217217
return
218218
}
219219

@@ -257,7 +257,7 @@ func TestReportHook_uploadResults(t *testing.T) {
257257

258258
if tt.errorContains != "" {
259259
require.Error(t, err)
260-
assert.Contains(t, err.Error(), tt.errorContains)
260+
require.ErrorContains(t, err, tt.errorContains)
261261
return
262262
}
263263

@@ -304,13 +304,12 @@ func TestReportHook_getPresignedUploadUrl(t *testing.T) {
304304

305305
if tt.errorContains != "" {
306306
require.Error(t, err)
307-
assert.Contains(t, err.Error(), tt.errorContains)
307+
require.ErrorContains(t, err, tt.errorContains)
308308
assert.Empty(t, url)
309309
return
310310
}
311311

312312
require.NoError(t, err)
313-
assert.NotEmpty(t, url)
314313
assert.Contains(t, url, mockServer.server.URL)
315314
assert.Contains(t, url, "/upload-report")
316315
})

pkg/cloud/token.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import (
1414
xhttp "github.com/aquasecurity/trivy/pkg/x/http"
1515
)
1616

17+
type accessTokenResponse struct {
18+
Token string `json:"token"`
19+
}
20+
1721
const (
1822
accessTokenPath = "/api-keys/access-tokens"
1923
)
@@ -30,12 +34,12 @@ func GetAccessToken(ctx context.Context, opts flag.Options) (string, error) {
3034
logger := log.WithPrefix(log.PrefixCloud)
3135

3236
client := xhttp.Client()
33-
url, err := url.JoinPath(opts.CloudOptions.ApiURL, accessTokenPath)
37+
u, err := url.JoinPath(opts.CloudOptions.ApiURL, accessTokenPath)
3438
if err != nil {
3539
return "", xerrors.Errorf("failed to join server URL and token path: %w", err)
3640
}
37-
logger.Debug("Requesting access token from Trivy Cloud", log.String("url", url))
38-
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, http.NoBody)
41+
logger.Debug("Requesting access token from Trivy Cloud", log.String("url", u))
42+
req, err := http.NewRequestWithContext(ctx, http.MethodPost, u, http.NoBody)
3943
if err != nil {
4044
return "", xerrors.Errorf("failed to create token request: %w", err)
4145
}
@@ -50,13 +54,11 @@ func GetAccessToken(ctx context.Context, opts flag.Options) (string, error) {
5054
return "", xerrors.Errorf("failed to get access token: received status code %d", resp.StatusCode)
5155
}
5256

53-
var accessTokenResponse struct {
54-
Token string `json:"token"`
55-
}
56-
if err := json.NewDecoder(resp.Body).Decode(&accessTokenResponse); err != nil {
57+
var tokenResponse accessTokenResponse
58+
if err := json.NewDecoder(resp.Body).Decode(&tokenResponse); err != nil {
5759
return "", xerrors.Errorf("failed to decode access token response: %w", err)
5860
}
5961

6062
logger.Debug("Created a new access token")
61-
return accessTokenResponse.Token, nil
63+
return tokenResponse.Token, nil
6264
}

pkg/flag/cloud_flags.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ var (
3737
}
3838

3939
CloudSecretConfigFlag = Flag[bool]{
40-
Name: "cloud-download-secret-config",
41-
ConfigName: "cloud.download-secret-config",
40+
Name: "cloud-use-secret-config",
41+
ConfigName: "cloud.use-secret-config",
4242
Default: true,
43-
Usage: "Download secret configurations from Trivy Cloud platform",
43+
Usage: "Use secret configurations from Trivy Cloud platform",
4444
TelemetrySafe: true,
4545
}
4646

0 commit comments

Comments
 (0)