Skip to content

Commit df6a059

Browse files
committed
Generalized state install CVE report.
Accurately listing all package names being checked would often result in a horrendously long notice. Also, now that `state install` allows multiple arguments, singular "Dependency" is not good grammar.
1 parent 41e44c1 commit df6a059

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
@@ -1099,7 +1099,7 @@ progress_search:
10991099
progress_platform_search:
11001100
other: "• Searching for platform in the ActiveState Catalog"
11011101
progress_cve_search:
1102-
other: "• Checking for vulnerabilities (CVEs) on [ACTIONABLE]{{.V0}}[/RESET] and its dependencies"
1102+
other: "• Checking for vulnerabilities (CVEs)"
11031103
setup_runtime:
11041104
other: "Setting Up Runtime"
11051105
progress_solve:
@@ -1138,13 +1138,13 @@ unstable_feature_banner:
11381138
other: "[NOTICE]Beta Feature: This feature is still in beta and may be unstable.[/RESET]\n"
11391139
warning_vulnerable:
11401140
other: |
1141-
[ERROR]Warning: Dependency has {{.V0}} direct and {{.V1}} indirect known vulnerabilities (CVEs)[/RESET]
1141+
[ERROR]Warning: Found {{.V0}} direct and {{.V1}} indirect known vulnerabilities (CVEs)[/RESET]
11421142
warning_vulnerable_indirectonly:
11431143
other: |
1144-
[ERROR]Warning: Dependency has {{.V0}} indirect known vulnerabilities (CVEs)[/RESET]
1144+
[ERROR]Warning: Found {{.V0}} indirect known vulnerabilities (CVEs)[/RESET]
11451145
warning_vulnerable_directonly:
11461146
other: |
1147-
[ERROR]Warning: Dependency has {{.V0}} known vulnerabilities (CVEs)[/RESET]
1147+
[ERROR]Warning: Found {{.V0}} known vulnerabilities (CVEs)[/RESET]
11481148
cve_critical:
11491149
other: Critical
11501150
cve_high:
@@ -1159,7 +1159,7 @@ disable_prompting_vulnerabilities:
11591159
other: To disable prompting for vulnerabilities run '[ACTIONABLE]state config set security.prompt.enabled false[/RESET]'.
11601160
warning_vulnerable_short:
11611161
other: |
1162-
[ERROR]Warning:[/RESET] Dependency has [ERROR]{{.V0}} known vulnerabilities (CVEs)[/RESET]. Severity: {{.V1}}. Run '[ACTIONABLE]state security[/RESET]' for more info.
1162+
[ERROR]Warning:[/RESET] Found [ERROR]{{.V0}} known vulnerabilities (CVEs)[/RESET]. Severity: {{.V1}}. Run '[ACTIONABLE]state security[/RESET]' for more info.
11631163
prompt_continue_pkg_operation:
11641164
other: |
11651165
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)