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

fix: NPG-5347 Apply security best practices #286

Closed
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
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly

- package-ecosystem: cargo
directory: /
schedule:
interval: monthly
14 changes: 12 additions & 2 deletions .github/workflows/branch-delete-cleanup.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
name: Branch Deleted
on: delete
permissions:
contents: read

jobs:
delete:
permissions:
contents: write # for stefanzweifel/git-auto-commit-action to push code in repo
name: On branch deleted
if: github.event.ref_type == 'branch'

runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@c8454efe5d0bdefd25384362fe217428ca277d57 # v2.2.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Set env
run: |
GIT_BRANCH=$(echo ${{ github.event.ref }} | sed -e "s#refs/heads/##g")
Expand All @@ -18,7 +28,7 @@ jobs:
echo "Clean up for branch ${{ env.GIT_BRANCH }}"

- name: Get current published documentation
uses: actions/checkout@v3
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
ref: gh-pages

Expand All @@ -27,6 +37,6 @@ jobs:
rm -rf ${{ env.GIT_BRANCH }}

- name: Save updated docs
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@3ea6ae190baf489ba007f7c92608f33ce20ef04a # v4.16.0
with:
commit_message: Removed Draft Docs for ${{ env.GIT_BRANCH }}
32 changes: 26 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,47 @@ env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 15


permissions:
contents: read

jobs:
cancel:
permissions:
actions: write # for styfle/cancel-workflow-action to cancel/stop running workflows
name: 'Cancel Previous Runs'
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: styfle/cancel-workflow-action@0.11.0
- name: Harden Runner
uses: step-security/harden-runner@c8454efe5d0bdefd25384362fe217428ca277d57 # v2.2.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # 0.11.0
with:
access_token: ${{ github.token }}

build_on_linux:
name: Build Catalyst Core on Linux
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@c8454efe5d0bdefd25384362fe217428ca277d57 # v2.2.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Install rust
uses: actions-rs/toolchain@v1
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
with:
toolchain: ${{env.RUST_LATEST_STABLE_VERSION}}

- name: Cache rust
uses: Swatinem/rust-cache@v2
uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # v2.2.1
with:
shared-key: "build_cache"
save-if: ${{ github.ref == 'refs/heads/main' }}
Expand All @@ -74,6 +89,11 @@ jobs:
env:
CARGO_FLAGS: --verbose --locked
steps:
- name: Harden Runner
uses: step-security/harden-runner@c8454efe5d0bdefd25384362fe217428ca277d57 # v2.2.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Checkout code on PR
# Workaround for the running out of disk space issue. See https://github.com/actions/runner-images/issues/1341
run: |
Expand All @@ -98,7 +118,7 @@ jobs:
git config --system core.longpaths true

- name: Cache rust
uses: Swatinem/rust-cache@v2
uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # v2.2.1
with:
workspaces: "C:\\${{ github.event.repository.name }}"
save-if: ${{ github.ref == 'refs/heads/main' }}
Expand All @@ -119,7 +139,7 @@ jobs:
"PQ_LIB_DIR=${env:PROGRAMFILES}\PostgreSQL\14\lib" >> $env:GITHUB_ENV

- name: Install rust
uses: actions-rs/toolchain@v1
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
with:
toolchain: ${{env.RUST_LATEST_STABLE_VERSION}}

Expand Down
38 changes: 27 additions & 11 deletions .github/workflows/ci-tests-n-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ concurrency:
group: ${{ github.sha }}
cancel-in-progress: true

permissions:
contents: read

jobs:
unit-tests:
permissions:
checks: write # for coverallsapp/github-action to create new checks
contents: read # for actions/checkout to fetch code
name: Unit Tests
runs-on: ubuntu-latest
needs: [integration-tests]
Expand All @@ -38,26 +44,31 @@ jobs:
ports:
- 5432:5432
steps:
- name: Harden Runner
uses: step-security/harden-runner@c8454efe5d0bdefd25384362fe217428ca277d57 # v2.2.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
with:
toolchain: ${{env.RUST_LATEST_STABLE_VERSION}} # it says it can read the rust-toolchain file, but it fails if we omit this
components: llvm-tools-preview

- name: Cache rust
uses: Swatinem/rust-cache@v2
uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # v2.2.1
with:
shared-key: "build_cache"
save-if: "false"

