Skip to content

Commit

Permalink
apply security best practices
Browse files Browse the repository at this point in the history
  • Loading branch information
vasu1124 committed Mar 14, 2024
1 parent ffb96db commit a038b7b
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 38 deletions.
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly

- package-ecosystem: docker
directory: /
schedule:
interval: monthly

- package-ecosystem: gomod
directory: /
schedule:
interval: monthly
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ jobs:
# DOCKER_TARGET_PLATFORM: linux/amd64,linux/arm/v7

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

- name: Check out cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ on:
branches: [ "main" ]
workflow_dispatch:

permissions:
contents: read

jobs:
analyze:
name: Analyze
Expand Down Expand Up @@ -48,6 +51,11 @@ jobs:
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

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

- name: Checkout repository
uses: actions/checkout@v4

Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/reuse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
branches: [ "main" ]
workflow_dispatch:

permissions:
contents: read

jobs:
reuse:
name: reuse
Expand All @@ -18,6 +21,11 @@ jobs:
security-events: write

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

- name: Checkout repository
uses: actions/checkout@v4

Expand Down
75 changes: 40 additions & 35 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,42 +32,47 @@ jobs:
# actions: read

steps:
- name: "Checkout code"
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: audit

- name: "Run analysis"
uses: ossf/[email protected]
with:
results_file: results.sarif
results_format: sarif
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecard on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
- name: "Checkout code"
uses: actions/checkout@v4
with:
persist-credentials: false

# 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.
# For private repositories:
# - `publish_results` will always be set to `false`, regardless
# of the value entered here.
publish_results: true
- name: "Run analysis"
uses: ossf/[email protected]
with:
results_file: results.sarif
results_format: sarif
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecard on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
# repo_token: ${{ secrets.SCORECARD_TOKEN }}

# 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/[email protected]
with:
name: SARIF file
path: results.sarif
retention-days: 5
# 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.
# For private repositories:
# - `publish_results` will always be set to `false`, regardless
# of the value entered here.
publish_results: true

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/[email protected]
with:
sarif_file: results.sarif
# 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/[email protected]
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/[email protected]
with:
sarif_file: results.sarif
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

FROM golang:1.21-alpine as builder
FROM golang:1.22-alpine as builder
ARG gitVersion=0.0.0-dev
ARG gitCommit=0000000000000000000000000000000000000000
ARG gitTreeState="dirty"
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/useless/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

# Build the manager binary
FROM golang:1.21 as builder
FROM golang:1.22 as builder
ARG TARGETOS
ARG TARGETARCH

Expand Down

0 comments on commit a038b7b

Please sign in to comment.