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] ci: Harden GitHub Actions #31

Merged
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
Expand Up @@ -9,3 +9,9 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "daily"


- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
17 changes: 14 additions & 3 deletions .github/workflows/codacy-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,29 @@ on:
schedule:
- cron: '16 4 * * 0'

permissions: # added using https://github.com/step-security/secure-workflows
contents: read

jobs:
codacy-security-scan:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
name: Codacy Security Scan
runs-on: ubuntu-latest
steps:
# Checkout the repository to the GitHub Actions runner
- name: Harden Runner
uses: step-security/harden-runner@2e205a28d0e1da00c5f53b161f4067b052c61f34
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791

# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@1.1.0
uses: codacy/codacy-analysis-cli-action@d840f886c4bd4edc059706d09c6a1586111c540b
with:
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
# You can also omit the token and run the tools that support default configurations
Expand All @@ -44,6 +55,6 @@ jobs:

# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v1
uses: github/codeql-action/upload-sarif@aacfdb2143271bef44adf6400251bdce32a5dd9a
with:
sarif_file: results.sarif
14 changes: 11 additions & 3 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,29 @@ name: Test and coverage

on: [push, pull_request]

permissions: # added using https://github.com/step-security/secure-workflows
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@2e205a28d0e1da00c5f53b161f4067b052c61f34
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791
with:
fetch-depth: 2
- uses: actions/setup-go@v2
- uses: actions/setup-go@bfdd3570ce990073878bf10f6b2d79082de49492
with:
go-version: '1.18'
- name: Run coverage
run: make calculate_coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b
with:
verbose: true
flags: go_tests
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ on:
schedule:
- cron: '17 11 * * 4'

permissions: # added using https://github.com/step-security/secure-workflows
contents: read

jobs:
analyze:
name: Analyze
Expand All @@ -38,12 +41,17 @@ jobs:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

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

- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@aacfdb2143271bef44adf6400251bdce32a5dd9a
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -54,7 +62,7 @@ jobs:
# 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@v1
uses: github/codeql-action/autobuild@aacfdb2143271bef44adf6400251bdce32a5dd9a

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -68,4 +76,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@aacfdb2143271bef44adf6400251bdce32a5dd9a
12 changes: 10 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
on: [ push ]
name: Go tests
permissions: # added using https://github.com/step-security/secure-workflows
contents: read

jobs:
Build-and-test:
strategy:
Expand All @@ -8,10 +11,15 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@2e205a28d0e1da00c5f53b161f4067b052c61f34
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@bfdd3570ce990073878bf10f6b2d79082de49492
with:
go-version: ${{ matrix.go-version }}

Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
name: golangci-lint
on: [push ]
permissions: # added using https://github.com/step-security/secure-workflows
contents: read

jobs:
golangci:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@2e205a28d0e1da00c5f53b161f4067b052c61f34
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@5c56cd6c9dc07901af25baab6f2b0d9f3b7c3018
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/mysql.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: MySQL tests
on: [ push ]

permissions: # added using https://github.com/step-security/secure-workflows
contents: read

jobs:
Test-mysql-integration:
runs-on: ubuntu-latest
Expand All @@ -20,11 +23,16 @@ jobs:
- 3306:3306

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

- name: Check out repository code
uses: actions/checkout@v2
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@bfdd3570ce990073878bf10f6b2d79082de49492
with:
go-version: 1.16

Expand All @@ -42,7 +50,7 @@ jobs:
run: go test -coverprofile=coverage.txt -covermode=atomic -coverpkg=github.com/muir/libschema/... ./lsmysql/...

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b
with:
verbose: true
flags: mysql_tests
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/pg.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: PostgreSQL tests
on: [ push ]

permissions: # added using https://github.com/step-security/secure-workflows
contents: read

jobs:
Test-postgres-integration:
runs-on: ubuntu-latest
Expand All @@ -19,11 +22,16 @@ jobs:
- 5432:5432

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

- name: Check out repository code
uses: actions/checkout@v2
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@bfdd3570ce990073878bf10f6b2d79082de49492
with:
go-version: 1.16

Expand All @@ -41,7 +49,7 @@ jobs:
run: go test -coverprofile=coverage.txt -covermode=atomic -coverpkg=github.com/muir/libschema/... ./lspostgres/...

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b
with:
verbose: true
flags: pg_tests
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/s2.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: SingleStore tests
on: [ push ]

permissions: # added using https://github.com/step-security/secure-workflows
contents: read

jobs:
Test-mysql-integration:
runs-on: ubuntu-latest
Expand All @@ -19,15 +22,20 @@ jobs:
SINGLESTORE_LICENSE: ${{ secrets.SINGLESTORE_LICENSE }}

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

- name: sanity check using mysql client
run: |
mysql -u root -ptest -e "CREATE DATABASE libschematest" -h 127.0.0.1

- name: Check out repository code
uses: actions/checkout@v2
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@bfdd3570ce990073878bf10f6b2d79082de49492
with:
go-version: 1.16

Expand All @@ -45,7 +53,7 @@ jobs:
run: go test -coverprofile=coverage.txt -covermode=atomic -coverpkg=github.com/muir/libschema/... ./lsmysql/... ./lssinglestore/...

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b
with:
verbose: true
flags: singlestore_tests
Expand Down