Skip to content

Commit a711c73

Browse files
authored
Merge branch 'main' into peter-at-progress/hab-auth-token
2 parents c5274db + 59f6caf commit a711c73

3 files changed

Lines changed: 49 additions & 7 deletions

File tree

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @brianLoomis @sean-sype-simmons @chef/chef-infra-owners
1+
* @brianLoomis @sean-sype-simmons @chef/chef-infra-owners @chef/chef-360-tech-owners

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -894,13 +894,16 @@ jobs:
894894
with:
895895
ruby-version: '3.4'
896896
bundler-cache: false
897+
working-directory: ${{ inputs.ruby-app-directory != '' && inputs.ruby-app-directory || '.' }}
897898

898899
- name: Run bundle install to generate Gemfile.lock
899900
if: ${{ inputs.language == 'ruby' && inputs.run-bundle-install == true }}
901+
continue-on-error: true
902+
working-directory: ${{ inputs.ruby-app-directory != '' && inputs.ruby-app-directory || '.' }}
900903
run: |
901-
echo "Generating Gemfile.lock for Grype scan..."
902-
bundle install
903-
echo "Gemfile.lock generated successfully"
904+
if [ ! -f Gemfile.lock ]; then
905+
bundle install
906+
fi
904907
905908
- name: Determine severity threshold
906909
id: severity
@@ -944,10 +947,10 @@ jobs:
944947
exit 0
945948
fi
946949
947-
# Extract vulnerability counts using jq or grep fallback
950+
# Extract vulnerability counts using jq with deduplication (unique_by vulnerability ID + package + version)
948951
if command -v jq &> /dev/null; then
949-
CRITICAL_COUNT=$(jq '[.matches[]? | select(.vulnerability.severity == "Critical")] | length' "$JSON_FILE" 2>/dev/null || echo "0")
950-
HIGH_COUNT=$(jq '[.matches[]? | select(.vulnerability.severity == "High")] | length' "$JSON_FILE" 2>/dev/null || echo "0")
952+
CRITICAL_COUNT=$(jq '[.matches[]? | select(.vulnerability.severity == "Critical")] | unique_by(.vulnerability.id + .artifact.name + .artifact.version) | length' "$JSON_FILE" 2>/dev/null || echo "0")
953+
HIGH_COUNT=$(jq '[.matches[]? | select(.vulnerability.severity == "High")] | unique_by(.vulnerability.id + .artifact.name + .artifact.version) | length' "$JSON_FILE" 2>/dev/null || echo "0")
951954
else
952955
CRITICAL_COUNT=$(grep -o '"severity":"Critical"' "$JSON_FILE" | wc -l | tr -d ' ' || echo "0")
953956
HIGH_COUNT=$(grep -o '"severity":"High"' "$JSON_FILE" | wc -l | tr -d ' ' || echo "0")

.github/workflows/sbom.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,35 @@ jobs:
280280
path: ${{ inputs.ruby-app-directory != '' && format('{0}/Gemfile.lock', inputs.ruby-app-directory) || 'Gemfile.lock' }}
281281
name: ${{ github.event.repository.name }}-Gemfile-lock.txt
282282

283+
- name: Set up Go (required for Go workspace vendoring)
284+
if: ${{ hashFiles('go.work') != '' }}
285+
uses: actions/setup-go@v5
286+
with:
287+
go-version: 'stable'
288+
289+
- name: Prepare Go workspace for BlackDuck scanning
290+
if: ${{ hashFiles('go.work') != '' }}
291+
run: |
292+
# Extract all relative module paths from go.work.
293+
# grep -oE handles both single-line (use ./path) and block (use (\n ./path\n)) syntax
294+
# because it matches any './' sequence anywhere in the file.
295+
GO_WORK_DEPTH=$(grep -oE '\./[^[:space:]"/)]+' go.work \
296+
| awk -F'/' '{print NF-1}' \
297+
| sort -rn | head -1)
298+
# Default to 1 if all modules sit at root or grep returned nothing
299+
[[ -z "$GO_WORK_DEPTH" || "$GO_WORK_DEPTH" -le 0 ]] && GO_WORK_DEPTH=1
300+
echo "GO_WORK_DETECTOR_DEPTH=${GO_WORK_DEPTH}" >> "$GITHUB_ENV"
301+
echo "Go workspace detector search depth: ${GO_WORK_DEPTH}"
302+
# Vendor all workspace dependencies (requires Go 1.22+).
303+
# If this fails (e.g. private module network issue) Detect will still run
304+
# with the correct search depth and resolve modules via the Go toolchain.
305+
if go work vendor; then
306+
echo "GOFLAGS=-mod=vendor" >> "$GITHUB_ENV"
307+
echo "Successfully vendored Go workspace dependencies"
308+
else
309+
echo "go work vendor did not complete; Detect will resolve modules via Go toolchain"
310+
fi
311+
283312
- name: Construct BlackDuck detect arguments
284313
id: detect-args
285314
run: |
@@ -303,6 +332,16 @@ jobs:
303332
# RAPID scan for PRs - automatically compares against baseline from target branch
304333
DETECT_ARGS="${DETECT_ARGS} --detect.blackduck.scan.mode=RAPID"
305334
fi
335+
336+
# If repo uses a Go workspace, increase detector search depth so Detect finds
337+
# go.mod files inside module subdirectories (default depth 0 = root only = only Git found).
338+
# Also set accuracy.required=NONE: Detect's default HIGH accuracy check fails for multi-module
339+
# Go workspaces (FAILURE_ACCURACY_NOT_MET / exit 15) because it can't fully resolve the graph
340+
# via `go list` across workspace modules. Vendor mode resolves deps; accuracy=NONE lets it proceed.
341+
if [[ -f "go.work" ]]; then
342+
DETECT_ARGS="${DETECT_ARGS} --detect.detector.search.depth=${{ env.GO_WORK_DETECTOR_DEPTH }}"
343+
DETECT_ARGS="${DETECT_ARGS} --detect.accuracy.required=NONE"
344+
fi
306345
307346
echo "DETECT_ARGS=${DETECT_ARGS}" >> $GITHUB_ENV
308347
echo "Constructed detect_args: ${DETECT_ARGS}"

0 commit comments

Comments
 (0)