Skip to content

Commit d76454f

Browse files
committed
ci(owasp): bun monorepo support — setup via local action, bun install, create per-package node_modules symlinks so ODC sees deps; enable experimental analyzers; upload reports
1 parent 2facd0b commit d76454f

1 file changed

Lines changed: 32 additions & 45 deletions

File tree

.github/workflows/owasp-scan.yml

Lines changed: 32 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,66 @@
11
name: owasp-dependency-check
22
on:
3-
workflow_dispatch:
3+
pull_request:
44
release:
55
types: [published]
6-
pull_request:
7-
branches: [dev]
8-
schedule:
9-
- cron: "0 5 * * 1" # weekly, 05:00 UTC Mondays
6+
workflow_dispatch:
107

118
permissions:
129
contents: read
10+
security-events: write
1311

1412
jobs:
1513
depcheck:
1614
runs-on: ubuntu-latest
17-
permissions:
18-
contents: read
19-
security-events: write
20-
actions: read
2115
steps:
22-
- uses: actions/checkout@v4
16+
- name: Checkout (release tag)
17+
if: github.event_name == 'release'
18+
uses: actions/checkout@v4
19+
with:
20+
ref: ${{ github.event.release.tag_name }}
21+
- name: Checkout (PR/default)
22+
if: github.event_name != 'release'
23+
uses: actions/checkout@v4
2324

24-
- name: Detect JS tooling (bun / node)
25-
id: meta
26-
run: |
27-
set -e
28-
has_file() { git ls-files -z | tr '\0' '\n' | grep -qE "$1" && echo true || echo false; }
29-
echo "has_bun=$(has_file '(^|/)bun\.lockb$')" >> "$GITHUB_OUTPUT"
30-
echo "has_node=$(has_file '(^|/)package\.json$')" >> "$GITHUB_OUTPUT"
31-
echo "has_pnpm_lock=$(has_file '(^|/)pnpm-lock\.yaml$')" >> "$GITHUB_OUTPUT"
32-
echo "has_yarn_lock=$(has_file '(^|/)yarn\.lock$')" >> "$GITHUB_OUTPUT"
33-
echo "has_package_lock=$(has_file '(^|/)package-lock\.json$')" >> "$GITHUB_OUTPUT"
25+
- name: Setup Bun (repo action)
26+
uses: ./.github/actions/setup-bun
3427

35-
- name: Setup Bun (if bun.lockb present)
36-
if: steps.meta.outputs.has_bun == 'true'
37-
run: |
38-
curl -fsSL https://bun.sh/install | bash
39-
echo "$HOME/.bun/bin" >> $GITHUB_PATH
40-
bun --version
28+
- name: Install workspace deps (Bun)
29+
run: bun install --frozen-lockfile || bun install
4130

42-
- name: Install JS deps for analysis
43-
if: steps.meta.outputs.has_bun == 'true' || steps.meta.outputs.has_node == 'true'
31+
- name: Ensure per-package node_modules (symlink to root)
4432
run: |
4533
set -e
46-
if [ "${{ steps.meta.outputs.has_bun }}" = "true" ]; then
47-
bun install --frozen-lockfile || bun install
48-
else
49-
sudo apt-get update -y
50-
sudo apt-get install -y nodejs npm || true
51-
npm i -g corepack || true
52-
corepack enable || true
53-
if [ "${{ steps.meta.outputs.has_pnpm_lock }}" = "true" ]; then corepack prepare pnpm@9 --activate || true; pnpm install --frozen-lockfile || pnpm install || true; fi
54-
if [ "${{ steps.meta.outputs.has_package_lock }}" = "true" ]; then npm ci || npm i || true; fi
55-
if [ "${{ steps.meta.outputs.has_yarn_lock }}" = "true" ]; then corepack prepare yarn@stable --activate || true; yarn install --frozen-lockfile || yarn install || true; fi
56-
fi
34+
root_nm="$(pwd)/node_modules"
35+
if [ ! -d "$root_nm" ]; then echo 'No root node_modules after bun install' >&2; exit 1; fi
36+
# create a node_modules symlink in every workspace package that lacks one
37+
git ls-files -z | tr '\0' '\n' | grep -E '(^|/)package.json$' | while read -r pj; do
38+
pkgdir="$(dirname "$pj")"
39+
[ "$pkgdir" = ".github/actions/setup-bun" ] && continue
40+
if [ ! -d "$pkgdir/node_modules" ]; then
41+
echo "linking $pkgdir/node_modules -> $root_nm"
42+
ln -s "$root_nm" "$pkgdir/node_modules" || true
43+
fi
44+
done
5745
5846
- name: Cache dependency-check data
5947
uses: actions/cache@v4
6048
with:
6149
path: ~/.m2/repository/org/owasp/dependency-check-data/
62-
key: depcheck-data-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
50+
key: depcheck-data-${{ runner.os }}-v2
6351
restore-keys: |
6452
depcheck-data-${{ runner.os }}-
6553
6654
- name: Run OWASP Dependency-Check
6755
uses: dependency-check/[email protected]
68-
env:
69-
JAVA_HOME: /opt/jdk
7056
with:
71-
project: "OpenCode"
72-
path: "."
57+
project: OpenCode
58+
path: .
7359
format: ALL
60+
args: --enableExperimental
7461

7562
- name: Upload reports
7663
uses: actions/upload-artifact@v4
7764
with:
7865
name: owasp-depcheck-report
79-
path: reports
66+
path: reports/**

0 commit comments

Comments
 (0)