Skip to content

fix(ci): the Kubescape guard does not count a scan with an interleaved flag or no framework list #4379

Closed

Description

@devantler

🤖 Generated by the Agentic Engineer

Found while working on #3585.

Evidence

Each line below sits in a second run: step beside the real ksail workload scan --framework nsa,mitre --compliance-threshold 95 step. The guard on main (9da24196) accepts every one and reports nsa,mitre, while the line runs a scan of nsa alone that can overwrite the uploaded SARIF.

# Line Why the guard misses it
U1 ksail workload --benchmark scan --framework nsa -o kubescape.sarif A root flag between workload and scan (also --experimental, --config=…). Cobra strips flags while it resolves subcommands, so this is the scan command, but every rule looks for workload scan as adjacent words.
U2 ksail workload scan -o kubescape.sarif A scan with no --framework is skipped rather than counted. It runs ksail's default framework set, which is nsa here because the repo's ksail.yaml sets none, and it writes the uploaded file.

U1 relies on Cobra's stripFlags (reviewed in source). U2 relies on the --framework default of nsa declared by ksail workload scan.

Audience and problem

Same gate as #2823 and #3338: the guard must count every scan that runs, because a reduced scan beside the full one can replace the SARIF that Code Scanning keeps.

Direction

  • U1: find the subcommand the way Cobra does, skipping flag words between ksail, workload and scan, or refuse any ksail line whose subcommand words are not adjacent.
  • U2: count an unframed ksail workload scan as an invocation. The step then holds two scans and is refused, and an unframed scan on its own is refused as reading no framework list.

Acceptance criteria

  • U1 (each root flag) and U2 are refused, each by a test that fails on main.
  • Controls stay accepted: the real workflows, and ksail --version / ksail workload validate steps beside the scan.
  • Every existing test passes unmodified.

Activity

  1. added theissue type on Oct 2, 2026
  2. moved this to 📥 Backlog in 🌊 Project Boardon Oct 2, 2026
  3. self-assigned this
    on Oct 3, 2026
  4. added 2 commits that reference this issue on Oct 3, 2026
  5. devantler commented on Oct 3, 2026

    @devantler
    ContributorAuthor

    🤖 Generated by the Agentic Engineer

    Delivered by merged PR #4431, reviewed source commit 06d951f.

    The shared regression table refuses reduced scans with each original interleaved root flag and scans lacking an explicit framework list. Separate positive controls prove full scans with supported interleaved flags are parsed correctly. Version/validation commands beside the scan and the real workflows remain accepted.

    Acceptance was checked against the original issue body. The original historical test file is unchanged. All 266 test/subtest assertions passed with race detection, including 28 Bash recording witnesses; the unframed-scan safeguard mutation fails its intended regression. Source CI and protected merge-queue CI passed. Closing as completed.

  6. moved this from 📥 Backlog to ✅ Done in 🌊 Project Boardon Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

Priority

None yet

Effort

None yet

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions