Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: embed docker scanning into argus builder action [OUTDATED] #284

Closed
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
91bd171
feat: break argus-docker-build workflow into composite actions
hspitzley-czi Jul 11, 2024
170834f
use composite actions in reusable workflow
hspitzley-czi Jul 11, 2024
e2f15bc
add checkouts
hspitzley-czi Jul 11, 2024
57305fb
pin composite actions
hspitzley-czi Jul 11, 2024
1fa107d
image uri and working directory support
hspitzley-czi Jul 11, 2024
a8184bb
move image scan to build stage
hspitzley-czi Jul 11, 2024
74c9379
remove unused arg
hspitzley-czi Jul 11, 2024
2d7cf50
pin 74c93798c163c312f0e0fcb813c04924ea2e215d
hspitzley-czi Jul 11, 2024
b7d8eaf
fix path join
hspitzley-czi Jul 11, 2024
6fe6c2d
upgrade workflow
hspitzley-czi Jul 11, 2024
74403de
Merge branch 'main' into CCIE-3097-make-argus-docker-builder-gh-actio…
hspitzley-czi Jul 12, 2024
c4f14a1
feat: embed docker scanning into argus builder action
hspitzley-czi Jul 12, 2024
1452f01
add output for whether vulnerability threshold was exceeded
hspitzley-czi Jul 12, 2024
c68491c
output results
hspitzley-czi Jul 12, 2024
6498306
add container scan step to argus docker build action
hspitzley-czi Jul 12, 2024
9dda02a
use composite action with vulnerability scanning
hspitzley-czi Jul 12, 2024
393c85f
try managed arm runner
hspitzley-czi Jul 12, 2024
7800407
Revert "try managed arm runner"
hspitzley-czi Jul 12, 2024
d5f287c
bump container scan inspector dep
hspitzley-czi Jul 12, 2024
64b3208
change image_uri format
hspitzley-czi Jul 12, 2024
6c88980
use new version in workflow
hspitzley-czi Jul 12, 2024
2e76635
back to image_uri
hspitzley-czi Jul 12, 2024
ba91051
workflow - back to image_uri
hspitzley-czi Jul 12, 2024
4d5a6e7
try docker login
hspitzley-czi Jul 15, 2024
11f4ade
workflow with docker login
hspitzley-czi Jul 15, 2024
747a0ff
Merge branch 'main' into CCIE-3099-embed-docker-scanning-into-argus-b…
hspitzley-czi Jul 17, 2024
f968444
docker login without explicit creds
hspitzley-czi Jul 17, 2024
186117b
workflow - docker login without explicit creds
hspitzley-czi Jul 17, 2024
8461a2c
try local image with load: true
hspitzley-czi Jul 18, 2024
300a5a1
try 8461a2ca27a313af1984f32f6d6b9df3b80607c8 - local image with load:…
hspitzley-czi Jul 18, 2024
09df741
move 'load: true'
hspitzley-czi Jul 18, 2024
e0d6da6
docker-build - use version with 'load: true'
hspitzley-czi Jul 18, 2024
ce3d9de
workflow - use version with 'load: true'
hspitzley-czi Jul 18, 2024
1c4976a
push false
hspitzley-czi Jul 18, 2024
b4b6079
docker-build - push false
hspitzley-czi Jul 18, 2024
e0cd558
workflow - push false
hspitzley-czi Jul 18, 2024
557c7b9
no qemu
hspitzley-czi Jul 18, 2024
daba8ef
docker-build - no qemu
hspitzley-czi Jul 18, 2024
c387835
workflow - no qemu
hspitzley-czi Jul 18, 2024
bb9bb68
remove buildx setup
hspitzley-czi Jul 18, 2024
9f972cd
Update .github/actions/argus-builder/docker-build/action.yml
hspitzley-czi Feb 3, 2025
bf5acfe
new runner tags
hspitzley-czi Feb 3, 2025
d5402bc
re-add buildx
hspitzley-czi Feb 3, 2025
dcd8089
use ARM64-dev runners
hspitzley-czi Feb 3, 2025
6229e8c
fix image uri
hspitzley-czi Feb 3, 2025
3f0d80b
debug logs
hspitzley-czi Feb 3, 2025
9d51866
add 'issues: write' permission
hspitzley-czi Feb 3, 2025
c2b5a8e
change to 'pull-requests: read' perm
hspitzley-czi Feb 4, 2025
341750b
add back 'issues: write'
hspitzley-czi Feb 4, 2025
a76e7db
pull-requests: write
hspitzley-czi Feb 4, 2025
c51705f
fix vuln report url
hspitzley-czi Feb 4, 2025
ff64f01
remove logs
hspitzley-czi Feb 4, 2025
12cea78
better comment
hspitzley-czi Feb 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig helps developers define and maintain consistent coding styles across different editors and IDEs

