Skip to content

Commit

Permalink
Generalized state install CVE report.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mitchell-as committed Dec 24, 2024
1 parent 41e44c1 commit df6a059
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions internal/locale/locales/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ progress_search:
progress_platform_search:
other: "• Searching for platform in the ActiveState Catalog"
progress_cve_search:
other: "• Checking for vulnerabilities (CVEs) on [ACTIONABLE]{{.V0}}[/RESET] and its dependencies"
other: "• Checking for vulnerabilities (CVEs)"
setup_runtime:
other: "Setting Up Runtime"
progress_solve:
Expand Down Expand Up @@ -1138,13 +1138,13 @@ unstable_feature_banner:
other: "[NOTICE]Beta Feature: This feature is still in beta and may be unstable.[/RESET]\n"
warning_vulnerable:
other: |
[ERROR]Warning: Dependency has {{.V0}} direct and {{.V1}} indirect known vulnerabilities (CVEs)[/RESET]
[ERROR]Warning: Found {{.V0}} direct and {{.V1}} indirect known vulnerabilities (CVEs)[/RESET]
warning_vulnerable_indirectonly:
other: |
[ERROR]Warning: Dependency has {{.V0}} indirect known vulnerabilities (CVEs)[/RESET]
[ERROR]Warning: Found {{.V0}} indirect known vulnerabilities (CVEs)[/RESET]
warning_vulnerable_directonly:
other: |
[ERROR]Warning: Dependency has {{.V0}} known vulnerabilities (CVEs)[/RESET]
[ERROR]Warning: Found {{.V0}} known vulnerabilities (CVEs)[/RESET]
cve_critical:
other: Critical
cve_high:
Expand All @@ -1159,7 +1159,7 @@ disable_prompting_vulnerabilities:
other: To disable prompting for vulnerabilities run '[ACTIONABLE]state config set security.prompt.enabled false[/RESET]'.
warning_vulnerable_short:
other: |
[ERROR]Warning:[/RESET] Dependency has [ERROR]{{.V0}} known vulnerabilities (CVEs)[/RESET]. Severity: {{.V1}}. Run '[ACTIONABLE]state security[/RESET]' for more info.
[ERROR]Warning:[/RESET] Found [ERROR]{{.V0}} known vulnerabilities (CVEs)[/RESET]. Severity: {{.V1}}. Run '[ACTIONABLE]state security[/RESET]' for more info.
prompt_continue_pkg_operation:
other: |
Do you want to continue installing this dependency despite its vulnerabilities?
Expand Down
4 changes: 2 additions & 2 deletions internal/runbits/cves/cves.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ func (c *CveReport) Report(newBuildPlan *buildplan.BuildPlan, oldBuildPlan *buil
}
}

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

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

names := changedRequirements(oldBuildPlan, newBuildPlan)
vulnerabilities := model.CombineVulnerabilities(ingredientVulnerabilities, names...)

if c.prime.Prompt() == nil || !c.shouldPromptForSecurity(vulnerabilities) {
Expand Down
10 changes: 5 additions & 5 deletions test/integration/package_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ func (suite *PackageIntegrationTestSuite) TestCVE_NoPrompt() {
// Note: this version has 2 direct vulnerabilities, and 3 indirect vulnerabilities, but since
// we're not prompting, we're only showing a single count.
cp = ts.Spawn("install", "[email protected]")
cp.ExpectRe(`Warning: Dependency has .* vulnerabilities`, e2e.RuntimeSolvingTimeoutOpt)
cp.ExpectRe(`Warning: Found .* vulnerabilities`, e2e.RuntimeSolvingTimeoutOpt)
cp.ExpectExitCode(0)
}

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

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

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

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

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

0 comments on commit df6a059

Please sign in to comment.