Skip to content

Commit 5abb45c

Browse files
committed
test(java): scan pom.xml integration tests offline to avoid Maven Central rate limits
The pom.xml fixture used in integration tests declares jackson-databind as a direct dependency. Resolving its transitive dependencies fetches POMs from Maven Central, which now returns 429 Too Many Requests due to tightened rate limits. Since aquasecurity#10693 a 429 is a fatal error, so these tests fail intermittently (the limit is per-IP and accumulates across a CI job). The golden files contain only the direct jackson-databind dependency, so offline scanning produces identical output while removing the dependency on a live Maven Central. Run the three pom.xml integration tests with --offline-scan. Remote resolution stays covered by the pom parser unit tests.
1 parent f2a1237 commit 5abb45c

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

integration/client_server_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type csArgs struct {
3737
secretConfig string
3838
Distro string
3939
VulnSeveritySources []string
40+
OfflineScan bool
4041
}
4142

4243
// TestClientServer tests the client-server mode of Trivy.
@@ -282,6 +283,7 @@ func TestClientServer(t *testing.T) {
282283
Command: "repo",
283284
RemoteAddrOption: "--server",
284285
Target: "testdata/fixtures/repo/pom/",
286+
OfflineScan: true,
285287
},
286288
golden: goldenPom,
287289
},
@@ -727,6 +729,9 @@ func setupClient(t *testing.T, c csArgs, addr, cacheDir string) []string {
727729
if c.IgnoreUnfixed {
728730
osArgs = append(osArgs, "--ignore-unfixed")
729731
}
732+
if c.OfflineScan {
733+
osArgs = append(osArgs, "--offline-scan")
734+
}
730735
if len(c.Severity) != 0 {
731736
osArgs = append(osArgs,
732737
"--severity", strings.Join(c.Severity, ","),

integration/repo_test.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type repoTestArgs struct {
3636
vex string
3737
vulnSeveritySources []string
3838
tfExcludeDownloadedModules bool
39+
offlineScan bool
3940
}
4041

4142
// TestRepository tests `trivy repo` with the local code repositories.
@@ -210,8 +211,9 @@ func TestRepository(t *testing.T) {
210211
{
211212
name: "pom",
212213
args: repoTestArgs{
213-
scanner: types.VulnerabilityScanner,
214-
input: "testdata/fixtures/repo/pom",
214+
scanner: types.VulnerabilityScanner,
215+
input: "testdata/fixtures/repo/pom",
216+
offlineScan: true,
215217
},
216218
golden: goldenPom,
217219
},
@@ -481,10 +483,11 @@ func TestRepository(t *testing.T) {
481483
{
482484
name: "pom.xml generating CycloneDX SBOM (with vulnerabilities)",
483485
args: repoTestArgs{
484-
command: "fs",
485-
scanner: types.VulnerabilityScanner,
486-
format: "cyclonedx",
487-
input: "testdata/fixtures/repo/pom",
486+
command: "fs",
487+
scanner: types.VulnerabilityScanner,
488+
format: "cyclonedx",
489+
input: "testdata/fixtures/repo/pom",
490+
offlineScan: true,
488491
},
489492
golden: goldenPomCycloneDX,
490493
},
@@ -691,6 +694,9 @@ func buildArgs(t *testing.T, cacheDir, command string, format types.Format, test
691694
if testArgs.tfExcludeDownloadedModules {
692695
osArgs = append(osArgs, "--tf-exclude-downloaded-modules")
693696
}
697+
if testArgs.offlineScan {
698+
osArgs = append(osArgs, "--offline-scan")
699+
}
694700

695701
return osArgs
696702
}

0 commit comments

Comments
 (0)