# Top-most EditorConfig file
root = true

# Set defaults for all file extensions
[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

# Set specific yaml file settings
[*.{yml,yaml}]
indent_style = space
indent_size = 2
53 changes: 45 additions & 8 deletions .github/actions/argus-builder/docker-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ inputs:
github_private_key:
description: 'GitHub App private key'
required: true
fail_on_vulnerabilities:
description: 'whether to fail the action if vulnerabilities are found'
required: false
default: "true"

outputs:
image_uri:
Expand Down Expand Up @@ -77,7 +81,7 @@ runs:
lifecycle-policy: core-platform-settings/ecr/lifecycle-policy.json
repository-policy: core-platform-settings/ecr/repository-policy.json
- name: Build And Push
uses: chanzuckerberg/github-actions/.github/actions/docker-build-push@docker-build-push-v1.6.0
uses: chanzuckerberg/github-actions/.github/actions/docker-build-push@CCIE-3099-embed-docker-scanning-into-argus-builder-gh-actions
with:
dockerfile: ${{ github.event.repository.name }}/${{ inputs.dockerfile }}
context: ${{ github.event.repository.name }}/${{ inputs.context }}
Expand All @@ -89,10 +93,43 @@ runs:
IMAGE_TAG=${{ inputs.image_tag }}
${{ inputs.build_args }}

# TODO: scan image for vulnerabilities
# - name: Scan for vulnerabilities
# uses: chanzuckerberg/github-actions/.github/actions/argus-builder/scan-for-vulnerabilities@main
# with:
# image_uri: ${{ steps.ecr_metadata.outputs.ECR_REGISTRY }}/${{ steps.ecr_metadata.outputs.ECR_REPO_NAME }}:${{ inputs.image_tag }}
# github_app_id: ${{ inputs.github_app_id }}
# github_private_key: ${{ inputs.github_private_key }}
- name: Scan for vulnerabilities
uses: chanzuckerberg/github-actions/.github/actions/container-scanning@CCIE-3099-embed-docker-scanning-into-argus-builder-gh-actions
id: scan
with:
image_uri: ${{ inputs.image_name }}:${{ inputs.image_tag }}
fail_on_vulnerabilities: ${{ inputs.fail_on_vulnerabilities }}

- name: Notify on skipped vulnerabilities
uses: actions/github-script@v7
if: inputs.fail_on_vulnerabilities != 'true' && steps.scan.outputs.vulnerability_threshold_exceeded == 1
with:
script: |
let issueNumber;
if (context.issue.number) {
// use issue number from context if present
issueNumber = context.issue.number;
} else {
// Otherwise use issue number from commit
issueNumber = (
await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
})
).data[0].number;
}
const body = `
:rotating_light: **Vulnerabilities found in image**: ${{ steps.ecr_metadata.outputs.IMAGE_URI }} :rotating_light:

Please review the vulnerabilities found in the image and take appropriate action:
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ github.job }}

${{ steps.scan.outputs.inspector_scan_results_markdown }}
`;
await github.rest.issues.createComment({
issue_number: issueNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body,
});
11 changes: 9 additions & 2 deletions .github/actions/container-scanning/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ inputs:
description: 'whether to fail the action if vulnerabilities are found'
required: false
default: "true"
outputs:
vulnerability_threshold_exceeded:
description: '1 if the vulnerability threshold was exceeded, 0 otherwise'
value: ${{ steps.inspector.outputs.vulnerability_threshold_exceeded }}
inspector_scan_results_markdown:
description: 'path to the markdown file containing the Inspector scan results'
value: ${{ steps.inspector.outputs.inspector_scan_results_markdown }}
runs:
using: "composite"
steps:
Expand All @@ -38,7 +45,7 @@ runs:
role-duration-seconds: 1800
role-session-name: github-actions-inspector
- name: Scan built image with Inspector
uses: aws-actions/[email protected].0
uses: aws-actions/[email protected].2
id: inspector
with:
artifact_type: 'container'
Expand All @@ -55,4 +62,4 @@ runs:
- name: Fail job if vulnerability threshold is exceeded
if: contains(inputs.fail_on_vulnerabilities, 'true')
shell: bash
run: exit ${{ steps.inspector.outputs.vulnerability_threshold_exceeded }}
run: exit ${{ steps.inspector.outputs.vulnerability_threshold_exceeded }}
11 changes: 6 additions & 5 deletions .github/actions/docker-build-push/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ outputs:
runs:
using: "composite"
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
Expand Down Expand Up @@ -80,7 +80,7 @@ runs:
with:
file: ${{ inputs.dockerfile }}
context: ${{ inputs.context }}
push: true
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: ${{ steps.cache-from.outputs.cacheFrom }}
Expand All @@ -89,3 +89,4 @@ runs:
build-args: ${{ inputs.build_args }}
secret-files: ${{ inputs.secret-files }}
platforms: ${{ inputs.platforms }}
load: true
14 changes: 10 additions & 4 deletions .github/workflows/argus-docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
required: false
type: string
default: '.'
fail_on_vulnerabilities:
description: 'whether to fail the action if vulnerabilities are found'
required: false
type: boolean
default: true

jobs:
prep:
Expand All @@ -53,7 +58,7 @@
id-token: write
contents: read
steps:
- uses: chanzuckerberg/github-actions/.github/actions/argus-builder/build-prep@b7d8eaf3c08d100ded457432f9ce6be6d88932e3
- uses: chanzuckerberg/github-actions/.github/actions/argus-builder/build-prep@CCIE-3099-embed-docker-scanning-into-argus-builder-gh-actions

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Docker Image Build' step
Uses Step: build_prep
uses 'chanzuckerberg/github-actions/.github/actions/argus-builder/build-prep' with ref 'CCIE-3099-embed-docker-scanning-into-argus-builder-gh-actions', not a pinned commit hash
id: build_prep
with:
path_filters: ${{ inputs.path_filters }}
Expand All @@ -76,7 +81,7 @@
build-docker:
name: Build Docker Image
needs: [prep]
runs-on:
runs-on:
- self-hosted
- Linux
- ${{ matrix.image.platform == 'linux/amd64' && 'X64' || 'ARM64' }}
Expand All @@ -89,7 +94,7 @@
matrix:
image: ${{ fromJson(needs.prep.outputs.images) }}
steps:
- uses: chanzuckerberg/github-actions/.github/actions/argus-builder/docker-build@b7d8eaf3c08d100ded457432f9ce6be6d88932e3
- uses: chanzuckerberg/github-actions/.github/actions/argus-builder/docker-build@CCIE-3099-embed-docker-scanning-into-argus-builder-gh-actions

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Docker Image Build' step
Uses Step
uses 'chanzuckerberg/github-actions/.github/actions/argus-builder/docker-build' with ref 'CCIE-3099-embed-docker-scanning-into-argus-builder-gh-actions', not a pinned commit hash
with:
image_name: ${{ matrix.image.name }}
dockerfile: ${{ matrix.image.dockerfile }}
Expand All @@ -99,6 +104,7 @@
image_tag: ${{ needs.prep.outputs.image_tag }}
github_app_id: ${{ secrets.CZI_GITHUB_HELPER_APP_ID }}
github_private_key: ${{ secrets.CZI_GITHUB_HELPER_PK }}
fail_on_vulnerabilities: ${{ inputs.fail_on_vulnerabilities }}

update-manifests:
name: Update ArgoCD manifests
Expand All @@ -108,7 +114,7 @@
id-token: write
contents: read
steps:
- uses: chanzuckerberg/github-actions/.github/actions/argus-builder/manifest-update@b7d8eaf3c08d100ded457432f9ce6be6d88932e3
- uses: chanzuckerberg/github-actions/.github/actions/argus-builder/manifest-update@CCIE-3099-embed-docker-scanning-into-argus-builder-gh-actions

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Docker Image Build' step
Uses Step
uses 'chanzuckerberg/github-actions/.github/actions/argus-builder/manifest-update' with ref 'CCIE-3099-embed-docker-scanning-into-argus-builder-gh-actions', not a pinned commit hash
with:
envs: ${{ inputs.envs }}
image_tag: ${{ needs.prep.outputs.image_tag }}
Expand Down