-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OPS-4460 - Github actions for pr validation (#105)
* OPS-4460 added scans for pr validation * added a access config * added needed secrets GH_TOKEN * chore: address gosec issues * chore: bump go version * ci: fix ci action --------- Signed-off-by: Tyler Gillson <[email protected]> Co-authored-by: umar <[email protected]> Co-authored-by: Fayas Ahamed <[email protected]> Co-authored-by: Tyler Gillson <[email protected]>
- Loading branch information
1 parent
6d5477c
commit a69f2f6
Showing
8 changed files
with
117 additions
and
19 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 |
---|---|---|
@@ -1,27 +1,38 @@ | ||
name: CI | ||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ci-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build-with-coverage: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Unshallow | ||
run: git fetch --prune --unshallow | ||
|
||
- name: Configure git for private modules | ||
env: | ||
TOKEN: ${{ secrets.SPECTRO_TOKEN }} | ||
USER: ${{ secrets.SPECTRO_USER }} | ||
run: git config --global url."https://${USER}:${TOKEN}@github.com".insteadOf "https://github.com" | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.21 | ||
go-version-file: go.mod | ||
|
||
- name: Vet | ||
run: make vet | ||
|
||
- name: Lint | ||
run: make lint | ||
|
||
- name: Test | ||
run: make test |
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,26 @@ | ||
name: GoLicensesPRValidation | ||
on: [pull_request] | ||
|
||
concurrency: | ||
group: go-licenses-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
go-licenses-pr-scan: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: gcr.io/spectro-images-public/golang:1.22-alpine | ||
steps: | ||
- name: install-go-licenses | ||
run: GOBIN=/usr/local/bin go install github.com/google/go-licenses@latest | ||
|
||
- name: checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: set-github-access | ||
run: | | ||
/usr/bin/git config --global --add url."https://${{ secrets.GH_TOKEN }}:x-oauth-basic@github".insteadOf https://github | ||
/usr/bin/git config --global --add url."https://${{ secrets.GH_TOKEN }}:x-oauth-basic@github".insteadOf git@github | ||
- name: go-licenses-scan | ||
run: go-licenses check --ignore github.com/spectrocloud ./... |
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,38 @@ | ||
name: GoSecPRValidation | ||
on: [pull_request] | ||
|
||
concurrency: | ||
group: gosec-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
gosec-pr-scan: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: gcr.io/spectro-dev-public/bulwark/gosec:latest | ||
env: | ||
REPO: ${{ github.event.repository.name }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- name: gosec-scan | ||
shell: sh | ||
env: | ||
BRANCH: ${{ github.head_ref || github.ref_name }} | ||
GO111MODULE: on | ||
run: /workspace/bulwark -name CodeSASTGoSec -verbose -target $REPO -tags "branch:$BRANCH,rules:-G101" | ||
|
||
- name: check-result | ||
shell: sh | ||
run: | | ||
resultPath=$REPO-result.json | ||
issues=$(cat $resultPath | jq -r '.Stats.found') | ||
echo "Found ${issues} issues" | ||
echo "Issues by Rule ID" | ||
jq -r '.Issues | group_by (.rule_id)[] | {rule: .[0].rule_id, count: length}' $resultPath | ||
if [ "$issues" -gt 0 ]; then | ||
echo "GoSec SAST scan failed with below findings..." | ||
cat $resultPath | ||
exit 1 | ||
else | ||
echo "GoSec SAST scan passed" | ||
fi |
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,28 @@ | ||
name: GoVulnCheckPRValidation | ||
on: [pull_request] | ||
|
||
concurrency: | ||
group: govulncheck-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
govulncheck-pr-scan: | ||
runs-on: security-runner | ||
container: | ||
image: gcr.io/spectro-images-public/golang:1.22-alpine | ||
steps: | ||
- name: install-govulncheck | ||
run: GOBIN=/usr/local/bin go install golang.org/x/vuln/cmd/govulncheck@latest | ||
|
||
- name: checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: set-github-access | ||
run: | | ||
/usr/bin/git config --global --add url."https://${{ secrets.GH_TOKEN }}:x-oauth-basic@github".insteadOf https://github | ||
/usr/bin/git config --global --add url."https://${{ secrets.GH_TOKEN }}:x-oauth-basic@github".insteadOf git@github | ||
- name: govulncheck-scan | ||
run: | | ||
go version | ||
govulncheck -mode source ./... |
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
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