Skip to content

ci: run code scan only when dependency files change - #219

Open
yaroslavmokflmg wants to merge 7 commits into
mainfrom
hotfix/conditional-code-scan
Open

yaroslavmokflmg wants to merge 7 commits into
mainfrom
hotfix/conditional-code-scan

Conversation

@yaroslavmokflmg

@yaroslavmokflmg yaroslavmokflmg commented Sep 28, 2026 •

Copy link
Copy Markdown

The trivy action now checks (dorny/paths-filter) whether the PR touched anything under the scan path, minus skip-dirs, or the root pom.xml, .trivyignore or the action itself; otherwise the scan is skipped. Same action in every repo, workflows only grant pull-requests: read.

Change-Set: hotfix-conditional-code-scan

Change set flamingo-stack/fleetmdm#219: these pull requests are one change, reviewed together.

Merge order: #219 → flamingo-stack/meshcentral#213 → flamingo-stack/openframe-oss-frontend#498 → flamingo-stack/openframe-oss-tenant#2379

Linked by the Depends-On / Change-Set lines in these descriptions; this block is maintained by the hub.

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

🦩 Flamingo Code Review

2 finding(s) — 0 action required · 2 recommended · 0 informational

Mode: advisory · 2 defect(s) outside any rule

Inline comments: 2 new

Change set

  • Not linked to flamingo-stack/openframe-oss-tenant#2379, flamingo-stack/meshcentral#213, flamingo-stack/openframe-oss-lib#2408, flamingo-stack/openframe-oss-frontend#498 (open, same branch name). If this pull request needs one of them merged first, add a line to this pull request's description:
  • Depends-On: https://github.com/flamingo-stack/openframe-oss-tenant/pull/2379
  • Depends-On: https://github.com/flamingo-stack/meshcentral/pull/213
  • Depends-On: https://github.com/flamingo-stack/openframe-oss-lib/pull/2408
  • Depends-On: https://github.com/flamingo-stack/openframe-oss-frontend/pull/498
  • The Flamingo reviewer then checks imports and consumers against that pull request’s branch and states the merge order.

Need another pass? Commits pushed after this review are not reviewed automatically.

  • Review the new commits — the commits added since this review
  • Review the whole diff again — ignoring what was already reviewed

Prefer typing? Comment @flamingo-review, or @flamingo-review full. To review every push on this pull request, add the flamingo-review-always label.

React 👍/👎 on inline comments to teach the reviewer.

Started 2026-09-28 08:26 UTC · updated 2026-09-28 08:29 UTC · workflow run

@yaroslavmokflmg yaroslavmokflmg self-assigned this Sep 28, 2026
Comment on lines 74 to 78
- name: Scan code
if: steps.should_run.outputs.deps == 'true'
uses: ./.github/steps/trivy
with:
scan: code

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 [warn/recommended] Trivy code scan now silently skipped for PRs, undermining required security gate

The 'Scan code' step (Trivy vulnerability scan) is now gated behind steps.should_run.outputs.deps == 'true', meaning the mandatory code security scan only runs when files matching the deps filter (pom.xml, package.json, go.mod, Dockerfile*, etc.) changed. Any PR that changes application source code without touching those specific manifest/lock files (e.g. changes to .go source files that introduce a vulnerable pattern, or changes elsewhere not covered by the filter globs) will skip the scan entirely, even though the job is still reported as passing (skipped steps do not fail the job). This weakens the security posture of a workflow whose stated purpose is code scanning on every pull request, and should be paired with clear reasoning/documentation on why skipping is safe, or the filter should be broadened to include source file changes relevant to the scan.

Evidence
      - name: Scan code
        if: steps.should_run.outputs.deps == 'true'
        uses: ./.github/steps/trivy
        with:
          scan: code
🤖 Prompt for AI agents
In .github/workflows/test.yml around lines 74-78, address this code-review finding: Trivy code scan now silently skipped for PRs, undermining required security gate.
The 'Scan code' step (Trivy vulnerability scan) is now gated behind steps.should_run.outputs.deps == 'true', meaning the mandatory code security scan only runs when files matching the deps filter (pom.xml, package.json, go.mod, Dockerfile*, etc.) changed. Any PR that changes application source code without touching those specific manifest/lock files (e.g. changes to .go source files that introduce a vulnerable pattern, or changes elsewhere not covered by the filter globs) will skip the scan entirely, even though the job is still reported as passing (skipped steps do not fail the job). This weakens the security posture of a workflow whose stated purpose is code scanning on every pull request, and should be paired with clear reasoning/documentation on why skipping is safe, or the filter should be broadened to include source file changes relevant to the scan.
The flagged code:
```
      - name: Scan code
        if: steps.should_run.outputs.deps == 'true'
        uses: ./.github/steps/trivy
        with:
          scan: code
```
Make the minimal change that resolves the finding; do not refactor unrelated code.

