-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add check secrets and update GHA workflow files (#379)
- Loading branch information
Showing
9 changed files
with
149 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
enable-secret-scan-all-files: true | ||
framework: | ||
- secrets | ||
quiet: true | ||
skip-path: | ||
- docs | ||
summary-position: bottom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name: "CodeQL config" | ||
|
||
paths-ignore: | ||
- tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# 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: '17 4 * * 2' | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: [self-hosted, public, linux, x64] | ||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3 | ||
- name: Set up Go | ||
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4 | ||
with: | ||
go-version: '1.19' # To match codeql go version | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@83f0fe6c4988d98a455712a27f0255212bba9bd4 # v2 | ||
with: | ||
languages: go | ||
config-file: ./.github/codeql-config.yml | ||
- name: Build | ||
run: go build | ||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@83f0fe6c4988d98a455712a27f0255212bba9bd4 # v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# !!! Important !!! | ||
# This a reusable workflow and is used in the PR and push to main branch flow separately | ||
# to be able to protect it behind a manual approval in the PR flow | ||
|
||
name: security-shared | ||
|
||
on: | ||
workflow_call: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
gosec: | ||
runs-on: [self-hosted, public, linux, x64] | ||
env: | ||
GO111MODULE: on | ||
steps: | ||
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- name: Run Gosec Security Scanner | ||
uses: securego/gosec@c5ea1b7bdd9efc3792e513258853552b0ae31e06 # v2 | ||
with: | ||
args: './...' | ||
trufflehog-secrets: | ||
runs-on: [self-hosted, public, linux, x64] | ||
steps: | ||
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- name: detect secrets | ||
uses: edplato/trufflehog-actions-scan@0af17d9dd1410283f740eb76b0b8f6b696cadefc # v0.9 | ||
with: | ||
scanArguments: "--regex --entropy=False --exclude_paths .github/exclude-patterns.txt --max_depth=1" | ||
checkov-secrets: | ||
runs-on: [self-hosted, public, linux, x64] | ||
steps: | ||
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- name: Scan for secrets | ||
uses: bridgecrewio/checkov-action@master # use latest and greatest | ||
with: | ||
api-key: ${{ secrets.BC_API_KEY }} | ||
config_file: .github/checkov.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,24 @@ | ||
# !!! Important !!! | ||
# any change to this workflow will not take into effect on the same PR and only after, | ||
# because of security implications from target 'pull_request_target' | ||
|
||
name: security | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
pull_request_target: # this is needed to use the API key in a PR | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
gosec: | ||
runs-on: [self-hosted, public, linux, x64] | ||
env: | ||
GO111MODULE: on | ||
steps: | ||
- name: Checkout Source | ||
uses: actions/checkout@v2 | ||
- name: Run Gosec Security Scanner | ||
uses: securego/gosec@master | ||
with: | ||
args: './...' | ||
codeql: | ||
runs-on: [self-hosted, public, linux, x64] | ||
permissions: | ||
security-events: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.19' # To match codeql go version | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v2 | ||
with: | ||
languages: go | ||
- name: Build | ||
run: go build | ||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v2 | ||
detect-secrets: | ||
runs-on: [self-hosted, public, linux, x64] | ||
start-security-scan: | ||
runs-on: ubuntu-latest | ||
environment: scan-security | ||
steps: | ||
- uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3 | ||
- name: detect secrets | ||
uses: edplato/trufflehog-actions-scan@0af17d9dd1410283f740eb76b0b8f6b696cadefc # v0.9 | ||
with: | ||
scanArguments: "--regex --entropy=False --exclude_paths .github/exclude-patterns.txt --max_depth=1" | ||
- run: echo start security scan # just needs a simple step to better control the follow-up jobs | ||
security: | ||
needs: start-security-scan | ||
uses: ./.github/workflows/security-shared.yml | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters