Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3ea7bf5
Install basic dependencies
ChaohuiLi0321 Sep 5, 2025
60c0fd0
Add temporary file ignore filter settings
ChaohuiLi0321 Sep 5, 2025
e137e6e
Create the plugin package initialization file plugins/base_plugin.py …
ChaohuiLi0321 Sep 5, 2025
1c9a181
Create the core engine core/scanner_engine.py
ChaohuiLi0321 Sep 5, 2025
9367023
Create a configuration management system config/scanner_config.yaml
ChaohuiLi0321 Sep 5, 2025
714d083
Configuration Manager - handles loading and validation of YAML config…
ChaohuiLi0321 Sep 5, 2025
b3fe677
NutriHelp Security Scanner V2.0 - Main Entry Point: scanner_v2.py, Mo…
ChaohuiLi0321 Sep 5, 2025
f5fde8d
Phase 1 Quick verification script——Verify that the modular infrastruc…
ChaohuiLi0321 Sep 5, 2025
fe7e9c9
Create a file named test_basic_functionality.py to test the basic fun…
ChaohuiLi0321 Sep 5, 2025
7a16146
Create a JWT missing protection plug-in plugins/jwt_security/jwt_miss…
ChaohuiLi0321 Sep 5, 2025
d0a8f7f
Create a JWT configuration verification plug-in plugins/jwt_security/…
ChaohuiLi0321 Sep 5, 2025
2b66c52
Generate HTML report, view HTML report
ChaohuiLi0321 Sep 5, 2025
f637efd
Temporarily add a Scanner to http://localhost/api-docs/
ChaohuiLi0321 Sep 6, 2025
f0995aa
Integrate Vulnerability_Scanner_V2.0 into Swagger UI, with the URL: h…
ChaohuiLi0321 Sep 6, 2025
19bad1e
resolve conflicts and commit
ChaohuiLi0321 Sep 6, 2025
1a7925e
Change Comment
ChaohuiLi0321 Sep 6, 2025
45c8264
Update comment
ChaohuiLi0321 Sep 6, 2025
a49416e
Update - Ensure both command scanning and Swagger UI scanning are wor…
ChaohuiLi0321 Sep 6, 2025
37015cc
Update - Ensured that the report generated by command scan is consist…
ChaohuiLi0321 Sep 6, 2025
ca3e920
Use the command "python scanner_v2.py --target ../ --format html --ou…
ChaohuiLi0321 Sep 6, 2025
6375f5b
Use Swagger UI: http://localhost:8001/scanner/docs to test and genera…
ChaohuiLi0321 Sep 6, 2025
702082a
Integrate Vulnerability_Scanner_V2.0 into the Swagger UI: http://loca…
ChaohuiLi0321 Sep 7, 2025
7c28bc8
Update security report
ChaohuiLi0321 Sep 7, 2025
ecfe6fe
Add standard password or related security testing mechanisms and inte…
ChaohuiLi0321 Sep 7, 2025
ac49ba6
update comment
ChaohuiLi0321 Sep 7, 2025
3788ba0
include general_security in GET /api/scanner/plugins
ChaohuiLi0321 Sep 12, 2025
3e9f647
chore: update .gitignore to ignore venv and pytest cache
ChaohuiLi0321 Sep 12, 2025
4b7fc1e
Add general security rules and enhance testing framework
ChaohuiLi0321 Sep 12, 2025
97d3d1d
Add Python executable resolution and setup script for virtual environ…
ChaohuiLi0321 Sep 12, 2025
3b9bbd9
Merge branch 'master' of https://github.com/Gopher-Industries/Nutrihe…
ChaohuiLi0321 Sep 12, 2025
c1498cd
Add migration task document for Vulnerability Scanner CI from V1.4 to…
ChaohuiLi0321 Sep 13, 2025
07359f4
Merge remote-tracking branch 'upstream/master' into Vulnerability_Sca…
ChaohuiLi0321 Sep 16, 2025
ba07154
Add v8-to-istanbul dependency to package.json and package-lock.json
ChaohuiLi0321 Sep 16, 2025
22ec9c4
Enhance API documentation, and integrate swagger-jsdoc for dynamic do…
ChaohuiLi0321 Sep 16, 2025
0662947
Add jest configuration for test matching in package.json
ChaohuiLi0321 Sep 16, 2025
230e742
Add .gitignore entries for vulnerability scanner reports and update s…
ChaohuiLi0321 Sep 17, 2025
1bd8b52
Merge remote-tracking branch 'upstream/master' into Vulnerability_Sca…
ChaohuiLi0321 Sep 18, 2025
15b2719
Add manual vulnerability scan workflow and update documentation
ChaohuiLi0321 Sep 18, 2025
a5ba1ea
Merge remote-tracking branch 'upstream/master' into Vulnerability_Sca…
ChaohuiLi0321 Sep 25, 2025
a43df7c
Update package-lock.json due to “npm install”
ChaohuiLi0321 Sep 25, 2025
e0e8dab
Merge remote-tracking branch 'upstream/master' into Vulnerability_Sca…
ChaohuiLi0321 Sep 25, 2025
c03ed8c
feat: enhance scanner setup and validation process
ChaohuiLi0321 Sep 26, 2025
8ede8a0
Merge pull request #6 from Gopher-Industries/master
ChaohuiLi0321 Sep 26, 2025
690a065
refactor: remove Python setup and V2 scanner integration from securit…
ChaohuiLi0321 Sep 26, 2025
7450193
refactor: remove unused API files and dependencies from the project
ChaohuiLi0321 Sep 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/security-assessment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
- name: Install dependencies
run: npm ci