confidence: 55 — react 👍/👎 to teach the reviewer

Comment thread .github/workflows/test.yml Outdated
Comment on lines +47 to +65
- name: Check if scan should run
id: should_run
uses: dorny/paths-filter@v4.0.2
with:
filters: |
deps:
- '**/pom.xml'
- '.mvn/**'
- '**/package.json'
- '**/package-lock.json'
- '**/yarn.lock'
- '**/pnpm-lock.yaml'
- '**/go.mod'
- '**/go.sum'
- '**/Cargo.toml'
- '**/Cargo.lock'
- '**/Dockerfile*'
- '.trivyignore'
- '.github/steps/trivy/**'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 [warn/recommended] paths-filter runs against the base checkout, not the PR head, likely misdetecting changed files

The new 'Check if scan should run' step using dorny/paths-filter runs BEFORE the 'Checkout' step that fetches the PR head SHA (actions/checkout with ref: ${{ github.event.pull_request.head.sha }}). Since paths-filter is not itself preceded by a checkout of the PR head in this job, it evaluates against whatever ref the runner's default checkout provides (or none at all, since the explicit Checkout step is now itself gated by the filter's own output). This can produce incorrect deps filtering: on the initial run there is no checkout yet, so paths-filter falls back to comparing commit refs via the GitHub API only if a 'base'/'ref' is set, but no explicit base/head input is provided here, making the result depend on default behavior rather than the intended PR diff. Combined with the fact that the Checkout step is now conditioned on the filter's own output, if the filter step misbehaves (e.g., due to missing checkout context) the whole job silently skips the security scan for PRs that do touch dependency files, which is a correctness/security regression for a job whose entire purpose is dependency vulnerability scanning.

Evidence
      - name: Check if scan should run
        id: should_run
        uses: dorny/paths-filter@v4.0.2
        with:
          filters: |
            deps:
              - '**/pom.xml'
              - '.mvn/**'
              - '**/package.json'
              - '**/package-lock.json'
              - '**/yarn.lock'
              - '**/pnpm-lock.yaml'
🤖 Prompt for AI agents
In .github/workflows/test.yml around lines 47-65, address this code-review finding: paths-filter runs against the base checkout, not the PR head, likely misdetecting changed files.
The new 'Check if scan should run' step using dorny/paths-filter runs BEFORE the 'Checkout' step that fetches the PR head SHA (actions/checkout with ref: ${{ github.event.pull_request.head.sha }}). Since paths-filter is not itself preceded by a checkout of the PR head in this job, it evaluates against whatever ref the runner's default checkout provides (or none at all, since the explicit Checkout step is now itself gated by the filter's own output). This can produce incorrect deps filtering: on the initial run there is no checkout yet, so paths-filter falls back to comparing commit refs via the GitHub API only if a 'base'/'ref' is set, but no explicit base/head input is provided here, making the result depend on default behavior rather than the intended PR diff. Combined with the fact that the Checkout step is now conditioned on the filter's own output, if the filter step misbehaves (e.g., due to missing checkout context) the whole job silently skips the security scan for PRs that do touch dependency files, which is a correctness/security regression for a job whose entire purpose is dependency vulnerability scanning.
The flagged code:
```
      - name: Check if scan should run
        id: should_run
        uses: dorny/paths-filter@v4.0.2
        with:
          filters: |
            deps:
              - '**/pom.xml'
              - '.mvn/**'
              - '**/package.json'
              - '**/package-lock.json'
              - '**/yarn.lock'
              - '**/pnpm-lock.yaml'
              - '**/go.mod'
              - '**/go.sum'
              - '**/Cargo.toml'
              - '**/Cargo.lock'
              - '**/Dockerfile*'
              - '.trivyignore'
              - '.github/steps/trivy/**'
```
Make the minimal change that resolves the finding; do not refactor unrelated code.

confidence: 45 — react 👍/👎 to teach the reviewer

@yaroslavmokflmg yaroslavmokflmg changed the title ci: run code scan only when dependency manifests change ci: run code scan only when the scanned path changes Sep 28, 2026
@yaroslavmokflmg yaroslavmokflmg changed the title ci: run code scan only when the scanned path changes ci: run code scan only when dependency files change Sep 29, 2026

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant