Skip to content
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

Add OpenSSF scorecard workflow #71

Merged
merged 2 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/ci-build-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,27 @@ on:
branches:
- main

permissions:
contents: read

jobs:
build:
runs-on: windows-latest

steps:
- name: Harden Runner
uses: step-security/harden-runner@248ae51c2e8cc9622ecf50685c8bf7150c6e8813
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Set up git env
run: |
git config --global core.autocrlf false
$gopath = (go env GOPATH)
echo "GOPATH=$gopath" >> $env:GITHUB_ENV

- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@d0651293c4a5a52e711f25b41b05b2212f385d28

- name: Format
run: |
Expand All @@ -46,7 +54,7 @@ jobs:
run: |
go test -tags WINDOWS ./...

- uses: dominikh/staticcheck-action@v1.1.0
- uses: dominikh/staticcheck-action@4ec9a0dff54be2642bc76581598ba433fd8d4967
with:
version: "2021.1.2"
install-go: false
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,28 @@ on:
branches:
- main

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
container:
image: golang:1.16.10-alpine3.14

steps:
- name: Harden Runner
uses: step-security/harden-runner@248ae51c2e8cc9622ecf50685c8bf7150c6e8813
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Set up environment
run : |
apk update
apk add gcc libc-dev bash perl curl make

- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@d0651293c4a5a52e711f25b41b05b2212f385d28

- name: Format
run: |
Expand All @@ -38,7 +46,7 @@ jobs:
run: |
go test ./...

- uses: dominikh/staticcheck-action@v1.1.0
- uses: dominikh/staticcheck-action@4ec9a0dff54be2642bc76581598ba433fd8d4967
with:
version: "2021.1.2"
install-go: false
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@ jobs:
language: [ 'go' ]

steps:
- name: Harden Runner
uses: step-security/harden-runner@248ae51c2e8cc9622ecf50685c8bf7150c6e8813
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@d0651293c4a5a52e711f25b41b05b2212f385d28

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@efa51083fa7b87d9a6681705d27d30e0a699388b
with:
languages: ${{ matrix.language }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@efa51083fa7b87d9a6681705d27d30e0a699388b
70 changes: 70 additions & 0 deletions .github/workflows/scorecards-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright Contributors to the L3AF Project.
# SPDX-License-Identifier: Apache-2.0
#
# For documentation on the github environment, see
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
#
# For documentation on the syntax of this file, see
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions

name: Scorecards

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

concurrency:
# Cancel any Scorecards workflow currently in progress for the same PR.
# Allow running concurrently with any other commits.
group: scorecards-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

# Declare default permissions as read only.
permissions: read-all

jobs:
analysis:
name: Scorecards analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
actions: read
contents: read

steps:
- name: "Checkout code"
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@b614d455ee90608b5e36e3299cd50d457eb37d5f # Don't update this until they fix PR support
with:
results_file: results.sarif
results_format: sarif
# Read-only PAT token. To create it,
# follow the steps in https://github.com/ossf/scorecard-action#pat-token-creation.
repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
# Publish the results to enable scorecard badges. For more details, see
# https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories, `publish_results` will automatically be set to `false`,
# regardless of the value entered here.
publish_results: ${{ github.event_name != 'pull_request' }}

# Upload the results as artifacts (optional).
- name: "Upload artifact"
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard so it will be visible
# at https://github.com/l3af-project/l3afd/security/code-scanning.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@27ea8f8fe5977c00f5b37e076ab846c5bd783b96
with:
sarif_file: results.sarif