- name: Start server in background
run: |
npm start &
Expand Down Expand Up @@ -84,7 +85,7 @@ jobs:
run: |
echo "Starting security assessment..."

# Run the assessment
# Run the assessment (original behavior without full V2 scan integration)
node security/runAssessment.js

# Find the latest generated JSON report
Expand Down
102 changes: 102 additions & 0 deletions .github/workflows/vulnerability-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Manual Vulnerability & Test Scan

on:
workflow_dispatch:
inputs:
run_tests:
description: 'Set to true to run unit tests (may require DB). Default: false'
required: false
default: 'false'
fail_on_critical:
description: 'If true, the job will fail when the vulnerability_report.json contains CRITICAL issues. Default: false'
required: false
default: 'false'

env:
NODE_VERSION: '20'

jobs:
vulnerability-scan:
name: Run vulnerability scans and tests (manual)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: package-lock.json

- name: Install npm dependencies
run: npm ci
- name: Setup Python 3
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Prepare Scanner Environment (V2)
run: |
node scripts/prepareScanner.js
if [ ! -d Vulnerability_Tool_V2/venv ]; then
echo "Scanner venv not created (Python missing or script skipped). Using system python.";
fi

- name: Run unit tests (mocha)
if: ${{ github.event.inputs.run_tests == 'true' }}
run: |
echo "run_tests was set to true — running unit tests"
if npm run | grep -q "test:unit"; then
npm run test:unit
elif npm run | grep -q "test:rce"; then
npm run test:rce || true
else
echo "No test script found (test:unit/test:rce). Skipping tests.";
fi

- name: Run npm audit and save JSON
run: |
npm audit --json > npm_audit.json || true

- name: Run Vulnerability_Tool_V2 - JSON output
run: |
PYEXEC="python3"
if [ -f Vulnerability_Tool_V2/venv/bin/python ]; then PYEXEC="Vulnerability_Tool_V2/venv/bin/python"; fi
if [ -f Vulnerability_Tool_V2/scanner_v2.py ]; then
$PYEXEC Vulnerability_Tool_V2/scanner_v2.py --target . --format json --output vulnerability_report.json || true
else
echo "Vulnerability_Tool_V2/scanner_v2.py not found" > vulnerability_report.json
fi

