Skip to content
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
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@ updates:
codeql-action:
patterns:
- "github/codeql-action*"
cooldown:
default-days: 7

# dependabot auto-detects the vendor/ directory and runs `go mod tidy` + `go mod vendor` on updates
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
cooldown:
default-days: 7

# dev tools (actionlint, golangci-lint, gofumpt) pinned in .tools/go.mod; tools move slowly,
# so only check quarterly
- package-ecosystem: "gomod"
directory: "/.tools"
schedule:
interval: "quarterly"
cooldown:
default-days: 7
2 changes: 2 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: ./.go-version
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pr-depscheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: ./.go-version
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pr-golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: ./.go-version
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pr-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: ./.go-version
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # goreleaser derives the changelog and version from tag history
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: ./.go-version
cache: false
- uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
- uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3
with:
Expand All @@ -44,7 +46,7 @@
id-token: write # sign the provenance
contents: write # upload multiple.intoto.jsonl to the release
# the slsa builder must be referenced by tag, not commit hash; it verifies its own ref at runtime
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.1.0
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.1.0 # zizmor: ignore[unpinned-uses]
with:
base64-subjects: ${{ needs.goreleaser.outputs.hashes }}
upload-assets: true
Expand All @@ -58,6 +60,8 @@
attestations: write # actions/attest-build-provenance stores the attestation
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: docker/setup-buildx-action@594f3bf4285d9ea8dc53c9a0c9c4092420091003 # v4.4.0
- uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
- uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
Expand Down Expand Up @@ -108,6 +112,8 @@
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: update tap formula (source build)
env:
TAG: ${{ github.ref_name }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/shellcheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# shellcheck is preinstalled on ubuntu-latest
- run: make shellcheck
2 changes: 2 additions & 0 deletions .github/workflows/typos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- run: make typos
2 changes: 2 additions & 0 deletions .github/workflows/workflow-actionlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: ./.go-version
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/workflow-yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- run: make yamllint
27 changes: 27 additions & 0 deletions .github/workflows/workflow-zizmor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: workflow security audit

# Audits .github/workflows/ with zizmor (template injection, credential persistence, excessive
# permissions, dangerous triggers). Complements actionlint, which covers syntax, expressions and
# shell but not these. make downloads the version pinned in the makefile.

on:
push:
branches: [ 'main' ]
pull_request:
types: ['opened', 'synchronize']

permissions:
contents: read

concurrency:
group: 'workflow-zizmor-${{ github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
workflow-zizmor:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- run: make zizmor
20 changes: 17 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ GOFUMPT=$(TOOLS_BIN)/gofumpt
GOLANGCI_LINT=$(TOOLS_BIN)/golangci-lint

# non-Go tools also live in .tools/bin at pinned versions, but the pins are here (dependabot
# cannot bump them): shellcheck and typos are static binaries downloaded from their github releases,
# cannot bump them): shellcheck, typos and zizmor are static binaries downloaded from their github releases,
# yamllint is python installed into a repo-local venv. all rebuild when this makefile changes.
SHELLCHECK_VERSION=v0.11.0
TYPOS_VERSION=v1.50.1
YAMLLINT_VERSION=1.38.0
ZIZMOR_VERSION=v1.30.1
SHELLCHECK=$(TOOLS_BIN)/shellcheck
TYPOS=$(TOOLS_BIN)/typos
YAMLLINT=$(TOOLS_BIN)/yamllint
ZIZMOR=$(TOOLS_BIN)/zizmor

# golangci-lint with the azproviderlint module plugin compiled in (.tools/.custom-gcl.yml);
# lint runs use this binary, the plain go.mod one exists to bootstrap `golangci-lint custom`
Expand Down Expand Up @@ -58,6 +60,14 @@ $(YAMLLINT): makefile
@mkdir -p $(TOOLS_BIN)
@python3 -m venv .tools/venv && .tools/venv/bin/pip install -q yamllint==$(YAMLLINT_VERSION) && ln -sf ../venv/bin/yamllint $@

$(ZIZMOR): makefile
@echo "==> downloading zizmor $(ZIZMOR_VERSION)..."
@mkdir -p $(TOOLS_BIN)
@case "$$(uname)" in Darwin) target=apple-darwin;; *) target=unknown-linux-gnu;; esac; \
arch=$$(uname -m); [ "$$arch" = "arm64" ] && arch=aarch64; \
curl -sSfL "https://github.com/zizmorcore/zizmor/releases/download/$(ZIZMOR_VERSION)/zizmor-$$arch-$$target.tar.gz" \
| tar -xz -O zizmor > $@ && chmod +x $@

default: fmt build

all: fmt build
Expand All @@ -78,7 +88,7 @@ docker: ## Build the ghp-sync docker image
docker build --network=host --tag ghp-sync --build-arg GO_VERSION=$(shell cat .go-version) \
--build-arg VERSION=${GIT_VERSION} --build-arg GIT_COMMIT=${GIT_COMMIT} .

tools: $(ACTIONLINT) $(GOFUMPT) $(GOLANGCI_LINT) $(GOLANGCI_LINT_MODULES) $(SHELLCHECK) $(TYPOS) $(YAMLLINT) ## Install all pinned dev tools into .tools/bin
tools: $(ACTIONLINT) $(GOFUMPT) $(GOLANGCI_LINT) $(GOLANGCI_LINT_MODULES) $(SHELLCHECK) $(TYPOS) $(YAMLLINT) $(ZIZMOR) ## Install all pinned dev tools into .tools/bin

##@ Formatting
fmt: $(GOFUMPT) $(GOLANGCI_LINT) ## Fix Go formatting (gofmt, gofumpt, goimports)
Expand Down Expand Up @@ -122,6 +132,10 @@ typos-fix: $(TYPOS) ## Fix spelling mistakes found by typos
@echo "==> Fixing typos..."
@$(TYPOS) --write-changes

zizmor: $(ZIZMOR) ## Audit GitHub workflows for security issues with zizmor
@echo "==> Auditing workflows with zizmor..."
@$(ZIZMOR) .

depscheck: ## Check that go.mod/go.sum and vendor/ are in sync
@echo "==> Checking source code with go mod tidy..."
@go mod tidy
Expand All @@ -147,4 +161,4 @@ test: build ## Run the unit tests (with -race)

check-all: build test lint actionlint yamllint shellcheck typos depscheck ## Run build + test + all linters + depscheck

.PHONY: default all help fmt goimports build docker lint lint-fix actionlint yamllint shellcheck typos typos-fix depscheck check-all install tools test
.PHONY: default all help fmt goimports build docker lint lint-fix actionlint yamllint shellcheck typos typos-fix zizmor depscheck check-all install tools test
Loading