-
Notifications
You must be signed in to change notification settings - Fork 31
Harden github action #1766
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
Harden github action #1766
Changes from all commits
c3ee932
5ce909b
99bd230
f8a2779
d994e7b
ee2f5bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,24 +6,20 @@ on: | |
| workflow_dispatch: | ||
| push: | ||
|
|
||
| permissions: | ||
| contents: write | ||
| actions: read | ||
| security-events: write | ||
| packages: write | ||
|
|
||
|
|
||
| jobs: | ||
| golangci: | ||
| name: lint | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 - https://github.com/actions/checkout/releases/tag/v5.0.0 | ||
| with: | ||
| submodules: recursive | ||
| persist-credentials: false | ||
| - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 - https://github.com/actions/setup-go/releases/tag/v5.5.0 | ||
| with: | ||
| go-version: '1.25.5' | ||
| go-version: '1.25.6' | ||
| cache: false | ||
| - name: golangci-lint | ||
| uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0 - https://github.com/golangci/golangci-lint-action/releases/tag/v8.0.0 | ||
|
|
@@ -34,16 +30,18 @@ jobs: | |
| tests: | ||
| name: tests | ||
| runs-on: ubuntu-latest | ||
|
|
||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Check out code | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 - https://github.com/actions/checkout/releases/tag/v5.0.0 | ||
| with: | ||
| submodules: recursive | ||
| persist-credentials: false | ||
| - name: Set up Go | ||
| uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 - https://github.com/actions/setup-go/releases/tag/v5.5.0 | ||
| with: | ||
| go-version: '1.25.5' | ||
| go-version: '1.25.6' | ||
|
|
||
| - name: Run unittests | ||
| run: go test $(go list ./... | grep -v "/mocks") -coverprofile=coverage.out && go tool cover -func=coverage.out | ||
|
|
@@ -56,6 +54,11 @@ jobs: | |
|
|
||
| devguard: | ||
| uses: l3montree-dev/devguard-action/.github/workflows/full.yml@main | ||
| permissions: | ||
| contents: write | ||
| actions: read | ||
| security-events: write | ||
| packages: write | ||
| with: | ||
| asset-name: l3montree-cybersecurity/projects/devguard/assets/devguard | ||
| api-url: https://api.main.devguard.org | ||
|
|
@@ -70,6 +73,9 @@ jobs: | |
|
|
||
| build-scanner-image: | ||
| uses: l3montree-dev/devguard-action/.github/workflows/build-image.yml@main | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| with: | ||
| artifact-name: "pkg:oci/scanner?repository_url=ghcr.io/l3montree-dev/devguard/scanner" | ||
| asset-name: l3montree-cybersecurity/projects/devguard/assets/devguard | ||
|
|
@@ -83,6 +89,9 @@ jobs: | |
| # Image scanning job to detect vulnerabilities in the built Docker image | ||
| scanner-container-scanning: | ||
| uses: l3montree-dev/devguard-action/.github/workflows/container-scanning.yml@main | ||
| permissions: | ||
| contents: read | ||
| security-events: write | ||
| needs: | ||
| - build-scanner-image | ||
| with: | ||
|
|
@@ -97,11 +106,14 @@ jobs: | |
| devguard-token: ${{ secrets.DEVGUARD_TOKEN }} | ||
|
|
||
| deploy-scanner: | ||
| needs: | ||
| needs: | ||
| - build-scanner-image | ||
| - scanner-container-scanning | ||
| - tests | ||
| uses: l3montree-dev/devguard-action/.github/workflows/deploy.yml@main | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| with: | ||
| asset-name: l3montree-cybersecurity/projects/devguard/assets/devguard | ||
| api-url: https://api.main.devguard.org | ||
|
|
@@ -110,11 +122,14 @@ jobs: | |
| devguard-token: ${{ secrets.DEVGUARD_TOKEN }} | ||
|
|
||
| sign-scanner: | ||
| needs: | ||
| needs: | ||
| - build-scanner-image | ||
| - scanner-container-scanning | ||
| - tests | ||
| uses: l3montree-dev/devguard-action/.github/workflows/sign.yml@main | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| with: | ||
| asset-name: l3montree-cybersecurity/projects/devguard/assets/devguard | ||
| api-url: https://api.main.devguard.org | ||
|
|
@@ -124,11 +139,14 @@ jobs: | |
| devguard-token: ${{ secrets.DEVGUARD_TOKEN }} | ||
|
|
||
| attest-scanner: | ||
| needs: | ||
| needs: | ||
| - build-scanner-image | ||
| - scanner-container-scanning | ||
| - tests | ||
| uses: l3montree-dev/devguard-action/.github/workflows/attest.yml@main | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| with: | ||
| asset-name: l3montree-cybersecurity/projects/devguard/assets/devguard | ||
| api-url: https://api.main.devguard.org | ||
|
|
@@ -140,6 +158,8 @@ jobs: | |
| release: | ||
| name: Build and Release Binaries | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| # needs: [golangci, tests, sign-scanner, devguard] | ||
| if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/test-release' | ||
| outputs: | ||
|
|
@@ -149,16 +169,18 @@ jobs: | |
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.25' | ||
| go-version: '1.25.6' | ||
| cache: false | ||
|
|
||
| - name: Get tag | ||
| id: tag | ||
| run: | | ||
| if [[ "${{ github.ref }}" == refs/tags/* ]]; then | ||
| if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | ||
| echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | ||
| echo "TAG_NO_V=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV | ||
| else | ||
|
|
@@ -170,7 +192,7 @@ jobs: | |
| mkdir -p dist | ||
|
|
||
| # Build flags for security-hardened binaries | ||
| BUILD_FLAGS="-s -w -buildid= -X main.version=${{ steps.tag.outputs.tag }} -X main.commit=${{ github.sha }} -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ) -X main.builtBy=github-actions" | ||
| BUILD_FLAGS="-s -w -buildid= -X main.version=${STEPS_TAG_OUTPUTS_TAG} -X main.commit=${{ github.sha }} -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ) -X main.builtBy=github-actions" | ||
|
Comment on lines
183
to
+195
|
||
|
|
||
| # Build for Linux amd64 | ||
| GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="$BUILD_FLAGS" -o dist/devguard-scanner-linux-amd64 ./cmd/devguard-scanner | ||
|
|
@@ -189,6 +211,8 @@ jobs: | |
|
|
||
| # Build for macOS arm64 | ||
| GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="$BUILD_FLAGS" -o dist/devguard-scanner-darwin-arm64 ./cmd/devguard-scanner | ||
| env: | ||
| STEPS_TAG_OUTPUTS_TAG: ${{ steps.tag.outputs.tag }} | ||
|
|
||
| - name: Create archives | ||
| run: | | ||
|
|
@@ -231,7 +255,7 @@ jobs: | |
| " | ||
|
|
||
| - name: Create GitHub Release | ||
| uses: softprops/action-gh-release@v1 | ||
| uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1 | ||
| with: | ||
| tag_name: ${{ steps.tag.outputs.tag }} | ||
| name: "DevGuard Scanner ${{ steps.tag.outputs.tag }}" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the
releasejob,actions/checkout@v4andactions/setup-go@v5are referenced by mutable tags while the earlier jobs pin these actions by commit SHA. For a hardened workflow, pin these actions to specific commit SHAs (and keep the version comment) to reduce supply-chain risk.