- name: Run Vulnerability_Tool_V2 - HTML output
run: |
PYEXEC="python3"
if [ -f Vulnerability_Tool_V2/venv/bin/python ]; then PYEXEC="Vulnerability_Tool_V2/venv/bin/python"; fi
if [ -f Vulnerability_Tool_V2/scanner_v2.py ]; then
$PYEXEC Vulnerability_Tool_V2/scanner_v2.py --target . --format html --output vulnerability_report.html || true
else
echo "Vulnerability_Tool_V2/scanner_v2.py not found" > vulnerability_report.html
fi

- name: Collect generated reports
run: |
ls -la || true
echo "Collected artifacts:"; ls -la *.html *.txt npm_audit.json || true

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: vulnerability-scan-reports
path: |
vulnerability_report.json
vulnerability_report.html
vulnerability_tool_report.txt
npm_audit.json

- name: Fail on critical findings (optional)
if: ${{ github.event.inputs.fail_on_critical == 'true' }}
run: |
echo "Checking vulnerability_report.json for CRITICAL findings..."
python3 scripts/ci_check_vuln.py
31 changes: 30 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,33 @@ __pycache__/

# Ignore generated security assessment reports
/security/reports/
```
```

# Python virtual environments
venv/
.env/
__pycache__/
*.pyc

# Local virtualenv created during testing
.venv/

# pytest cache
.pytest_cache/

# pipenv
Pipfile.lock

# macOS system files
.DS_Store

# VS Code settings
.vscode/

# Logs and temp files
*.log
*.tmp

# Vulnerability Scanner V2 reports - generated artifacts
Vulnerability_Tool_V2/reports/
Vulnerability_Tool_V2/reports/*
43 changes: 37 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ git clone https://github.com/Gopher-Industries/Nutrihelp-api
```bash
cd Nutrihelp-api
```
4. Install the required dependencies (including python dependencies):
4. Install dependencies (runs automated bootstrap via npm postinstall):
```bash
npm install
pip install -r requirements.txt
npm install node-fetch
npm install --save-dev jest supertest
```
5. Contact a project maintainer to get the `.env` file that contains the necessary environment variables and place it in the root of the project directory.
6. Start the server:
What happens automatically:
- Node dependencies installed
- Environment bootstrap runs (`scripts/bootstrap.js --mode=postinstall`)
- If no `.env` exists a minimal placeholder is generated (internal team must replace with real values)
- Vulnerability scanner virtual environment prepared if Python 3 is available
- Environment validation runs (warnings only in postinstall mode)

3. Start the server:
```bash
npm start
```
Expand Down Expand Up @@ -57,3 +60,31 @@ npx jest .\test\healthNews.test.js

/\ Please refer to the "PatchNotes_VersionControl" file for /\
/\ recent updates and changes made through each version. /\


## CI: Manual Vulnerability & Test Scan (V2 Aligned)

This repository includes a manual GitHub Actions workflow that runs the Vulnerability Scanner (V2) and optional tests.

How to run
- Open the repository on GitHub and go to the Actions tab.
- Select the workflow named `Manual Vulnerability & Test Scan`.
- Click the `Run workflow` button.

Inputs
- `run_tests` (default: `false`) — set to `true` to run unit tests (`npm run test:unit`). Tests may require a database or other services; use with caution.
- `fail_on_critical` (default: `false`) — set to `true` to make the job fail when the scanner JSON report contains one or more `CRITICAL` findings.

Artifacts
- `vulnerability-scan-reports` (artifact bundle) — contains:
- `vulnerability_report.json` — machine-readable scan results
- `vulnerability_report.html` — human-friendly HTML report (if HTML rendering succeeds)
- `vulnerability_tool_report.txt` — legacy/auxiliary scanner output (if generated)
- `npm_audit.json` — result of `npm audit --json`

Notes and recommendations
- The scanner excludes internal tool directories and common noisy paths (for example `Vulnerability_Tool_V2`, legacy `Vulnerability_Tool`, `node_modules`, test caches).
- If you enable `run_tests`, ensure the required environment (DB, credentials) is available to avoid noisy failures.
- Use `fail_on_critical=true` for gating releases or running stricter checks in CI; keep it `false` for quick, informational scans.


82 changes: 82 additions & 0 deletions VULN_CI_MIGRATION_TASK.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Vulnerability Scanner CI Migration Task (V1.4 -> V2.0)

This document is a handover for the next developer to migrate `.github/workflows/security.yml` from invoking
`Vulnerability_Tool/Vulnerability_Scanner_V1.4.py` to using `Vulnerability_Tool_V2/scanner_v2.py`.

Goal
- Run the V2.0 scanner in GitHub Actions to produce human-readable HTML (recommended) and/or JSON reports and
upload them as artifacts.
- Keep reproducibility by preferring the repository-provided venv setup (`setup_venv.sh`) and consider caching to
reduce CI time.

Acceptance criteria
1. Actions produces a report file (HTML or JSON) under `Vulnerability_Tool_V2/reports/` and uploads it as an artifact.
Suggested filename: `security_report_${{ github.sha }}.html`.
2. Decide and document whether CRITICAL findings should fail the CI job (i.e. block PRs) and reflect that decision in
the workflow (comments or parameters).
3. Document performance / caching recommendations (for example, use `actions/cache` to cache pip wheels or pip cache
directories).

Key information
- V2 CLI entry: `Vulnerability_Tool_V2/scanner_v2.py`. Required argument: `--target` (target directory). Optional flags:
`--format` (json|html|summary), `--output` (write output file), and `--verbose`.
- Recommended: use the repo script to create a virtual environment: `Vulnerability_Tool_V2/setup_venv.sh` which will
create `Vulnerability_Tool_V2/venv` and install dependencies from `requirements.txt`.

Recommended implementation (preferred: use repository venv)

Replace the existing step that used to run V1 against each changed file with the snippet below. Adjust to your job
context and branching strategy as needed.

```yaml
# ...existing job steps...
- name: Set up Python venv for scanner
run: |
cd Vulnerability_Tool_V2
chmod +x ./setup_venv.sh || true
./setup_venv.sh

- name: Run Vulnerability_Tool_V2 scanner
run: |
SCAN_OUTPUT=Vulnerability_Tool_V2/reports/security_report_${{ github.sha }}.html
Vulnerability_Tool_V2/venv/bin/python Vulnerability_Tool_V2/scanner_v2.py --target . --format html --output "$SCAN_OUTPUT" --verbose
ls -la Vulnerability_Tool_V2/reports || true

- name: Upload scanner report
uses: actions/upload-artifact@v4
with:
name: security-scan-report
path: Vulnerability_Tool_V2/reports/security_report_${{ github.sha }}.html
```

Minimal alternative (do not create venv; use system Python)

```yaml
- name: Install scanner deps (system python)
run: |
python3 -m pip install --upgrade pip
pip install -r Vulnerability_Tool_V2/requirements.txt

- name: Run scanner (system python)
run: |
python3 Vulnerability_Tool_V2/scanner_v2.py --target . --format html --output Vulnerability_Tool_V2/reports/security_report_${{ github.sha }}.html
```

Notes and optimizations
- Caching: use `actions/cache` to speed up dependency installation (cache pip wheel files or pip cache directories).
- Exit code behavior: V2 will return a non-zero exit code if CRITICAL issues are found (the CLI returns 1 on
critical findings). If you want PRs to be blocked on criticals, keep this behavior. Otherwise, use
`continue-on-error: true` for the scanner step or capture the exit code and treat it as a warning while still
uploading the report.
- Scan scope: V1 was scanning changed files one-by-one. V2 is intended to scan directories. If you want to scan only
changed files, you can copy changed files to a temporary directory in the job and use `--target` to point to that
temporary directory, or adapt scanner configuration to accept a file-list.

Additional resources
- Scanner entrypoint: `Vulnerability_Tool_V2/scanner_v2.py`
- Requirements: `Vulnerability_Tool_V2/requirements.txt`
- venv setup script: `Vulnerability_Tool_V2/setup_venv.sh`

Handover
Assign this task to the person responsible for CI and link this document in the issue/PR. Include the acceptance
criteria in the PR description when implementing the change.
4 changes: 4 additions & 0 deletions Vulnerability_Tool_V2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore generated reports from the scanner
reports/
# Keep temp json files used during rendering
tmp_*.json
Loading
Loading