Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[StepSecurity] Apply security best practices #5

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
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
10 changes: 9 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: CI Build & Test
# Triggers the workflow on push or pull request events
on: [push, pull_request]
permissions:
contents: read

jobs:
build:
strategy:
Expand Down Expand Up @@ -96,8 +99,13 @@ jobs:
runs-on: ${{ matrix.os }}

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

- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
submodules: 'True'

Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/codacy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- v2
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read

jobs:
tidy:
name: Tidy
Expand All @@ -22,7 +25,12 @@ jobs:
CCT_OUT: /tmp/cct-out

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

- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
submodules: 'True'

Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ on:
schedule:
- cron: '28 5 * * 4'

permissions:
contents: read

jobs:
analyze:
name: Analyze
Expand All @@ -39,12 +42,17 @@ jobs:
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

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

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@0116bc2df50751f9724a2e35ef1f24d22f90e4e1 # v2.22.3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -58,7 +66,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@0116bc2df50751f9724a2e35ef1f24d22f90e4e1 # v2.22.3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -71,6 +79,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@0116bc2df50751f9724a2e35ef1f24d22f90e4e1 # v2.22.3
with:
category: "/language:${{matrix.language}}"
12 changes: 10 additions & 2 deletions .github/workflows/coverity.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Coverity Scan
on: workflow_dispatch
permissions:
contents: read

jobs:
coverity:
name: Coverity Scan
Expand All @@ -11,7 +14,12 @@ jobs:
BUILD_TOOL_DIR: "${{ github.workspace }}/coverity-build"

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

- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
submodules: 'True'

Expand All @@ -33,7 +41,7 @@ jobs:

- name: Cache the Coverity Build Tool
id: cache-build-tool
uses: actions/cache@v3
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
key: coverity-${{ runner.os }}-${{ steps.get-cov-md5.outputs.md5 }}
path: '${{ env.BUILD_TOOL_DIR }}/coverity_tool.tgz'
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Dependency Review Action
#
# This Action will scan dependency manifest files that change as part of a Pull Request,
# surfacing known-vulnerable versions of the packages declared or updated in the PR.
# Once installed, if the workflow run is marked as required,
# PRs introducing known-vulnerable packages will be blocked from merging.
#
# Source repository: https://github.com/actions/dependency-review-action
name: 'Dependency Review'
on: [pull_request]

permissions:
contents: read

jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
with:
egress-policy: audit

- name: 'Checkout Repository'
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: 'Dependency Review'
uses: actions/dependency-review-action@0efb1d1d84fc9633afcdaad14c485cbbc90ef46c # v2.5.1
14 changes: 11 additions & 3 deletions .github/workflows/doxygen.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Doxygen
on: workflow_dispatch
permissions:
contents: read

jobs:
doxygen:
name: Build Doxygen Docs
Expand All @@ -9,7 +12,12 @@ jobs:
VERSION: 1.9.7

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

- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
submodules: 'True'

Expand All @@ -20,7 +28,7 @@ jobs:

- name: Cache the Doxygen binary
id: cache-binary
uses: actions/cache@v3
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
key: 'doxygen-${{ runner.os }}-${{ env.VERSION }}'
path: '${{ env.TOOL_DIR }}/doxygen.tgz'
Expand Down Expand Up @@ -50,7 +58,7 @@ jobs:
tar czf ./docs.tgz docs

- name: Upload Documentation
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: docs
path: ./docs.tgz
12 changes: 10 additions & 2 deletions .github/workflows/klee.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@ on:
# The branches below must be a subset of the branches above
branches: [ "main" ]
workflow_dispatch:
permissions:
contents: read

jobs:
klee:
runs-on: ubuntu-latest
container:
image: klee/klee:2.3
options: -u 0 --ulimit="stack=-1:-1"
steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
with:
egress-policy: audit

- name: Get the Kitware APT repository signing key
run: |
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
Expand All @@ -46,7 +54,7 @@ jobs:
sudo apt-get install -y git

- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
submodules: 'True'

Expand Down Expand Up @@ -74,7 +82,7 @@ jobs:
tar czf ./kout.tgz "${{ github.workspace }}/build/klee/kout"

- name: Upload Test Outputs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: kout.tgz
path: ./kout.tgz
11 changes: 8 additions & 3 deletions .github/workflows/msvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ jobs:
runs-on: windows-2019

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

- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
submodules: 'True'

Expand All @@ -57,13 +62,13 @@ jobs:

# Upload SARIF file to GitHub Code Scanning Alerts
- name: Upload SARIF to GitHub
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@0116bc2df50751f9724a2e35ef1f24d22f90e4e1 # v2.22.3
with:
sarif_file: ${{ steps.run-analysis.outputs.sarif }}

# Upload SARIF file as an Artifact to download and view
- name: Upload SARIF as an Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: sarif-file
path: ${{ steps.run-analysis.outputs.sarif }}
5 changes: 5 additions & 0 deletions .github/workflows/scorecard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ jobs:
# actions: read

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

- name: "Checkout code"
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/sonarcloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ jobs:
CLANG_VERSION: 14

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

- name: Install clang
run: |
if ! command -v "clang++-${{ env.CLANG_VERSION }}"
Expand All @@ -28,7 +33,7 @@ jobs:
sudo ./llvm.sh "$CLANG_VERSION" all
fi

- uses: actions/checkout@v3
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
submodules: 'True'
Expand All @@ -43,7 +48,7 @@ jobs:
ninja-build

- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v1
uses: SonarSource/sonarcloud-github-c-cpp@8d08b4c506dc7a0601ad08b06f73fc9718cea84e # v1.3.2

- name: Configure build
run: |
Expand Down
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.16.3
hooks:
- id: gitleaks
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: shellcheck
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
- id: cpplint
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pylint-dev/pylint
rev: v2.17.2
hooks:
- id: pylint
Loading