Skip to content

Commit

Permalink
Merge pull request #35 from sarg3nt/fix-trivy-db-download-failure
Browse files Browse the repository at this point in the history
Pass github token via build step env ar.
  • Loading branch information
sarg3nt authored Oct 30, 2024
2 parents 32aed5f + fb0d562 commit cba70d8
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 44 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7
with:
egress-policy: audit

- name: 'Checkout Repository'
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: 'Dependency Review'
uses: actions/dependency-review-action@4081bf99e2866ebe428fc0477b69eb4fcda7220a # v4.4.0
uses: actions/dependency-review-action@4081bf99e2866ebe428fc0477b69eb4fcda7220a
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Periodic Release
name: Weekly Release Build and Push

on:
schedule:
Expand All @@ -18,18 +18,24 @@ env:
permissions: read-all

jobs:
release:
release-build-and-push:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7
with:
egress-policy: audit

- name: 'Checkout Repository'
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
fetch-tags: true

# Must generate the tag version manually becuase scheduled workflows do not have access to ref: refs/tags/v1.0.0
- name: Get the latest tag version
id: get_version
run: |
Expand Down Expand Up @@ -77,11 +83,7 @@ jobs:
prerelease: false
tag: ${{ env.VERSION }}

- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit


- name: Log into registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
Expand All @@ -92,6 +94,7 @@ jobs:
- name: Build and push Docker image
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
with:
build-args: GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
push: true
tags: ${{ env.TAG_MAJOR }},${{ env.TAG_MINOR }},${{ env.TAG_PATCH }},${{ env.TAG_LATEST }}
tags: ${{ env.TAG_MAJOR }},${{ env.TAG_MINOR }},${{ env.TAG_PATCH }},${{ env.TAG_LATEST }}
env:
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65 changes: 56 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release
name: Release Build and Push

on:
push:
Expand All @@ -12,34 +12,79 @@ permissions:
contents: read

jobs:
release-docker-image:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7
with:
egress-policy: audit
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
auth.docker.io:443
cdn.dl.k8s.io:443
codecs.fedoraproject.org:443
distro.ibiblio.org:80
dl.google.com:443
dl.k8s.io:443
download.docker.com:443
epel.mirror.shastacoe.net:443
ftp-nyc.osuosl.org:443
ftp.agdsn.de:80
ftp.fau.de:80
ftp.halifax.rwth-aachen.de:443
ftp.plusline.net:443
get.helm.sh:443
ghcr.io:443
github.com:443
gitlab.com:443
mirror.chpc.utah.edu:80
mirror.informatik.hs-fulda.de:443
mirror.rnet.missouri.edu:80
mirror.siena.edu:80
mirror1.hs-esslingen.de:443
mirrors.fedoraproject.org:443
mirrors.rit.edu:80
mirrors.rockylinux.org:443
mirrors.xtom.de:80
mise-versions.jdx.dev:80
mise.jdx.dev:80
objects.githubusercontent.com:443
ohioix.mm.fcix.net:80
pkg-containers.githubusercontent.com:443
production.cloudflare.docker.com:443
proxy.golang.org:443
raw.githubusercontent.com:443
registry-1.docker.io:443
repo.ialab.dsu.edu:80
rocky-linux-europe-west3.production.gcp.mirrors.ctrliq.cloud:443
rocky.mirror.shastacoe.net:443
sftp.hpc.fau.edu:443
sum.golang.org:443
us.mirrors.cicku.me:443
volico.mm.fcix.net:80
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
fetch-tags: true

- name: Log into registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
Expand All @@ -48,9 +93,11 @@ jobs:
type=semver,pattern={{major}}
- name: Build and push Docker image
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
env:
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 5 additions & 5 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7
with:
egress-policy: audit

- name: "Checkout code"
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46
with:
results_file: results.sarif
results_format: sarif
Expand All @@ -64,7 +64,7 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v3.pre.node20
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
with:
name: SARIF file
path: results.sarif
Expand All @@ -73,6 +73,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard (optional).
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd
with:
sarif_file: results.sarif
27 changes: 14 additions & 13 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# separate terms of service, privacy policy, and support
# documentation.

name: trivy
name: Trivy

on:
push:
Expand All @@ -22,35 +22,36 @@ permissions:
contents: read

jobs:
build:
trivy-scan:
permissions:
contents: write # for actions/checkout to fetch code and for SBOM to push results
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
name: Build
runs-on: "ubuntu-20.04"
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7
with:
egress-policy: audit

- name: Log into registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit

- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: Build Docker image
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75
with:
build-args: GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
push: false
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
env:
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2
Expand All @@ -65,7 +66,7 @@ jobs:
ENV TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd
with:
sarif_file: 'trivy-results.sarif'

Expand All @@ -88,4 +89,4 @@ jobs:
with:
name: trivy-sbom-report
path: '${{ github.workspace }}/dependency-results.sbom.json'
retention-days: 20 # 90 is the default
retention-days: 30 # 90 is the default
4 changes: 0 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ LABEL org.opencontainers.image.source=https://github.com/sarg3nt/go-dev-containe

ENV TZ='America/Los_Angeles'

# Token for talking to the Github API for mise and our custom installs.
ARG GITHUB_TOKEN=""
ENV GITHUB_API_TOKEN=$GITHUB_TOKEN

# What user will be created in the dev container and will we run under.
# Reccomend not changing this.
ENV USERNAME="vscode"
Expand Down
6 changes: 6 additions & 0 deletions scripts/30_install_mise_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ main() {
log "Configuring mise" "green"
export PATH="$HOME/.local/share/mise/shims:$HOME/.local/bin/:$PATH"

if [[ -n "${GITHUB_API_TOKEN:-}" ]]; then
log "GITHUB_API_TOKEN found" "green"
else
log "GITHUB_API_TOKEN not found" "yellow"
fi

log "Mise version" "green"
mise version

Expand Down

0 comments on commit cba70d8

Please sign in to comment.