Skip to content

Muninn Security Scan: 7 min on most code PRs, scope the PR scan #5499

Closed

Description

@squid-protocol

Measured (2026-10-16 to 2026-10-18, last 8 successful PR runs): muninn.yml takes 8.2 min median, 8.7 max. Of that, 7.1 min is the step "Run Muninn" (skaldlab/muninn v0.3.13, fail-on: info, format: sarif,comment). It is already path-filtered (#5132) to engine code, dependency pins, workflows and .claude/**, but that still matches most code PRs: 23 runs in the window.

Proposed

  • Find out what the 7 minutes are: the action's own setup/download, or the scan itself. Check the action's inputs for a diff or changed-files mode, or a path include/exclude list. If it scans the whole tree, find which directories dominate. Corpora, tests/ fixtures and generated docs are likely candidates, and none of them are in the PR path filter anyway. (docs: Muninn same-SHA full vs PR-scope comparison, 8m18s -> 55s (Part of #5499) #6915)
  • If the action supports it: on pull_request, scan only the paths in the workflow's own filter, or only the PR's changed files. The weekly schedule and dispatch keep the full scan.
  • If the action has no such knob: record that in this issue with the evidence, and consider caching whatever it downloads per run.

Rule: no security coverage lost. The full-tree scan still runs weekly, and any file a PR changes that matches the path filter is still scanned on that PR.

Acceptance: "Run Muninn" step time on a typical code PR, before and after, in the PR body. The same findings on a full scan of the same SHA.

Activity

  1. added
    github-actions
    ci-cd
    scope:infra
    on Oct 18, 2026
  2. squid-protocol commented on Oct 18, 2026

    @squid-protocol
    OwnerAuthor

    Investigation (run 39159017208, 2026-10-18, one of the 23 PR runs; skaldlab/muninn v0.3.13 dfbf06a4)

    Where the time goes (job step timestamps and the action log):

    Phase Time
    Build the action's Docker image (Build skaldlab/muninn@...; it is runs: docker with image: Dockerfile, rebuilt every run: alpine tool downloads, pip/uv install of semgrep/checkov/zizmor) 43 s
    checkout 6 s
    Run Muninn (7 m 28 s), scanner by scanner: gitleaks 13 s, zizmor 3 s, actionlint 0 s, poutine 2 s, semgrep 42 s, osv-scanner 2 s, trivy 8 s ~70 s
    checkov (19:34:41 -> 19:40:59) 6 m 18 s
    Upload SARIF 7 s

    So the 7.1 min is not setup: it is the scan, and 84% of it is a single scanner, checkov. Every other scanner together is about a minute.

    Why checkov is slow: the action runs checkov --directory <target> --output json --quiet --compact over the whole checkout (scanner/checkov.go buildArgs; only --skip-check is wired). The repo has 5,116 tracked files, of which 3,865 are under tests/ (314 in tests/equivalence, 234 in each golden master, 96 in cics_crucible) and 719 under docs/. Only about 480 files (gitgalaxy 349, .github 50, .claude 50, ci 20, templates 13) are in the PR path filter. Checkov walks all of them (1,085 are yaml/json/Dockerfile/tf-shaped).

    What the action offers (inputs: token, fail-on, config, format, output, target):

    • No diff or changed-files mode.
    • exclude-paths in muninn.yml exists in the config struct, but only semgrep reads it (scanner/semgrep.go); checkov ignores it. (Semgrep is only 42 s.)
    • suppressions: (what our muninn.yml uses for tests/ etc.) is applied AFTER the scanners, to findings. It saves no scan time.
    • target takes one directory under the workspace, so it can narrow the scan, but it would prefix the paths in SARIF and the suppression ids.

    Conclusion for the checkboxes: (1) done, see above. (2) The action has no changed-files mode, but the scan can be narrowed to our own PR filter by not materialising the other files: a sparse checkout on pull_request, with paths unchanged so SARIF locations and suppressions keep working. (3) Not needed: the 43 s image build is the only cacheable part and is not worth the complexity.

    Proposed diff (needs allow_workflows; I may not edit .github/workflows):

    --- a/.github/workflows/muninn.yml
    +++ b/.github/workflows/muninn.yml
    @@
           - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
             with:
               persist-credentials: false
    +          # #5499: on a PR scan only the paths this workflow's own filter triggers on (checkov alone spent 6m18s
    +          # of 7m28s walking tests/ and docs/). Schedule and dispatch leave this empty = full tree, the backstop.
    +          # Keep the list in step with `on.pull_request.paths`; the three config files are needed by the scanners.
    +          sparse-checkout: ${{ github.event_name == 'pull_request' && '/gitgalaxy/
    +            /.github/
    +            /.claude/
    +            /ci/
    +            /templates/
    +            /pyproject.toml
    +            /requirements*.txt
    +            /action.yml
    +            /muninn.yml
    +            /zizmor.yml' || '' }}
    +          sparse-checkout-cone-mode: false

    Expected: checkov over ~480 files instead of 5,116, so "Run Muninn" should drop from ~7.5 min to roughly 2 min. I could not measure this without a workflow change; the PR that applies it should record the before/after step time (before: 7 m 28 s here) and a workflow_dispatch full scan of the same SHA as the equal-findings check. Coverage: every file the PR filter matches is still scanned on the PR (the sparse list is the same set, plus the config files), and the weekly full scan is unchanged. One caveat: a PR that changes only gitgalaxy/** is no longer checked against tests//docs/ content, but tests/ is fully suppressed in muninn.yml already and docs/ is not in the PR filter.

    Class sweep: class = "PR-time CI scan walks the whole tree although the workflow's path filter covers a small part". Siblings: none found in this pass for scanners; I did not audit other workflows (main-watch.yml mentions Muninn; not examined). No issues filed.

  3. squid-protocol commented on Oct 22, 2026

    @squid-protocol
    OwnerAuthor

    Churn run 5499-20261022T1835Z (host nyx) ended without a PR. Measure-only: Muninn step 7m28s -> ~57s confirmed. Open: osv-scanner exits 128 on PR runs since the sparse checkout (silent loss of dependency scanning); needs a workflow edit (owner, see #5501) and a same-SHA workflow_dispatch comparison. Not closing #5499.

  4. 17 remaining items

  5. squid-protocol commented on Oct 25, 2026

    @squid-protocol
    OwnerAuthor

    #6622 merged: a partial slice of [c:736e44f0] "Find out what the 7 minutes are: the action's own setup/download, or the scan itself. Check the action's inputs for a diff or changed-files mode, or a path include/exclude list. If it scans the whole "; left: the two same-SHA workflow_dispatch runs (scope: full, scope: pr) and the muninn_scope_diff.py result are still to be run after merge (CI runs, not edits) (promoter-bot)

  6. squid-protocol commented on Oct 28, 2026

    @squid-protocol
    OwnerAuthor

    Churn run 5499-20261028T1745Z (host nyx) ended without a PR. Already on main (#5612 sparse checkout, #6622, #6489); no PR needed. Checklist item 2 covered, item 3 not needed (no knob, 55 s).

  7. squid-protocol commented on Oct 29, 2026

    @squid-protocol
    OwnerAuthor

    Claimed by promoter-bot host nyx, lease renewed 2026-10-29T02:13Z. It lapses after 6 h without a renewal. To take it back, assign someone or remove the claim:nyx label.

  8. squid-protocol commented on Oct 29, 2026

    @squid-protocol
    OwnerAuthor

    Already landed on main via #5612 (sparse checkout of the workflow's own filter paths on pull_request; schedule/dispatch keep the full scan), with follow-ups #6489 and #6622. 'Run Muninn' went from 7m28s to ~56s on PR runs; same-SHA check on eb5934f: full scan 8m18s vs PR-scope 55s, muninn_scope_diff.py exit 0, both with no findings; test_muninn_scope.py guards against lost coverage. The no-knob fallback was not needed.

  9. squid-protocol commented on Oct 29, 2026

    @squid-protocol
    OwnerAuthor

    Churn run 5499-20261029T0228Z (host nyx) ended without a PR. work already on main (#5612); issue closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ci-cdclaim:nyxgithub-actionsperformancepriority: mediumscope:infra

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions