Skip to content

Commit 58ae757

Browse files
committed
fix: update example workflows to pass in this repo
- Basic Scan: ignore examples/ test fixtures - SBOM Scan: add npm ci before SBOM generation - Container Scan: add Dockerfile and build step - Manual CLI: add --ignore-path examples - Auto-Fix: add --ignore-path examples
1 parent e002cf2 commit 58ae757

2 files changed

Lines changed: 37 additions & 4 deletions

File tree

.github/workflows/example-usage.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
with:
2424
path: '.'
2525
fail-on-vuln: true
26+
ignore-paths: 'examples/**' # Ignore test fixtures in this repo
2627

2728
# ===========================================
2829
# Full Featured - All options enabled
@@ -57,7 +58,15 @@ jobs:
5758
steps:
5859
- uses: actions/checkout@v4
5960

60-
- name: Generate SBOM (if needed)
61+
- name: Setup Node.js
62+
uses: actions/setup-node@v4
63+
with:
64+
node-version: '20'
65+
66+
- name: Install dependencies
67+
run: npm ci
68+
69+
- name: Generate SBOM
6170
run: npx @cyclonedx/cyclonedx-npm --output-file sbom.json
6271

6372
- name: Scan SBOM for vulnerabilities
@@ -76,6 +85,14 @@ jobs:
7685
steps:
7786
- uses: actions/checkout@v4
7887

88+
- name: Setup Node.js
89+
uses: actions/setup-node@v4
90+
with:
91+
node-version: '20'
92+
93+
- name: Install and build
94+
run: npm ci && npm run build
95+
7996
- name: Build Docker image
8097
run: docker build -t myapp:latest .
8198

@@ -107,7 +124,7 @@ jobs:
107124
run: npm install -g react2shell-guard@latest
108125

109126
- name: Run scan with SARIF output
110-
run: react2shell-guard . --sarif > results.sarif
127+
run: react2shell-guard . --sarif --ignore-path examples > results.sarif
111128
continue-on-error: true
112129

113130
- name: Upload SARIF to GitHub Security
@@ -117,7 +134,7 @@ jobs:
117134
category: react2shell-guard
118135

119136
- name: Fail if vulnerable
120-
run: react2shell-guard .
137+
run: react2shell-guard . --ignore-path examples
121138

122139
# ===========================================
123140
# Conditional Fix PR - Auto-create fix PRs
@@ -144,7 +161,7 @@ jobs:
144161
- name: Check for vulnerabilities
145162
id: scan
146163
run: |
147-
if react2shell-guard . --json | grep -q '"vulnerable": true'; then
164+
if react2shell-guard . --json --ignore-path examples | grep -q '"vulnerable": true'; then
148165
echo "vulnerable=true" >> $GITHUB_OUTPUT
149166
else
150167
echo "vulnerable=false" >> $GITHUB_OUTPUT

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Dockerfile for react2shell-guard container scanning example
2+
FROM node:20-alpine
3+
4+
WORKDIR /app
5+
6+
# Copy package files
7+
COPY package*.json ./
8+
9+
# Install dependencies
10+
RUN npm ci --only=production
11+
12+
# Copy source
13+
COPY dist/ ./dist/
14+
15+
# Set entrypoint
16+
ENTRYPOINT ["node", "dist/cli/index.js"]

0 commit comments

Comments
 (0)