Skip to content

Commit 0d3f8a2

Browse files
committed
Fail on critical higj
Signed-off-by: sandhi <sagarwal@progress.com>
1 parent 4ee8d09 commit 0d3f8a2

3 files changed

Lines changed: 184 additions & 6 deletions

File tree

.github/workflows/ci-main-pull-request.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ on:
209209
required: false
210210
default: true
211211
type: boolean
212+
polaris-fail-on-high-critical:
213+
description: 'Fail the pipeline if Polaris SAST scan finds HIGH or CRITICAL vulnerabilities'
214+
required: false
215+
type: boolean
216+
default: false
212217

213218
perform-sonarqube-scan:
214219
description: 'Perform basic SonarQube scan'
@@ -379,6 +384,11 @@ on:
379384
required: false
380385
type: string
381386
default: ''
387+
blackduck-fail-on-high-critical:
388+
description: 'Fail the pipeline if BlackDuck SCA scan finds HIGH or CRITICAL vulnerabilities'
389+
required: false
390+
type: boolean
391+
default: false
382392

383393
udf1:
384394
description: 'User defined flag 1'
@@ -715,13 +725,13 @@ jobs:
715725
run-trufflehog:
716726
name: 'Trufflehog scan'
717727
if: ${{ inputs.perform-trufflehog-scan }}
718-
uses: chef/common-github-actions/.github/workflows/trufflehog.yml@main
728+
uses: chef/common-github-actions/.github/workflows/trufflehog.yml@sandhi/fix-blackduc-sca
719729
needs: checkout
720730

721731
run-trivy:
722732
name: 'Trivy scan'
723733
if: ${{ inputs.perform-trivy-scan }}
724-
uses: chef/common-github-actions/.github/workflows/trivy.yml@main
734+
uses: chef/common-github-actions/.github/workflows/trivy.yml@sandhi/fix-blackduc-sca
725735
needs: checkout
726736
with:
727737
version: ${{ inputs.version }}
@@ -1116,6 +1126,12 @@ jobs:
11161126
polaris_assessment_mode: ${{ inputs.polaris-assessment-mode }}
11171127
# TODO: warning in GA - polaris_assessment_mode is deprecated. Use polaris_test_sast_location=remote and/or polaris_test_sca_location=remote for source upload scans instead.
11181128
polaris_waitForScan: 'true' # ${{ inputs.polaris-wait-for-scan }} # defaults to true - is this a boolean or string?
1129+
# Enable PR comments with severity filtering to fail on HIGH/CRITICAL
1130+
polaris_prComment_enabled: ${{ inputs.polaris-fail-on-high-critical && github.event_name == 'pull_request' && 'true' || 'false' }}
1131+
polaris_prComment_severities: ${{ inputs.polaris-fail-on-high-critical && 'CRITICAL,HIGH' || '' }}
1132+
# Create and upload SARIF report for GitHub Security tab
1133+
polaris_reports_sarif_create: true
1134+
polaris_upload_sarif_report: true
11191135
# not yet enabled from https://github.com/prgs-community/githubactions-securityscans/blob/main/polaris/README.md
11201136
# project_source_archive: ${{ inputs.polaris-source-archive != '' && inputs.polaris-source-archive || null }}
11211137
# project_source_excludes: ${{ inputs.polaris-source-excludes != '' && inputs.polaris-source-excludes || null }}
@@ -1381,7 +1397,7 @@ jobs:
13811397
name: 'Generating SBOM'
13821398
# Create software bill-of-materials (SBOM) using SPDX format
13831399
if: ${{ inputs.generate-sbom == true }}
1384-
uses: chef/common-github-actions/.github/workflows/sbom.yml@main
1400+
uses: chef/common-github-actions/.github/workflows/sbom.yml@sandhi/fix-blackduc-sca
13851401
needs: checkout # TODO: fix set-application-version
13861402
secrets: inherit
13871403
with:
@@ -1398,6 +1414,7 @@ jobs:
13981414
run-bundle-install: ${{ inputs.run-bundle-install }} # Passed to sbom.yml to generate Gemfile.lock at runtime
13991415
language: ${{ inputs.language }}
14001416
ruby-app-directory: ${{ inputs.ruby-app-directory }}
1417+
blackduck-fail-on-high-critical: ${{ inputs.blackduck-fail-on-high-critical }}
14011418

14021419
quality-dashboard:
14031420
name: 'Reporting to quality dashboard'

.github/workflows/sbom.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ on:
8282
required: false
8383
type: string
8484
default: ''
85+
blackduck-fail-on-high-critical:
86+
description: 'Fail the pipeline if BlackDuck SCA scan finds HIGH or CRITICAL vulnerabilities'
87+
required: false
88+
type: boolean
89+
default: false
8590

8691
env:
8792
# Set the default SBOM filename prefix
@@ -245,9 +250,28 @@ jobs:
245250
path: ${{ inputs.ruby-app-directory != '' && format('{0}/Gemfile.lock', inputs.ruby-app-directory) || 'Gemfile.lock' }}
246251
name: ${{ github.event.repository.name }}-Gemfile-lock.txt
247252

253+
- name: Construct BlackDuck detect arguments
254+
id: detect-args
255+
run: |
256+
# Start with base arguments (always exclude PIP detector)
257+
DETECT_ARGS="--detect.excluded.detector.types=PIP"
258+
259+
# Add low accuracy mode if requested
260+
if [[ "${{ inputs.blackduck-force-low-accuracy-mode }}" == "true" ]]; then
261+
DETECT_ARGS="${DETECT_ARGS} --detect.accuracy.required=NONE"
262+
fi
263+
264+
# Add source path if ruby-app-directory is specified
265+
if [[ -n "${{ inputs.ruby-app-directory }}" ]]; then
266+
DETECT_ARGS="${DETECT_ARGS} --detect.source.path=${{ inputs.ruby-app-directory }}"
267+
fi
268+
269+
echo "DETECT_ARGS=${DETECT_ARGS}" >> $GITHUB_ENV
270+
echo "Constructed detect_args: ${DETECT_ARGS}"
271+
248272
- name: BlackDuck SCA scan
249273
uses: blackduck-inc/black-duck-security-scan@v2.1.1
250-
continue-on-error: true # Allow pipeline to continue even with policy violations
274+
continue-on-error: false # Allow pipeline to continue even with policy violations
251275
env:
252276
GOPRIVATE: ${{ inputs.go-private-modules }}
253277
DETECT_PROJECT_GROUP_NAME: ${{ inputs.blackduck-project-group-name}} #'Chef-Agents' # <the_parent_group_of_your_target_project>, Chef, Chef-Agents, Chef-Automate, Chef-Chef360, Chef-Habitat, Chef-Infrastructure-Server, Chef-Shared-Services
@@ -257,8 +281,8 @@ jobs:
257281
blackducksca_url: ${{ secrets.BLACKDUCK_SBOM_URL }} # BLACKDUCK_URL, should be https://progresssoftware.app.blackduck.com/
258282
blackducksca_token: ${{ secrets.BLACKDUCK_SCA_TOKEN }} # was BLACKDUCK_API_KEY
259283
blackducksca_scan_full: true # Force INTELLIGENT scan mode for all branches (uploads results to server)
260-
detect_args: ${{ inputs.ruby-app-directory != '' && format('{0} --detect.source.path={1}', inputs.blackduck-force-low-accuracy-mode == true && '--detect.excluded.detector.types=PIP --detect.accuracy.required=NONE' || '--detect.excluded.detector.types=PIP', inputs.ruby-app-directory) || (inputs.blackduck-force-low-accuracy-mode == true && '--detect.excluded.detector.types=PIP --detect.accuracy.required=NONE' || '--detect.excluded.detector.types=PIP') }}
261-
# blackducksca_scan_failure_severities: 'BLOCKER,CRITICAL'
284+
detect_args: ${{ env.DETECT_ARGS }}
285+
blackducksca_scan_failure_severities: ${{ inputs.blackduck-fail-on-high-critical && 'CRITICAL' || '' }}
262286
# ignore python per https://documentation.blackduck.com/bundle/detect/page/packagemgrs/python.html
263287

264288
# original from https://github.com/progress-platform-services/common-github-actions/blob/main/.github/workflows/examples/ci-all-sbom-main.yml

.github/workflows/trigger.yml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# stub to call common GitHub Action (GA) as part of Continuous Integration (CI) Pull Request process checks for main branch
2+
# inputs are described in the chef/common-github-actions/<GA.yml> with same name as this stub
3+
#
4+
# secrets are inherited from the calling workflow, typically SONAR_TOKEN, SONAR_HOST_URL, GH_TOKEN, AKEYLESS_JWT_ID, POLARIS_SERVER_URL and POLARIS_ACCESS_TOKEN
5+
6+
name: CI Pull Request on Main Branch
7+
8+
on:
9+
pull_request:
10+
branches: [ main, release/** ]
11+
push:
12+
branches: [ main, release/** ]
13+
14+
workflow_dispatch:
15+
16+
permissions:
17+
contents: read
18+
19+
env:
20+
STUB_VERSION: "1.0.5"
21+
22+
jobs:
23+
echo_version:
24+
name: 'Echo stub version'
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: echo version of stub and inputs
28+
run: |
29+
echo "CI main pull request stub version $STUB_VERSION"
30+
31+
read_version:
32+
name: 'Read version from Github release'
33+
runs-on: ubuntu-latest
34+
outputs:
35+
version: ${{ steps.get_version.outputs.version }}
36+
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 0
41+
fetch-tags: true
42+
43+
- name: Read github release version
44+
id: get_version
45+
run: |
46+
VERSION=$(git describe --tags `git rev-list --tags --max-count=1` | sed 's/^v//' 2>/dev/null || echo "")
47+
echo "Latest release version: $VERSION"
48+
echo "version=$VERSION" >> $GITHUB_OUTPUT
49+
50+
call-ci-main-pr-check-pipeline:
51+
needs: read_version
52+
uses: chef/common-github-actions/.github/workflows/ci-main-pull-request.yml@sandhi/test-integrations
53+
secrets: inherit
54+
permissions:
55+
id-token: write
56+
contents: read
57+
58+
with:
59+
visibility: ${{ github.event.repository.visibility }} # private, public, or internal
60+
go-private-modules: GOPRIVATE for Go private modules, default is 'github.com/progress-platform-services/*'
61+
62+
# if version specified, it takes precedence; can be a semver like 1.0.2-xyz or a tag like "latest"
63+
version: ${{ needs.read_version.outputs.version }}
64+
detect-version-source-type: 'none' # options include "none" (do not detect), "file", "github-tag" or "github-release"
65+
detect-version-source-parameter: '' # use for file name
66+
language: 'go' # Go, Ruby, Rust, JavaScript, TypeScript, Python, Java, C#, PHP, other - used for build and SonarQube language setting
67+
68+
# complexity-checks
69+
perform-complexity-checks: false
70+
# scc-output-filename: 'scc-output.txt'
71+
perform-language-linting: false # Perform language-specific linting and pre-compilation checks
72+
73+
# trufflehog secret scanning
74+
perform-trufflehog-scan: true
75+
76+
# trivy dependency and container scanning
77+
perform-trivy-scan: true
78+
trivy-fail-on-high-critical: true
79+
80+
# grype vulnerability scanning
81+
perform-grype-scan: true
82+
83+
# BlackDuck SAST (Polaris) and SCA scans (requires a build or download to do SAST)
84+
# requires these secrets: POLARIS_SERVER_URL, POLARIS_ACCESS_TOKEN
85+
perform-blackduck-polaris: true
86+
polaris-application-name: "Chef-Chef360" # one of these: Chef-Agents, Chef-Automate, Chef-Chef360, Chef-Habitat, Chef-Infrastructure-Server, Chef-Shared-Services, Chef-Other, Chef-Non-Product
87+
polaris-project-name: ${{ github.event.repository.name }}
88+
polaris-blackduck-executable: 'path/to/blackduck/binary'
89+
polaris-executable-detect-path: 'path/to/detect'
90+
polaris-coverity-build-command: 'go build'
91+
polaris-coverity-clean-command: 'go clean'
92+
polaris-fail-on-high-critical: true # Fail pipeline if HIGH or CRITICAL vulnerabilities found
93+
94+
# perform application build and unit testing, will use custom repository properties when implemented for chef-primary-application, chef-build-profile, and chef-build-language
95+
build: false
96+
# ga-build-profile: $chef-ga-build-profile
97+
# language: $chef-ga-build-language # this will be removed from stub as autodetected in central GA
98+
unit-tests: false
99+
100+
# perform SonarQube scan, with or wihout unit test coverage data
101+
# requires secrets SONAR_TOKEN and SONAR_HOST_URL (progress.sonar.com)
102+
perform-sonarqube-scan: true
103+
# perform-sonar-build: true
104+
# build-profile: 'default'
105+
# report-unit-test-coverage: true
106+
107+
perform-docker-scan: false # scan Dockerfile and built images with Docker Scout or Trivy; see repo custom properties matching "container"
108+
109+
# report to central developer dashboard
110+
report-to-atlassian-dashboard: false
111+
quality-product-name: 'Chef-360' # product name for quality reporting, like Chef360, Courier, Inspec
112+
# quality-product-name: ${{ github.event.repository.name }} # like 'Chef-360' - the product name for quality reporting, like Chef360, Courier, Inspec
113+
# quality-sonar-app-name: 'YourSonarAppName'
114+
# quality-testing-type: 'Integration' like Unit, Integration, e2e, api, Performance, Security
115+
# quality-service-name: 'YourServiceOrRepoName'
116+
# quality-junit-report: 'path/to/junit/report''
117+
118+
# perform native and Habitat packaging, publish to package repositories
119+
package-binaries: false # Package binaries (e.g., RPM, DEB, MSI, dpkg + signing + SHA)
120+
habitat-build: false # Create Habitat packages
121+
publish-packages: false # Publish packages (e.g., container from Dockerfile to ECR, go-releaser binary to releases page, omnibus to artifactory, gems, choco, homebrew, other app stores)
122+
123+
# generate and export Software Bill of Materials (SBOM) in various formats
124+
generate-sbom: true
125+
export-github-sbom: true # SPDX JSON artifact on job instance
126+
perform-blackduck-sca-scan: true # combined with generate sbom & generate github-sbom, also needs version above
127+
blackduck-project-group-name: 'Chef-Chef360' # typically one of (Chef), Chef-Agents, Chef-Automate, Chef-Chef360, Chef-Habitat, Chef-Infrastructure-Server, Chef-Shared-Services, Chef-Non-Product'
128+
blackduck-project-name: ${{ github.event.repository.name }} # BlackDuck project name, typically the repository name
129+
blackduck-fail-on-high-critical: true # Fail pipeline if HIGH or CRITICAL vulnerabilities found
130+
generate-blackduck-sbom: false # obsolete, use perform-blackduck-sca-scan instead
131+
132+
generate-msft-sbom: false
133+
license_scout: false # Run license scout for license compliance (uses .license_scout.yml)
134+
135+
# udf1: 'default' # user defined flag 1
136+
# udf2: 'default' # user defined flag 2
137+
# udf3: 'default' # user defined flag 3

0 commit comments

Comments
 (0)