Skip to content

Commit 245e064

Browse files
authored
Merge pull request #3624 from ActiveState/mitchell/dx-3186
Generalized `state install` CVE report.
2 parents c210e20 + df6a059 commit 245e064

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

internal/locale/locales/en-us.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ progress_search:
11011101
progress_platform_search:
11021102
other: "• Searching for platform in the ActiveState Catalog"
11031103
progress_cve_search:
1104-
other: "• Checking for vulnerabilities (CVEs) on [ACTIONABLE]{{.V0}}[/RESET] and its dependencies"
1104+
other: "• Checking for vulnerabilities (CVEs)"
11051105
setup_runtime:
11061106
other: "Setting Up Runtime"
11071107
progress_solve:
@@ -1140,13 +1140,13 @@ unstable_feature_banner:
11401140
other: "[NOTICE]Beta Feature: This feature is still in beta and may be unstable.[/RESET]\n"
11411141
warning_vulnerable:
11421142
other: |
1143-
[ERROR]Warning: Dependency has {{.V0}} direct and {{.V1}} indirect known vulnerabilities (CVEs)[/RESET]
1143+
[ERROR]Warning: Found {{.V0}} direct and {{.V1}} indirect known vulnerabilities (CVEs)[/RESET]
11441144
warning_vulnerable_indirectonly:
11451145
other: |
1146-
[ERROR]Warning: Dependency has {{.V0}} indirect known vulnerabilities (CVEs)[/RESET]
1146+
[ERROR]Warning: Found {{.V0}} indirect known vulnerabilities (CVEs)[/RESET]
11471147
warning_vulnerable_directonly:
11481148
other: |
1149-
[ERROR]Warning: Dependency has {{.V0}} known vulnerabilities (CVEs)[/RESET]
1149+
[ERROR]Warning: Found {{.V0}} known vulnerabilities (CVEs)[/RESET]
11501150
cve_critical:
11511151
other: Critical
11521152
cve_high:
@@ -1161,7 +1161,7 @@ disable_prompting_vulnerabilities:
11611161
other: To disable prompting for vulnerabilities run '[ACTIONABLE]state config set security.prompt.enabled false[/RESET]'.
11621162
warning_vulnerable_short:
11631163
other: |
1164-
[ERROR]Warning:[/RESET] Dependency has [ERROR]{{.V0}} known vulnerabilities (CVEs)[/RESET]. Severity: {{.V1}}. Run '[ACTIONABLE]state security[/RESET]' for more info.
1164+
[ERROR]Warning:[/RESET] Found [ERROR]{{.V0}} known vulnerabilities (CVEs)[/RESET]. Severity: {{.V1}}. Run '[ACTIONABLE]state security[/RESET]' for more info.
11651165
prompt_continue_pkg_operation:
11661166
other: |
11671167
Do you want to continue installing this dependency despite its vulnerabilities?

internal/runbits/cves/cves.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ func (c *CveReport) Report(newBuildPlan *buildplan.BuildPlan, oldBuildPlan *buil
7777
}
7878
}
7979

80-
names := changedRequirements(oldBuildPlan, newBuildPlan)
81-
pg := output.StartSpinner(c.prime.Output(), locale.Tr("progress_cve_search", strings.Join(names, ", ")), constants.TerminalAnimationInterval)
80+
pg := output.StartSpinner(c.prime.Output(), locale.T("progress_cve_search"), constants.TerminalAnimationInterval)
8281

