Skip to content

Commit

Permalink
[CP-Sec] Remediate OpenSSF flagged issues
Browse files Browse the repository at this point in the history
* Add top-level permissions to CodeQL workflow
* Add top-level permissions to CI workflow
* Pin docker image by hash
* Pin github actions by hash
  • Loading branch information
carlewis committed May 29, 2024
1 parent 5716ca8 commit 7b43cfa
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Continuous Integration

on: [push, pull_request]

permissions:
contents: read

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
Expand All @@ -12,10 +15,10 @@ jobs:
runs-on: ubuntu-latest

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

- name: clang-format
uses: jidicula/clang-format-action@v4.13.0
uses: jidicula/clang-format-action@c74383674bf5f7c69f60ce562019c1c94bc1421a # v4.13.0
with:
clang-format-version: '17'
check-path: 'src'
Expand All @@ -30,10 +33,10 @@ jobs:

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

- name: Path filter
uses: dorny/paths-filter@v3
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: changes
with:
filters: |
Expand All @@ -42,19 +45,19 @@ jobs:
- name: Set up Docker Buildx
if: steps.changes.outputs.container == 'true'
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0

- name: Log in to the Container registry
if: steps.changes.outputs.container == 'true'
uses: docker/login-action@v3
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
Expand All @@ -65,7 +68,7 @@ jobs:
- name: Build and push
if: steps.changes.outputs.container == 'true'
uses: docker/build-push-action@v5
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
context: '{{defaultContext}}:ci'
push: true
Expand All @@ -92,7 +95,7 @@ jobs:
password: ${{ secrets.github_token }}
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
submodules: "recursive"

Expand All @@ -118,7 +121,7 @@ jobs:

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

- name: Configure CMake (no graphics)
run: >
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ on:
env:
BUILD_TYPE: Release

permissions: {}

jobs:
analyze:
name: Analyze (${{ matrix.language }})
Expand Down Expand Up @@ -63,7 +65,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

# Handle git 'dubious ownership/safe.directory' container warnings (reduces related CodeQL verbosity)
- name: Add safe Git directory
Expand All @@ -72,7 +74,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
Expand Down Expand Up @@ -107,6 +109,6 @@ jobs:
run: cmake --build ${{github.workspace}}/build -- -k -j

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
# 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@v4
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: SARIF file
path: results.sarif
Expand Down
2 changes: 1 addition & 1 deletion ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:22.04
FROM ubuntu:24.04@sha256:3f85b7caad41a95462cf5b787d8a04604c8262cdcdf9a472b8c52ef83375fe15

# Get basic dependencies from Ubuntu repositories
RUN apt update && apt -y install wget gpg git cmake ninja-build \
Expand Down

0 comments on commit 7b43cfa

Please sign in to comment.