@@ -294,6 +294,45 @@ jobs:
294294 with :
295295 go-version : ' stable'
296296
297+ - name : Resolve Erlang/HEX dependencies for BlackDuck scanning
298+ if : inputs.language == 'erlang' || inputs.language == 'ruby-erlang'
299+ continue-on-error : true
300+ run : |
301+ # BlackDuck Detect needs rebar.lock files to accurately detect HEX dependencies.
302+ # Run `rebar3 get-deps` in every directory containing a rebar.config to generate
303+ # the lock files that the HEX detector relies on.
304+ echo "Resolving Erlang/HEX dependencies via rebar3..."
305+ find . -name "rebar.config" -not -path "*/.bridge/*" -not -path "*/node_modules/*" | while read cfg; do
306+ dir=$(dirname "$cfg")
307+ echo "Running rebar3 get-deps in: $dir"
308+ (cd "$dir" && rebar3 get-deps) || echo "rebar3 get-deps failed in $dir (continuing)"
309+ done
310+ echo "Erlang dependency resolution complete"
311+
312+ - name : Resolve Ruby dependencies for BlackDuck scanning
313+ if : ${{ inputs.run-bundle-install != true && (inputs.language == 'ruby' || inputs.language == 'ruby-erlang') }}
314+ continue-on-error : true
315+ run : |
316+ # BlackDuck Detect needs Gemfile.lock files to accurately detect RubyGems dependencies.
317+ # Repos like chef-server have multiple Gemfiles across subdirectories at varying depths.
318+ # Find every Gemfile that lacks a corresponding Gemfile.lock and run bundle install in
319+ # that directory so Detect's Bundler detector can pick up all Ruby dependency trees.
320+ BASE_DIR="${{ inputs.ruby-app-directory != '' && inputs.ruby-app-directory || '.' }}"
321+ echo "Scanning for Gemfiles under: $BASE_DIR"
322+ find "$BASE_DIR" -name "Gemfile" -not -name "*.lock" \
323+ -not -path "*/.bridge/*" -not -path "*/node_modules/*" -not -path "*/.git/*" \
324+ | while read gemfile; do
325+ dir=$(dirname "$gemfile")
326+ if [ ! -f "$dir/Gemfile.lock" ]; then
327+ echo "No Gemfile.lock in $dir — running bundle install..."
328+ (cd "$dir" && bundle install --without development test) \
329+ || echo "bundle install failed in $dir (continuing)"
330+ else
331+ echo "Gemfile.lock already exists in $dir — skipping"
332+ fi
333+ done
334+ echo "Ruby dependency resolution complete"
335+
297336 - name : Prepare Go workspace for BlackDuck scanning
298337 if : ${{ hashFiles('go.work') != '' }}
299338 run : |
@@ -350,6 +389,14 @@ jobs:
350389 DETECT_ARGS="${DETECT_ARGS} --detect.detector.search.depth=${{ env.GO_WORK_DETECTOR_DEPTH }}"
351390 DETECT_ARGS="${DETECT_ARGS} --detect.accuracy.required=NONE"
352391 fi
392+
393+ # For Erlang and ruby-erlang repos, rebar.config/rebar.lock files are often in
394+ # subdirectories. Default detector search depth is 0 (root only), which means only
395+ # the Git detector runs and HEX dependencies are never scanned.
396+ # Increase depth to 5 to find rebar.config/rebar.lock in nested app directories.
397+ if [[ "${{ inputs.language }}" == "erlang" || "${{ inputs.language }}" == "ruby-erlang" ]]; then
398+ DETECT_ARGS="${DETECT_ARGS} --detect.detector.search.depth=5"
399+ fi
353400
354401 echo "DETECT_ARGS=${DETECT_ARGS}" >> $GITHUB_ENV
355402 echo "Constructed detect_args: ${DETECT_ARGS}"
0 commit comments