- name: Install nextest
uses: taiki-e/install-action@nextest
uses: taiki-e/install-action@ddfbd2cab72fd94842c80ade93f28fe7ee9c71f8 # nextest

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
uses: taiki-e/install-action@cdc3afe6ed5a5d5870c227c04be4eeb43e48fc81 # cargo-llvm-cov

- name: Install system deps
run:
Expand Down Expand Up @@ -102,7 +113,7 @@ jobs:
cargo llvm-cov report --lcov --output-path ./lcov.info

- name: Upload code coverage to coveralls.io
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@50c33ad324a9902697adbf2f92c22cf5023eacf1 # master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: "./lcov.info"
Expand All @@ -124,26 +135,31 @@ jobs:
ports:
- 5432:5432
steps:
- name: Harden Runner
uses: step-security/harden-runner@c8454efe5d0bdefd25384362fe217428ca277d57 # v2.2.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
with:
toolchain: ${{env.RUST_LATEST_STABLE_VERSION}} # it says it can read the rust-toolchain file, but it fails if we omit this
components: llvm-tools-preview

- name: Cache rust
uses: Swatinem/rust-cache@v2
uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # v2.2.1
with:
shared-key: "build_cache"
save-if: "false"

- name: Install nextest
uses: taiki-e/install-action@nextest
uses: taiki-e/install-action@ddfbd2cab72fd94842c80ade93f28fe7ee9c71f8 # nextest

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
uses: taiki-e/install-action@cdc3afe6ed5a5d5870c227c04be4eeb43e48fc81 # cargo-llvm-cov

- name: Install system deps
run:
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: ["main"]
pull_request:
# The branches below must be a subset of the branches above
branches: ["main"]
schedule:
- cron: "0 0 * * 1"

permissions:
contents: read

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: ["javascript", "python"]
# CodeQL supports [ $supported-codeql-languages ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Harden Runner
uses: step-security/harden-runner@c8454efe5d0bdefd25384362fe217428ca277d57 # v2.2.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Checkout repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@32dc499307d133bb5085bae78498c0ac2cf762d5 # v2.2.5
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Autobuild attempts to build any compiled languages (C/C++, C#, 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@32dc499307d133bb5085bae78498c0ac2cf762d5 # v2.2.5

# ℹ️ 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

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@32dc499307d133bb5085bae78498c0ac2cf762d5 # v2.2.5
with:
category: "/language:${{matrix.language}}"
25 changes: 25 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
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@c8454efe5d0bdefd25384362fe217428ca277d57 # v2.2.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: 'Checkout Repository'
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: 'Dependency Review'
uses: actions/dependency-review-action@0efb1d1d84fc9633afcdaad14c485cbbc90ef46c # v2.5.1
15 changes: 10 additions & 5 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ jobs:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Harden Runner
uses: step-security/harden-runner@c8454efe5d0bdefd25384362fe217428ca277d57 # v2.2.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Checkout The Code
uses: actions/checkout@v3
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
fetch-depth: 0

Expand All @@ -24,7 +29,7 @@ jobs:
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV

- name: Build Docs
uses: docker://ghcr.io/input-output-hk/catalyst-gh-tools:v1.3
uses: docker://ghcr.io/input-output-hk/catalyst-gh-tools@sha256:d4d0beee1c85b8004f14775d60e7c612e5bdab1c14eb6ddcbcebce2a4903a44b # v1.3
with:
entrypoint: cargo
args: make build-docs
Expand All @@ -34,7 +39,7 @@ jobs:
- name: Deploy Docs
id: deployAttempt
continue-on-error: true
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@bd8c6b06eba6b3d25d72b7a1767993c0aeee42e7 # v3.9.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./book/html
Expand All @@ -55,7 +60,7 @@ jobs:
id: deployRetry1
if: steps.deployAttempt.outcome == 'failure'
continue-on-error: true
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@bd8c6b06eba6b3d25d72b7a1767993c0aeee42e7 # v3.9.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./book/html
Expand All @@ -72,7 +77,7 @@ jobs:
- name: Deploy Docs
id: deployRetry2
if: steps.deployRetry1.outcome == 'failure'
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@bd8c6b06eba6b3d25d72b7a1767993c0aeee42e7 # v3.9.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./book/html
Expand Down
Loading