8382
ingredientVulnerabilities, err := model.FetchVulnerabilitiesForIngredients(c.prime.Auth(), ingredients)
8483
if err != nil {
@@ -96,6 +95,7 @@ func (c *CveReport) Report(newBuildPlan *buildplan.BuildPlan, oldBuildPlan *buil
9695
pg.Stop(locale.T("progress_unsafe"))
9796
pg = nil
9897

98+
names := changedRequirements(oldBuildPlan, newBuildPlan)
9999
vulnerabilities := model.CombineVulnerabilities(ingredientVulnerabilities, names...)
100100

101101
if c.prime.Prompt() == nil || !c.shouldPromptForSecurity(vulnerabilities) {

test/integration/package_int_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ func (suite *PackageIntegrationTestSuite) TestCVE_NoPrompt() {
571571
// Note: this version has 2 direct vulnerabilities, and 3 indirect vulnerabilities, but since
572572
// we're not prompting, we're only showing a single count.
573573
cp = ts.Spawn("install", "[email protected]")
574-
cp.ExpectRe(`Warning: Dependency has .* vulnerabilities`, e2e.RuntimeSolvingTimeoutOpt)
574+
cp.ExpectRe(`Warning: Found .* vulnerabilities`, e2e.RuntimeSolvingTimeoutOpt)
575575
cp.ExpectExitCode(0)
576576
}
577577

@@ -594,7 +594,7 @@ func (suite *PackageIntegrationTestSuite) TestCVE_Prompt() {
594594
cp.ExpectExitCode(0)
595595

596596
cp = ts.Spawn("install", "[email protected]", "--ts=2024-09-10T16:36:34.393Z")
597-
cp.ExpectRe(`Warning: Dependency has .* vulnerabilities`, e2e.RuntimeSolvingTimeoutOpt)
597+
cp.ExpectRe(`Warning: Found .* vulnerabilities`, e2e.RuntimeSolvingTimeoutOpt)
598598
cp.Expect("Do you want to continue")
599599
cp.SendLine("y")
600600
cp.ExpectExitCode(0)
@@ -619,7 +619,7 @@ func (suite *PackageIntegrationTestSuite) TestCVE_NonInteractive() {
619619
cp.ExpectExitCode(0)
620620

621621
cp = ts.Spawn("install", "[email protected]", "--ts=2024-09-10T16:36:34.393Z", "--non-interactive")
622-
cp.ExpectRe(`Warning: Dependency has .* vulnerabilities`, e2e.RuntimeSolvingTimeoutOpt)
622+
cp.ExpectRe(`Warning: Found .* vulnerabilities`, e2e.RuntimeSolvingTimeoutOpt)
623623
cp.Expect("Aborting because State Tool is running in non-interactive mode")
624624
cp.ExpectNotExitCode(0)
625625
}
@@ -643,7 +643,7 @@ func (suite *PackageIntegrationTestSuite) TestCVE_Force() {
643643
cp.ExpectExitCode(0)
644644

645645
cp = ts.Spawn("install", "[email protected]", "--ts=2024-09-10T16:36:34.393Z", "--force")
646-
cp.ExpectRe(`Warning: Dependency has .* vulnerabilities`, e2e.RuntimeSolvingTimeoutOpt)
646+
cp.ExpectRe(`Warning: Found .* vulnerabilities`, e2e.RuntimeSolvingTimeoutOpt)
647647
cp.Expect("Continuing because the '--force' flag is set")
648648
cp.ExpectExitCode(0)
649649
}
@@ -664,7 +664,7 @@ func (suite *PackageIntegrationTestSuite) TestCVE_Indirect() {
664664
cp.ExpectExitCode(0)
665665

666666
cp = ts.Spawn("install", "private/ActiveState-CLI-Testing/language/python/django_dep", "--ts=2024-09-10T16:36:34.393Z")
667-
cp.ExpectRe(`Warning: Dependency has \d+ indirect known vulnerabilities`, e2e.RuntimeSolvingTimeoutOpt)
667+
cp.ExpectRe(`Warning: Found \d+ indirect known vulnerabilities`, e2e.RuntimeSolvingTimeoutOpt)
668668
cp.Expect("Do you want to continue")
669669
cp.SendLine("n")
670670
cp.ExpectExitCode(1)

0 commit comments

Comments
 (0)