-
Notifications
You must be signed in to change notification settings - Fork 36
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
base: main
Are you sure you want to change the base?
Changes from all commits
9b0ab3a
351ea5c
980a039
9f26520
9e22e3a
9c091a9
d3b966a
949cdba
6b8d181
c3339da
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 |
---|---|---|
|
@@ -7,6 +7,8 @@ updates: | |
time: "06:00" | ||
timezone: "America/Chicago" | ||
labels: [] | ||
commit-message: | ||
prefix: "ci" | ||
groups: | ||
github-actions: | ||
patterns: | ||
|
@@ -19,8 +21,15 @@ updates: | |
time: "06:00" | ||
timezone: "America/Chicago" | ||
labels: [] | ||
commit-message: | ||
prefix: "chore" | ||
Comment on lines
+24
to
+25
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. ditto |
||
open-pull-requests-limit: 15 | ||
groups: | ||
x: | ||
patterns: | ||
- "golang.org/x/*" | ||
ignore: | ||
# Ignore patch updates for all dependencies to reduce PR noise | ||
- dependency-name: "*" | ||
update-types: | ||
- version-update:semver-patch | ||
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. Do we need this? So far the number of updates seem to have been pretty mild. Or we could group updates weekly or something. |
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@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 | ||
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. actions/checkout is currently at |
||
with: | ||
persist-credentials: false | ||
|
||
- name: Run analysis | ||
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0 | ||
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. ossf/scorecard-action is currently at |
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
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@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 | ||
|
||
- 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@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 | ||
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. Same here |
||
|
||
- 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 build/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@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # 0.28.0 | ||
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. aquasecurity/trivy-action is currently at |
||
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@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # 0.28.0 | ||
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. Same here |
||
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 |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -27,6 +27,11 @@ upload: | |||||
|
||||||
TAG=$(shell git describe --always) | ||||||
|
||||||
build/linux/amd64: | ||||||
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
You can keep the PHONY (after editing the target name) for simplicity's sake though, otherwise you'll need to specify every Go-related file as a dependency 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. I think every OS/arch should be turned into a target just like this, and the |
||||||
mkdir -p bin | ||||||
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 | ||||||
.PHONY: build/linux/amd64 | ||||||
|
||||||
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 | ||||||
|
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.
Not a huge deal, but I think the prefixes may have no use, the changelog is manually curated.