Skip to content

Commit

Permalink
Merge branch 'main' into add-sarif-reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
kehoecj authored Aug 3, 2024
2 parents 9051e74 + e601c40 commit bb9ca38
Show file tree
Hide file tree
Showing 66 changed files with 978 additions and 317 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# recommended by https://github.com/golangci/golangci-lint-action
# this will force line ending to be lf on windows
*.go text eol=lf
47 changes: 35 additions & 12 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,24 @@ on:
- main
pull_request:

permissions:
contents: read

jobs:
download:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Harden Runner
uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
with:
egress-policy: audit

- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: '1.21'
go-version: '1.22'

- name: Download dependencies
run: go mod download
Expand All @@ -29,12 +37,17 @@ jobs:
needs: download
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Harden Runner
uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
with:
egress-policy: audit

- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: '1.21'
go-version: '1.22'

- name: Static Analysis
run: go vet ./...
Expand All @@ -46,12 +59,17 @@ jobs:
needs: download
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Harden Runner
uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
with:
egress-policy: audit

- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: '1.21'
go-version: '1.22'

- name: Build
run: |
Expand All @@ -65,14 +83,19 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Harden Runner
uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
with:
egress-policy: audit

- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: '1.21'
go-version: '1.22'

- name: Unit test
run: go test -v -cover -coverprofile coverage.out ./...
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: golangci-lint
on:
push:
branches:
- master
- main
pull_request:

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read

jobs:
golangci:
strategy:
matrix:
go: ['1.21']
os: [ubuntu-latest, macos-latest, windows-latest]
permissions:
# Optional: Allow write access to checks to allow the action to annotate code in the PR.
checks: write

name: lint
runs-on: ${{ matrix.os }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
with:
egress-policy: audit

- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: ${{ matrix.go }}
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@d6238b002a20823d52840fda27e2d4891c5952dc # v4.0.1
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.57.2

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
#
# Note: by default the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
args: --timeout=10m

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional:The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
58 changes: 58 additions & 0 deletions .github/workflows/goreportcard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Go Report Card

on:
push:
branches:
- main
pull_request:

permissions: # added using https://github.com/step-security/secure-repo
contents: read

jobs:
goreportcard:
strategy:
matrix:
go: ['stable']
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
with:
egress-policy: audit

- name: Setup Go ${{ matrix.go }}
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: ${{ matrix.go }}
cache: false
- name: Checkout gojp/goreportcard repo
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
repository: gojp/goreportcard
path: goreportcard
- name: Install goreportcard-cli
# goreportcard-cli requires the following linters:
# 1. gometalinter
# 2. golint
# 3. gocyclo
# 4. ineffassign
# 5. misspell
# among which, the linter gometalinter is deprecated. However, goreportcard repo has a vendor version of it.
# Hence installing from the repo instead of `go install`. Refer https://github.com/gojp/goreportcard/issues/301
run: |
cd goreportcard
# Install prerequisite linter binaries: gometalinter, golint, gocyclo, ineffassign & misspell
# Refer: https://github.com/gojp/goreportcard?tab=readme-ov-file#command-line-interface
make install
# Install goreportcard-cli binary
go install ./cmd/goreportcard-cli
- name: Checkout Boeing/config-file-validator repo
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Run goreportcard
run: |
# Failure threshold is set to 100% to fail at any errors. Default is 75%.
goreportcard-cli -t 100
28 changes: 20 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ env:
IMAGE_NAME: ${{ github.repository }}

permissions:
contents: write
packages: write
contents: read

jobs:
releases-matrix:
Expand All @@ -26,14 +25,22 @@ jobs:
- goarch: arm64
goos: windows

permissions:
packages: write

steps:
- uses: actions/checkout@v3
- uses: wangyoucao577/go-release-action@v1
- name: Harden Runner
uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
with:
egress-policy: audit

- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- uses: wangyoucao577/go-release-action@8fa1e8368c8465264d64e0198208e10f71474c87 # v1.50
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
go_version: 1.21
go_version: 1.22
binary_name: "validator"
ldflags: -w -s -extldflags "-static" -X github.com/Boeing/config-file-validator.version=${{ github.event.release.tag_name }}
build_tags: -tags netgo
Expand All @@ -46,15 +53,20 @@ jobs:
strategy:
matrix:
include:
- base: "alpine:3.18"
- base: "alpine:3.19@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b"
postfix: ""
- base: "scratch"
postfix: "-scratch"
- base: "ubuntu:20.04"
- base: "ubuntu:20.04@sha256:874aca52f79ae5f8258faff03e10ce99ae836f6e7d2df6ecd3da5c1cad3a912b"
postfix: "-ubuntu"

steps:
- uses: actions/checkout@v3
- name: Harden Runner
uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
with:
egress-policy: audit

- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.

name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '43 11 * * 5'
push:
branches: [ "main" ]
pull_request:

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

jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write

steps:
- name: Harden Runner
uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
with:
egress-policy: audit

- name: "Checkout code"
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
with:
results_file: results.sarif
results_format: sarif

# Public repositories:
# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
publish_results: true

# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@97a0fba1372883ab732affbe8f94b823f91727db # v3.pre.node20
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard (optional).
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
with:
sarif_file: results.sarif
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.so
*.dylib
cmd/validator/validator
bin/

# Test binary, built with `go test -c`
*.test
Expand Down
Loading

0 comments on commit bb9ca38

Please sign in to comment.