-
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
Open
ausbru87
wants to merge
10
commits into
main
Choose a base branch
from
123-add-security-scanning
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+168
−0
Open
Changes from 7 commits
Commits
Show all changes
10 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 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
Some comments aren't visible on the classic Files Changed page.
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
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. |
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@v4 | ||
deansheather marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
with: | ||
persist-credentials: false | ||
|
||
- name: Run analysis | ||
uses: ossf/[email protected] | ||
with: | ||
results_file: results.sarif | ||
results_format: sarif | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_results: true | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: SARIF file | ||
path: results.sarif | ||
retention-days: 5 | ||
|
||
- name: Upload to code-scanning | ||
uses: github/codeql-action/upload-sarif@v3 | ||
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,113 @@ | ||
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@v4 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: "go.mod" | ||
|
||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v3 | ||
with: | ||
languages: go | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v3 | ||
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@v4 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: "go.mod" | ||
|
||
- name: Build binary for linux/amd64 | ||
run: | | ||
TAG=$(git describe --always) | ||
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 | ||
deansheather marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build Docker image | ||
id: build | ||
run: | | ||
docker buildx build \ | ||
--platform linux/amd64 \ | ||
--tag code-marketplace:scan \ | ||
--load \ | ||
--build-arg TARGETARCH=amd64 \ | ||
. | ||
deansheather marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
echo "image=code-marketplace:scan" >> "$GITHUB_OUTPUT" | ||
- name: Run Trivy vulnerability scanner (table output for logs) | ||
uses: aquasecurity/[email protected] | ||
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/[email protected] | ||
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@v3 | ||
with: | ||
sarif_file: "trivy-results.sarif" | ||
category: "Trivy" | ||
|
||
- name: Upload Trivy scan results as artifact | ||
uses: actions/upload-artifact@v4 | ||
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
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.
Not a huge deal, but I think the prefixes may have no use, the changelog is manually curated.