-
Notifications
You must be signed in to change notification settings - Fork 47
Add automated security scanning workflows #124
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
Merged
Merged
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9b0ab3a
ci: add security scanning workflows (#123)
ausbru87 351ea5c
ci: scan for all CVE severity levels and remove Docker image scan
ausbru87 980a039
ci: add explicit scanners to Trivy configuration
ausbru87 9f26520
ci: build and scan Docker image like coder/coder
ausbru87 9e22e3a
ci: add table output and artifact upload for scan visibility
ausbru87 9c091a9
ci: add workflow_dispatch trigger to scorecard for manual testing
ausbru87 d3b966a
revert: remove workflow_dispatch from scorecard
ausbru87 949cdba
removed changes from changelog.md
ausbru87 6b8d181
updated Make for multiple targets and updated security.yaml to use ma…
ausbru87 c3339da
added sha pinning
ausbru87 2a40050
Updated SHAs
ausbru87 4769896
added explicit build targets for each arch
ausbru87 ad4db42
added explicit make build command instead of alias to security workflow
ausbru87 0f66771
removed prefixes due to changelog.md being manually curated
ausbru87 4bac609
reduce potential of credential leak by removing credential persistence
ausbru87 f4bf9a8
address review comments: refactor Makefile and move dev docs to CONTR…
ausbru87 f43c4e8
rename mac -> darwin and quote $@ in build targets
ausbru87 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| name: OpenSSF Scorecard | ||
|
|
||
| on: | ||
| branch_protection_rule: | ||
| schedule: | ||
| # Run weekly on Wednesdays at 7:27 UTC | ||
| - cron: "27 7 * * 3" | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| permissions: read-all | ||
|
|
||
| jobs: | ||
| analysis: | ||
| name: Scorecard analysis | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| security-events: write | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Run analysis | ||
| uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3 | ||
| with: | ||
| results_file: results.sarif | ||
| results_format: sarif | ||
| repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
| publish_results: true | ||
|
|
||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | ||
| with: | ||
| name: SARIF file | ||
| path: results.sarif | ||
| retention-days: 5 | ||
|
|
||
| - name: Upload to code-scanning | ||
| uses: github/codeql-action/upload-sarif@755f44910c12a3d7ca0d8c6e42c048b3362f7cec # v3.30.8 | ||
| with: | ||
| sarif_file: results.sarif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| name: security | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| schedule: | ||
| # Run every day at 10:00 UTC (6:00 AM ET / 3:00 AM PT) | ||
| - cron: "0 10 * * *" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| # Cancel in-progress runs for pull requests when developers push | ||
| # additional changes | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| jobs: | ||
| codeql: | ||
| name: CodeQL Analysis | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| security-events: write | ||
| actions: read | ||
| contents: read | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 | ||
| with: | ||
| go-version-file: "go.mod" | ||
|
|
||
| - name: Initialize CodeQL | ||
| uses: github/codeql-action/init@755f44910c12a3d7ca0d8c6e42c048b3362f7cec # v3.30.8 | ||
| with: | ||
| languages: go | ||
|
|
||
| - name: Perform CodeQL Analysis | ||
| uses: github/codeql-action/analyze@755f44910c12a3d7ca0d8c6e42c048b3362f7cec # v3.30.8 | ||
| with: | ||
| category: "/language:go" | ||
|
|
||
| trivy: | ||
| name: Trivy Docker Image Scan | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| security-events: write | ||
| contents: read | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 | ||
| with: | ||
| go-version-file: "go.mod" | ||
|
|
||
| - name: Build binary for linux/amd64 | ||
| run: make bin/code-marketplace-linux-amd64 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 | ||
|
|
||
| - name: Build Docker image | ||
| id: build | ||
| run: | | ||
| docker buildx bake \ | ||
| -f ./docker-bake.hcl \ | ||
| --set "*.platform=linux/amd64" \ | ||
| --set "*.tags=code-marketplace:scan" \ | ||
| --load | ||
| echo "image=code-marketplace:scan" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Run Trivy vulnerability scanner (table output for logs) | ||
| uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # v0.33.1 | ||
| with: | ||
| image-ref: ${{ steps.build.outputs.image }} | ||
| format: "table" | ||
| severity: "LOW,MEDIUM,HIGH,CRITICAL" | ||
|
|
||
| - name: Run Trivy vulnerability scanner (SARIF output for GitHub) | ||
| uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # v0.33.1 | ||
| with: | ||
| image-ref: ${{ steps.build.outputs.image }} | ||
| format: "sarif" | ||
| output: "trivy-results.sarif" | ||
| severity: "LOW,MEDIUM,HIGH,CRITICAL" | ||
|
|
||
| - name: Upload Trivy scan results to GitHub Security tab | ||
| uses: github/codeql-action/upload-sarif@755f44910c12a3d7ca0d8c6e42c048b3362f7cec # v3.30.8 | ||
| with: | ||
| sarif_file: "trivy-results.sarif" | ||
| category: "Trivy" | ||
|
|
||
| - name: Upload Trivy scan results as artifact | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | ||
| with: | ||
| name: trivy-results | ||
| path: trivy-results.sarif | ||
| retention-days: 7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -26,12 +26,34 @@ upload: | |||||
| .PHONY: gen | ||||||
|
|
||||||
| TAG=$(shell git describe --always) | ||||||
| GO_SRC=$(shell find . -name '*.go' -type f) | ||||||
| LDFLAGS=-ldflags "-X github.com/coder/code-marketplace/buildinfo.tag=$(TAG)" | ||||||
| $(shell mkdir -p bin) | ||||||
|
|
||||||
| build: | ||||||
| CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-X github.com/coder/code-marketplace/buildinfo.tag=$(TAG)" -o bin/code-marketplace-mac-amd64 ./cmd/marketplace/main.go | ||||||
| CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "-X github.com/coder/code-marketplace/buildinfo.tag=$(TAG)" -o bin/code-marketplace-mac-arm64 ./cmd/marketplace/main.go | ||||||
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-X github.com/coder/code-marketplace/buildinfo.tag=$(TAG)" -o bin/code-marketplace-linux-amd64 ./cmd/marketplace/main.go | ||||||
| CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-X github.com/coder/code-marketplace/buildinfo.tag=$(TAG)" -o bin/code-marketplace-linux-arm64 ./cmd/marketplace/main.go | ||||||
| CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-X github.com/coder/code-marketplace/buildinfo.tag=$(TAG)" -o bin/code-marketplace-windows-amd64 ./cmd/marketplace/main.go | ||||||
| CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -ldflags "-X github.com/coder/code-marketplace/buildinfo.tag=$(TAG)" -o bin/code-marketplace-windows-arm64 ./cmd/marketplace/main.go | ||||||
| # Individual build targets for each OS/arch combination | ||||||
| bin/code-marketplace-mac-amd64: $(GO_SRC) go.mod go.sum | ||||||
| CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o $@ ./cmd/marketplace/main.go | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
On all of them :(
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added |
||||||
|
|
||||||
| bin/code-marketplace-mac-arm64: $(GO_SRC) go.mod go.sum | ||||||
| CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o $@ ./cmd/marketplace/main.go | ||||||
|
|
||||||
| bin/code-marketplace-linux-amd64: $(GO_SRC) go.mod go.sum | ||||||
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o $@ ./cmd/marketplace/main.go | ||||||
|
|
||||||
| bin/code-marketplace-linux-arm64: $(GO_SRC) go.mod go.sum | ||||||
| CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o $@ ./cmd/marketplace/main.go | ||||||
|
|
||||||
| bin/code-marketplace-windows-amd64: $(GO_SRC) go.mod go.sum | ||||||
| CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o $@ ./cmd/marketplace/main.go | ||||||
|
|
||||||
| bin/code-marketplace-windows-arm64: $(GO_SRC) go.mod go.sum | ||||||
| CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build $(LDFLAGS) -o $@ ./cmd/marketplace/main.go | ||||||
|
|
||||||
| # Main build target - builds all platforms | ||||||
| build: bin/code-marketplace-mac-amd64 \ | ||||||
| bin/code-marketplace-mac-arm64 \ | ||||||
| bin/code-marketplace-linux-amd64 \ | ||||||
| bin/code-marketplace-linux-arm64 \ | ||||||
| bin/code-marketplace-windows-amd64 \ | ||||||
| bin/code-marketplace-windows-arm64 | ||||||
| .PHONY: build | ||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
mactargets should be calleddarwinThere 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.
Make sure you update your contributing.md section too
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.
swapped all mentions of
mac->darwin