Skip to content

chore: applly image scan#25

Merged
muhammad-tahir-nawaz merged 1 commit into
mainfrom
ci/reapply-image-scan
Jun 16, 2026
Merged

chore: applly image scan#25
muhammad-tahir-nawaz merged 1 commit into
mainfrom
ci/reapply-image-scan

Conversation

@muhammad-tahir-nawaz

Copy link
Copy Markdown
Contributor

Summary

Why

QA Report

  • No QA report required

Integration Tests

  • No integration tests required

Added

Edited

Dependencies

@muhammad-tahir-nawaz muhammad-tahir-nawaz self-assigned this Jun 16, 2026
Copilot AI review requested due to automatic review settings June 16, 2026 03:37
@muhammad-tahir-nawaz muhammad-tahir-nawaz merged commit 9e4fd8e into main Jun 16, 2026
5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the GitHub Actions CI/CD workflows to incorporate Trivy image scanning into the deployment pipeline and to simplify the existing Trivy+Go test workflow.

Changes:

  • Removed PR-commenting steps (and elevated PR permissions) from the Trivy + Go tests workflow.
  • Updated the deployment workflow to build the Docker image locally, run a Trivy image scan, then push the image if the scan passes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/trivy-go-tests.yaml Removes PR comment/report steps and reduces permissions; keeps Trivy FS scan + Go unit test execution.
.github/workflows/deployment.yaml Splits build/push into build → Trivy image scan → push to enforce vulnerability gating before publish.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 66 to +70
ignore-unfixed: true
format: 'table'
output: 'trivy-results.txt'
severity: 'CRITICAL,HIGH,MEDIUM,LOW'
exit-code: '1'
exit-code: '1'
Comment on lines +148 to +157
- name: Run Trivy vulnerability scanner on image
if: ${{ inputs.deploy_type != 'release-only' }}
uses: aquasecurity/trivy-action@0.35.0
with:
scan-type: 'image'
image-ref: ${{ secrets.GCP_REGISTRY }}/${{ secrets.GCP_PROJECT }}/${{ inputs.image_path }}:latest
ignore-unfixed: true
format: 'table'
severity: 'CRITICAL,HIGH'
exit-code: '1'
@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown

Greptile Summary

This PR introduces a "scan before push" pattern in the deployment workflow and removes the PR-comment surfacing logic from the filesystem scan workflow. The deployment flow now builds the Docker image locally, runs Trivy against it, and only pushes to the GCP registry if no CRITICAL/HIGH vulnerabilities are found.

  • deployment.yaml: Build step switches to push: false + load: true, a Trivy image scan is inserted (CRITICAL/HIGH, exit-code: 1), and a plain docker push step follows — correctly gating registry writes behind the vulnerability check.
  • trivy-go-tests.yaml: PR comment steps and the pull-requests: write permission are removed; Go tests are simplified to a single go test -v invocation (fixing the previous double-execution). However, output: 'trivy-results.txt' was left in the Trivy step with no replacement mechanism to surface the file, making scan failures opaque to developers.

Confidence Score: 3/5

The deployment workflow is safe; the filesystem scan workflow leaves scan failures opaque.

The deployment workflow correctly implements scan-before-push. The filesystem scan workflow removes the mechanism that made Trivy results visible without removing the file redirect, so developers cannot see what triggered a scan failure.

.github/workflows/trivy-go-tests.yaml — the output: 'trivy-results.txt' line needs to be removed or paired with an artifact upload step.

Important Files Changed

Filename Overview
.github/workflows/deployment.yaml Splits build+push into three steps (build locally, Trivy image scan, then push) so CRITICAL/HIGH vulnerabilities block the push. Logic is sound — load: true makes the image available to Trivy in the local Docker daemon before it reaches the registry.
.github/workflows/trivy-go-tests.yaml Removes PR comment steps and simplifies Go test execution, but leaves output: 'trivy-results.txt' in place with no artifact upload — scan results become invisible when the job fails.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant GH as GitHub Actions
    participant Docker as Docker Daemon
    participant Trivy as Trivy Scanner
    participant Registry as GCP Registry

    Note over GH: deployment.yaml (new flow)
    GH->>Docker: "docker/build-push-action (push=false, load=true)"
    Docker-->>GH: Image loaded locally
    GH->>Trivy: Scan local image (CRITICAL,HIGH)
    alt Vulnerabilities found
        Trivy-->>GH: exit-code 1 → job fails
        Note over Registry: Image never pushed
    else Clean scan
        Trivy-->>GH: exit-code 0
        GH->>Registry: docker push :latest
    end

    Note over GH: trivy-go-tests.yaml (new flow)
    GH->>Trivy: Scan filesystem (output→trivy-results.txt)
    alt Vulnerabilities found
        Trivy-->>GH: exit-code 1 → job fails
        Note over GH: Results in file only — not visible
    else Clean scan
        Trivy-->>GH: exit-code 0
    end
    GH->>GH: go test -v (stdout visible in logs)
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant GH as GitHub Actions
    participant Docker as Docker Daemon
    participant Trivy as Trivy Scanner
    participant Registry as GCP Registry

    Note over GH: deployment.yaml (new flow)
    GH->>Docker: "docker/build-push-action (push=false, load=true)"
    Docker-->>GH: Image loaded locally
    GH->>Trivy: Scan local image (CRITICAL,HIGH)
    alt Vulnerabilities found
        Trivy-->>GH: exit-code 1 → job fails
        Note over Registry: Image never pushed
    else Clean scan
        Trivy-->>GH: exit-code 0
        GH->>Registry: docker push :latest
    end

    Note over GH: trivy-go-tests.yaml (new flow)
    GH->>Trivy: Scan filesystem (output→trivy-results.txt)
    alt Vulnerabilities found
        Trivy-->>GH: exit-code 1 → job fails
        Note over GH: Results in file only — not visible
    else Clean scan
        Trivy-->>GH: exit-code 0
    end
    GH->>GH: go test -v (stdout visible in logs)
Loading

Reviews (1): Last reviewed commit: "chore: applly image scan" | Re-trigger Greptile

Comment on lines 67 to 69
format: 'table'
output: 'trivy-results.txt'
severity: 'CRITICAL,HIGH,MEDIUM,LOW'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 The output: 'trivy-results.txt' parameter redirects Trivy results to a file instead of stdout. The PR comment step that previously surfaced this file was removed, and no artifact-upload step replaced it. When the scan fails with exit-code: '1', developers will see the job fail but have no way to see which vulnerabilities triggered it — the results file is silently discarded at the end of the runner. Either remove output (letting results print to the workflow log) or add an actions/upload-artifact step so the file is retrievable.

Suggested change
format: 'table'
output: 'trivy-results.txt'
severity: 'CRITICAL,HIGH,MEDIUM,LOW'
format: 'table'
severity: 'CRITICAL,HIGH,MEDIUM,LOW'

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.

2 participants