Skip to content

Commit

Permalink
fix codeql and setup ossf scorecard workflow (#2410)
Browse files Browse the repository at this point in the history
* fix codeql and setup ossf scorecard workflow

Signed-off-by: Matthieu MOREL <[email protected]>

* Update dependabot.yml

Signed-off-by: Matthieu MOREL <[email protected]>

---------

Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 authored Jan 8, 2024
1 parent e9661e4 commit 8bd9e8a
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 23 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
version: 2
updates:
- package-ecosystem: docker
directory: "/"
schedule:
interval: daily
time: "03:00"
timezone: "Europe/Berlin"
- package-ecosystem: docker
directory: "/tests"
schedule:
interval: daily
time: "03:00"
timezone: "Europe/Berlin"
- package-ecosystem: gomod
directory: "/"
schedule:
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/base-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@ on:
paths-ignore:
- '**.md'

permissions:
contents: read

jobs:
basic-checks:
runs-on: ubuntu-20.04
env:
USER: jaegertracing
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: "1.21"

Expand Down
20 changes: 16 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ on:
paths-ignore:
- '**.md'

permissions:
contents: read

jobs:
codeql-analyze:
permissions:
actions: read # for github/codeql-action/init to get workflow details
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/autobuild to send a status report
name: CodeQL Analyze
runs-on: ubuntu-latest

Expand All @@ -22,19 +29,24 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: "Set up Go"
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: "go.mod"

# Disable CodeQL for tests
# https://github.com/github/codeql/issues/4786
- run: rm -rf ./tests

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v3.22.12
with:
languages: go

- name: Autobuild
uses: github/codeql-action/autobuild@v3
uses: github/codeql-action/autobuild@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v3.22.12

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v3.22.12
11 changes: 7 additions & 4 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ concurrency:
group: e2e-tests-${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

permissions:
contents: read

jobs:
e2e:
name: "Run ${{ matrix.testsuite.label }} E2E tests (${{ matrix.kube-version }})"
Expand All @@ -34,19 +37,19 @@ jobs:
- { name: "upgrade", label: "Upgrade" }
steps:
- name: "Check out code into the Go module directory"
uses: actions/checkout@v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: "Set up Go"
uses: actions/setup-go@v5
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: "1.21"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
with:
install: true
- name: Cache Docker layers
uses: actions/cache@v3
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: /tmp/.buildx-cache
key: e2e-${{ github.sha }}
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/ossf-scorecard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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: '45 13 * * 1'
push:
branches: [ "main" ]

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
# Uncomment the permissions below if installing in a private repository.
# contents: read
# actions: read

steps:
- name: "Checkout code"
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@e38b1902ae4f44df626f11ba0734b14fb91f8f86 # v2.1.2
with:
results_file: results.sarif
results_format: sarif
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@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@17573ee1cc1b9d061760f3a006fc4aac4f944fd5 # v2.2.4
with:
sarif_file: results.sarif
9 changes: 6 additions & 3 deletions .github/workflows/publish-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ on:
paths-ignore:
- '**.md'

permissions:
contents: read

jobs:
publish:
runs-on: ubuntu-latest
env:
USER: jaegertracing
steps:
- uses: actions/checkout@v4
- uses: docker/[email protected]
- uses: docker/[email protected]
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
- uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
- name: "publishes the images"
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ jobs:
USER: jaegertracing
steps:
- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: "1.21"

- uses: actions/checkout@v4
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: "install kubebuilder"
run: ./hack/install/install-kubebuilder.sh

- name: "install kustomize"
run: ./hack/install/install-kustomize.sh
- uses: docker/[email protected]
- uses: docker/[email protected]
- uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
- uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

- name: "generate release resources"
run: make release-artifacts USER=jaegertracing
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/sdk-scorecard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ on:
paths-ignore:
- '**.md'

permissions:
contents: read

jobs:
operator-sdk-scorecard:
name: "Operator-SDK Scorecard"
runs-on: ubuntu-latest
steps:
- name: "Check out code"
uses: actions/checkout@v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: "Install KIND"
run: ./hack/install/install-kind.sh
- name: "Install KUTTL"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.21 as builder
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.21@sha256:672a2286da3ee7a854c3e0a56e0838918d0dbb1c18652992930293312de898a6 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.asserts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.21 as builder
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.21@sha256:672a2286da3ee7a854c3e0a56e0838918d0dbb1c18652992930293312de898a6 as builder

WORKDIR /workspace

Expand Down Expand Up @@ -27,7 +27,7 @@ RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o ./index -a ./tests/assert-

# Use the curl container image to ensure we have curl installed. Also, it is a
# minimal container image
FROM curlimages/curl:7.81.0
FROM curlimages/curl@sha256:4bfa3e2c0164fb103fb9bfd4dc956facce32b6c5d47cc09fcec883ce9535d5ac
WORKDIR /
COPY --from=builder /workspace/reporter .
COPY --from=builder /workspace/reporter-otlp .
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status][ci-img]][ci] [![Go Report Card][goreport-img]][goreport] [![Code Coverage][cov-img]][cov] [![GoDoc][godoc-img]][godoc]
[![Build Status][ci-img]][ci] [![Go Report Card][goreport-img]][goreport] [![Code Coverage][cov-img]][cov] [![GoDoc][godoc-img]][godoc] [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/jaegertracing/jaeger-operator/badge)](https://securityscorecards.dev/viewer/?uri=github.com/jaegertracing/jaeger-operator)

# Jaeger Operator for Kubernetes

Expand Down
2 changes: 1 addition & 1 deletion tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The Dockerfile's resulting image is purpose-built for executing Jaeger Operator e2e tests within the OpenShift release (https://github.com/openshift/release) using Prow CI.
FROM golang:1.21
FROM golang@sha256:672a2286da3ee7a854c3e0a56e0838918d0dbb1c18652992930293312de898a6

# Set the user to root
USER root
Expand Down

0 comments on commit 8bd9e8a

Please sign in to comment.