Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

ci: validate complete Bandit scans at medium severity (#7625)

LearningCircuit929268f88c91
diff --git a/.file-whitelist.txt b/.file-whitelist.txt
index 95b3caf5c5..8ed7c5289e 100644
--- a/.file-whitelist.txt
+++ b/.file-whitelist.txt
@@ -69,6 +69,7 @@
# ---------------------------------------------------------------------------
^requirements/.*\.txt$
# pip-compile inputs for the focused CI workflows.
+^requirements/bandit\.in$
^requirements/ci-health\.in$
^requirements/gitleaks-tests\.in$
^requirements/semgrep\.in$
diff --git a/.github/SECURITY_ALERTS.md b/.github/SECURITY_ALERTS.md
index 83610c5772..999954682f 100644
--- a/.github/SECURITY_ALERTS.md
+++ b/.github/SECURITY_ALERTS.md
@@ -422,3 +422,35 @@ cannot be tracked in version-controlled files.
- [Gitleaks Configuration](workflows/gitleaks.yml)
- [XSS Protection Module](../src/local_deep_research/web/static/js/security/xss-protection.js)
- [SSRF Validator](../src/local_deep_research/security/ssrf_validator.py)
+
+## Bandit medium-severity context
+
+Bandit reports medium and high findings. Its native reports must be complete and
+agree before upload; the release gate continues to evaluate their effective
+SARIF severity. Reviewed source statements use rule-specific `nosec` annotations:
+
+- B608: one LLM prompt is not SQL. Migration queries interpolate only fixed table
+ or column identifiers; setting values and row identifiers remain parameters.
+- B104: address classifiers and URL builders recognize or replace bind-all
+ spellings. The frozen migration setting preserves the packaged server default.
+- B113: the safe request wrappers supply the caller-selected timeout in `kwargs`
+ before transport and preserve it across validated redirect hops.
+- B704: production asset URLs are verified and URL-quoted, diagnostic messages
+ and the banner use module-owned text, and development entry names come from
+ trusted template literals.
+- B615: two calls are local benchmark-registry operations. The actual dataset
+ loader consumes operator-selected benchmark records with `datasets>=5.0.1,<6`,
+ which does not support remote dataset loading scripts. These data sources are
+ intentionally not treated as pinned model weights; benchmark data provenance
+ and reproducibility remain separate concerns.
+
+Annotations apply only to their statements. Changes to these inputs, timeout
+forwarding, template callers or the dataset-loader dependency floor require
+renewed review. Native scanner fixtures verify that every reviewed rule family
+still detects unsafe examples and that an annotation leaves other rules on the
+same call and unannotated calls in the same function active.
+
+`test_bandit_reviewed_context.py` also guards the reviewed dataset dependency
+floor and rejects dynamic Vite entry arguments in templates. Changes to the
+annotated modules, dependency declarations or templates exercise the Bandit PR
+workflow, while its source scan remains part of release qualification.
diff --git a/.github/release-scan-policy.json b/.github/release-scan-policy.json
index 2500f2cdb7..54fb1c7dcd 100644
--- a/.github/release-scan-policy.json
+++ b/.github/release-scan-policy.json
@@ -2,7 +2,7 @@
"/language:python": "analyze",
"/language:javascript-typescript": "analyze",
"semgrep-security": "semgrep-scan",
- "bandit": "security-tests",
+ "bandit": "bandit-scan",
"bearer-security": "bearer-scan",
"devskim": "devskim-scan",
"container-security": "trivy-scan",
diff --git a/.github/scripts/check_bandit_report.py b/.github/scripts/check_bandit_report.py
new file mode 100644
index 0000000000..e9ff49f234
--- /dev/null
+++ b/.github/scripts/check_bandit_report.py
@@ -0,0 +1,215 @@
+"""Reject incomplete Bandit scans before uploading their native SARIF."""
+
+import argparse
+from collections import Counter
+import json
+import os
+from pathlib import Path
+import re
+import sys
+from urllib.parse import unquote, urlsplit
+
+
+LEVELS = {"HIGH": "error", "MEDIUM": "warning"}
+
+
+def source_path(value, *, is_uri=False):
+ if not isinstance(value, str) or not value:
+ raise ValueError("Bandit omitted a source path")
+ if is_uri:
+ parsed = urlsplit(value)
+ if (
+ parsed.scheme not in {"", "file"}
+ or parsed.netloc
+ or parsed.query
+ or parsed.fragment
+ ):
+ raise ValueError("Bandit reported a non-local source URI")
+ value = unquote(parsed.path)
+ return Path(value).resolve()
+
+
+def validate_metrics(metrics, expected):
+ if not isinstance(metrics, dict):
+ raise ValueError("Bandit omitted scan metrics")
+ total = metrics.get("_totals")
+ if (
+ not isinstance(total, dict)
+ or type(total.get("loc")) is not int
+ or total["loc"] <= 0
+ ):
+ raise ValueError("Bandit did not scan any source code")
+ scanned = set()
+ for filename, row in metrics.items():
+ if filename == "_totals":
+ continue
+ if (
+ not isinstance(row, dict)
+ or type(row.get("loc")) is not int
+ or row["loc"] < 0
+ ):
+ raise ValueError("Bandit reported malformed per-file metrics")
+ path = source_path(filename)
+ if path in scanned:
+ raise ValueError("Bandit reported duplicate file metrics")
+ scanned.add(path)
+ if not expected or scanned != expected:
+ raise ValueError("Bandit scan does not cover every target Python file")
+
+
+def finding_key(rule, filename, line, severity, expected, *, is_uri=False):
+ if not isinstance(rule, str) or not re.fullmatch(r"B[0-9]{3}", rule):
+ raise ValueError("Bandit finding has no recognized rule ID")
+ if severity not in LEVELS:
+ raise ValueError("Bandit must report medium and high findings")
+ if type(line) is not int or line < 1:
+ raise ValueError("Bandit finding has no valid source line")
+ path = source_path(filename, is_uri=is_uri)
+ if path not in expected:
+ raise ValueError("Bandit finding refers to an unscanned file")
+ return rule, path, line, severity
+
+
+def validate(report, sarif, source):
+ expected = {path.resolve() for path in source.rglob("*.py")}
+ if not isinstance(report, dict) or report.get("errors") != []:
+ raise ValueError("Bandit reported scan errors or omitted error status")
+ validate_metrics(report.get("metrics"), expected)
+ results = report.get("results")
+ if not isinstance(results, list):
+ raise ValueError("Bandit JSON findings are missing or malformed")
+ json_findings = Counter()
+ for result in results:
+ if not isinstance(result, dict):
+ raise ValueError("Bandit JSON finding is malformed")
+ lines = result.get("line_range")
+ if (
+ not isinstance(lines, list)
+ or not lines
+ or any(type(line) is not int or line < 1 for line in lines)
+ or result.get("line_number") not in lines
+ ):
+ raise ValueError("Bandit finding has no valid source range")
+ json_findings[
+ finding_key(
+ result.get("test_id"),
+ result.get("filename"),
+ lines[0],
+ result.get("issue_severity"),
+ expected,
+ )
+ ] += 1
+ if not isinstance(sarif, dict) or sarif.get("version") != "2.1.0":
+ raise ValueError("Expected native Bandit SARIF 2.1.0")
+ runs = sarif.get("runs")
+ if not isinstance(runs, list) or len(runs) != 1:
+ raise ValueError("Expected one complete Bandit SARIF run")
+ run = runs[0]
+ if not isinstance(run, dict):
+ raise ValueError("Bandit SARIF run is malformed")
+ driver = run.get("tool", {}).get("driver", {})
+ if driver.get("name") != "Bandit" or not driver.get("version"):
+ raise ValueError("SARIF does not identify the Bandit scanner")
+ if run.get("properties", {}).get("metrics") != report["metrics"]:
+ raise ValueError("Bandit JSON and SARIF scanned different source")
+ invocations = run.get("invocations")
+ if not isinstance(invocations, list) or not invocations:
+ raise ValueError("Bandit SARIF omitted scanner execution status")
+ for invocation in invocations:
+ if (
+ not isinstance(invocation, dict)
+ or invocation.get("executionSuccessful") is not True
+ ):
+ raise ValueError("Bandit SARIF records an unsuccessful scan")
+ for field in (
+ "toolExecutionNotifications",
+ "toolConfigurationNotifications",
+ ):
+ notifications = invocation.get(field, [])
+ if not isinstance(notifications, list) or any(
+ not isinstance(row, dict) or row.get("level") == "error"
+ for row in notifications
+ ):
+ raise ValueError("Bandit SARIF records scanner errors")
+ rules = driver.get("rules", [])
+ if not isinstance(rules, list):
+ raise ValueError("Bandit SARIF rule descriptors are malformed")
+ rule_ids = {}
+ for rule in rules:
+ if not isinstance(rule, dict) or not isinstance(rule.get("id"), str):
+ raise ValueError("Bandit SARIF rule descriptor is malformed")
+ if rule["id"] in rule_ids:
+ raise ValueError("Bandit SARIF rule descriptors are duplicated")
+ rule_ids[rule["id"]] = rule
+ results = run.get("results")
+ if not isinstance(results, list):
+ raise ValueError("Bandit SARIF findings are missing or malformed")
+ sarif_findings = Counter()
+ for result in results:
+ if not isinstance(result, dict) or result.get("ruleId") not in rule_ids:
+ raise ValueError("Bandit SARIF finding has no rule descriptor")
+ severity = result.get("properties", {}).get("issue_severity")
+ # Native SARIF omits level when it is the standard warning default.
+ rule = rule_ids[result["ruleId"]]
+ level = result.get(
+ "level",
+ rule.get("defaultConfiguration", {}).get("level", "warning"),
+ )
+ if severity not in LEVELS or level != LEVELS[severity]:
+ raise ValueError("Bandit SARIF finding has inconsistent severity")
+ locations = result.get("locations")
+ if not isinstance(locations, list) or len(locations) != 1:
+ raise ValueError("Bandit SARIF finding has no unique location")
+ physical = locations[0]["physicalLocation"]
+ sarif_findings[
+ finding_key(
+ result["ruleId"],
+ physical["artifactLocation"].get("uri"),
+ physical["region"].get("startLine"),
+ severity,
+ expected,
+ is_uri=True,
+ )
+ ] += 1
+ if sarif_findings != json_findings:
+ raise ValueError("Bandit SARIF findings differ from its JSON report")
+ counts = Counter()
+ for (_, _, _, severity), count in json_findings.items():
+ counts[severity] += count
+ return len(expected), counts
+
+
+def main():
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("report", type=Path)
+ parser.add_argument("sarif", type=Path)
+ parser.add_argument("--source", required=True, type=Path)
+ args = parser.parse_args()
+ try:
+ files, counts = validate(
+ json.loads(args.report.read_text(encoding="utf-8")),
+ json.loads(args.sarif.read_text(encoding="utf-8")),
+ args.source,
+ )
+ except (OSError, ValueError, TypeError, KeyError, AttributeError) as exc:
+ detail = (
+ str(exc)
+ .replace("%", "%25")
+ .replace("\r", "%0D")
+ .replace("\n", "%0A")
+ )
+ print(f"::error::Bandit report validation failed: {detail}")
+ return 1
+ summary = (
+ f"Bandit scanned {files} Python files; validated "
+ f"{counts['HIGH']} high and {counts['MEDIUM']} medium findings."
+ )
+ print(summary)
+ if path := os.environ.get("GITHUB_STEP_SUMMARY"):
+ with open(path, "a", encoding="utf-8") as stream:
+ stream.write(f"## Bandit scan evidence\n\n{summary}\n")
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/.github/workflows/bandit.yml b/.github/workflows/bandit.yml
new file mode 100644
index 0000000000..0f4425bf76
--- /dev/null
+++ b/.github/workflows/bandit.yml
@@ -0,0 +1,89 @@
+name: Bandit Python Security Scan
+
+on:
+ pull_request:
+ paths:
+ - '.github/workflows/bandit.yml'
+ - '.github/workflows/security-tests.yml'
+ - '.github/workflows/release-gate.yml'
+ - '.github/release-scan-policy.json'
+ - '.github/scripts/check_bandit_report.py'
+ - 'requirements/bandit.*'
+ - 'tests/ci/standalone/test_bandit*.py'
+ - 'pyproject.toml'
+ - 'src/local_deep_research/web/templates/**'
+ - 'src/local_deep_research/advanced_search_system/filters/followup_relevance_filter.py'
+ - 'src/local_deep_research/benchmarks/datasets/xbench_deepsearch.py'
+ - 'src/local_deep_research/benchmarks/runners.py'
+ - 'src/local_deep_research/benchmarks/web_api/benchmark_service.py'
+ - 'src/local_deep_research/database/migrations/versions/0008_fix_research_strategy_fk.py'
+ - 'src/local_deep_research/database/migrations/versions/0013_remove_meta_search_engines.py'
+ - 'src/local_deep_research/database/migrations/versions/0021_add_note_tables.py'
+ - 'src/local_deep_research/database/migrations/versions/0025_split_context_warning_dismissals.py'
+ - 'src/local_deep_research/database/migrations/versions/0031_reconcile_corrupted_settings.py'
+ - 'src/local_deep_research/security/network_utils.py'
+ - 'src/local_deep_research/security/notification_validator.py'
+ - 'src/local_deep_research/security/safe_requests.py'
+ - 'src/local_deep_research/security/url_builder.py'
+ - 'src/local_deep_research/utilities/llm_utils.py'
+ - 'src/local_deep_research/web/utils/vite_helper.py'
+ - 'src/local_deep_research/web_search_engines/rate_limiting/llm/wrapper.py'
+ workflow_call:
+ workflow_dispatch:
+
+permissions: {}
+
+jobs:
+ bandit-scan:
+ name: Bandit scan and report integrity
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+ permissions:
+ contents: read
+ security-events: write
+ steps:
+ - name: Harden runner
+ uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1
+ with:
+ egress-policy: audit
+ - name: Checkout
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ - name: Set up Python
+ uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
+ with:
+ python-version: '3.12'
+ - name: Install isolated, hash-verified Bandit
+ run: |
+ python -m venv "$RUNNER_TEMP/bandit-env"
+ "$RUNNER_TEMP/bandit-env/bin/python" -m pip install \
+ --require-hashes --only-binary=:all: -r requirements/bandit.txt
+ echo "$RUNNER_TEMP/bandit-env/bin" >> "$GITHUB_PATH"
+ - name: Test report policy and native scanner behavior
+ run: python -m unittest discover -s tests/ci/standalone -p 'test_bandit*.py' -v
+ - name: Scan Python source at medium and high severity
+ run: |
+ # Findings are enforced by the release alert gate. Scanner failures
+ # and incomplete reports must fail before any SARIF is uploaded.
+ bandit -r src/ --severity-level medium --exit-zero -f json -o bandit-report.json
+ bandit -r src/ --severity-level medium --exit-zero -f sarif -o bandit-results.sarif
+ - name: Require complete, matching native reports
+ run: python .github/scripts/check_bandit_report.py bandit-report.json bandit-results.sarif --source src
+ - name: Upload validated Bandit SARIF
+ if: success() && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
+ uses: github/codeql-action/upload-sarif@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0
+ with:
+ sarif_file: bandit-results.sarif
+ category: bandit
+ wait-for-processing: true
+ - name: Retain scanner diagnostics
+ if: always()
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
+ with:
+ name: bandit-reports
+ path: |
+ bandit-report.json
+ bandit-results.sarif
+ if-no-files-found: warn
+ retention-days: 7
diff --git a/.github/workflows/release-gate.yml b/.github/workflows/release-gate.yml
index cbbc662a91..d3806a92a7 100644
--- a/.github/workflows/release-gate.yml
+++ b/.github/workflows/release-gate.yml
@@ -80,6 +80,11 @@ jobs:
uses: $/.github/workflows/security-tests.yml
permissions:
contents: read
+
+ bandit-scan:
+ uses: $/.github/workflows/bandit.yml
+ permissions:
+ contents: read
security-events: write
semgrep-scan:
@@ -789,6 +794,7 @@ jobs:
- devskim-scan
- bearer-scan
- security-tests
+ - bandit-scan
- container-security
# grype-scan uploads the grype-filesystem / grype-container SARIF. Without
# this edge the alert query below can run before Grype's SARIF is indexed,
@@ -846,6 +852,7 @@ jobs:
needs:
# Existing scans
- security-tests
+ - bandit-scan
- semgrep-scan
- container-security
- owasp-zap-scan
@@ -947,6 +954,7 @@ jobs:
# Check all results silently first
check_result "${{ needs.security-tests.result }}" || true
+ check_result "${{ needs.bandit-scan.result }}" || true
check_result "${{ needs.semgrep-scan.result }}" || true
check_result "${{ needs.container-security.result }}" || true
check_result "${{ needs.owasp-zap-scan.result }}" || true
@@ -1018,6 +1026,13 @@ jobs:
FAILED="true"
fi
+ if [ "${{ needs.bandit-scan.result }}" = "success" ]; then
+ echo "✅ **Bandit Scan**: Passed"
+ else
+ echo "❌ **Bandit Scan**: ${{ needs.bandit-scan.result }}"
+ FAILED="true"
+ fi
+
if [ "${{ needs.semgrep-scan.result }}" = "success" ]; then
echo "✅ **Semgrep Scan**: Passed"
else
diff --git a/.github/workflows/security-tests.yml b/.github/workflows/security-tests.yml
index 60425b262f..65930ee931 100644
--- a/.github/workflows/security-tests.yml
+++ b/.github/workflows/security-tests.yml
@@ -12,7 +12,6 @@ jobs:
timeout-minutes: 40
permissions:
contents: read
- security-events: write # Required for uploading SARIF results to Code Scanning
services:
postgres:
@@ -63,32 +62,8 @@ jobs:
sudo apt-get update
sudo apt-get install -y libsqlcipher-dev
- - name: Install dependencies
- run: |
- pdm sync -d
- pdm add "bandit[sarif]" safety sqlparse pytest pytest-cov --no-sync
- pdm sync
-
- - name: Run Bandit security linter
- run: |
- # --exit-zero: report findings without failing (findings go to SARIF/Security tab)
- # If bandit crashes (bad config, missing files), it exits non-zero WITHOUT --exit-zero
- # and won't produce output files — the checks below catch that.
- pdm run bandit -r src/ -f json -o bandit-report.json -lll --exit-zero
- pdm run bandit -r src/ -f sarif -o bandit-results.sarif -lll --exit-zero
- # Crash detection: if bandit crashed, no output files were produced
- if [ ! -f bandit-report.json ] || [ ! -f bandit-results.sarif ]; then
- echo "::error::Bandit crashed — expected output files not produced"
- exit 1
- fi
- echo "Bandit security scan completed"
-
- - name: Upload Bandit SARIF to Code Scanning
- uses: github/codeql-action/upload-sarif@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0
- if: always()
- with:
- sarif_file: bandit-results.sarif
- category: bandit
+ - name: Install dependencies from the project lock
+ run: pdm sync -d
# Dependency vulnerability scanning is handled by OSV-Scanner
# (osv-scanner.yml), which reads pdm.lock directly and doesn't
@@ -143,28 +118,6 @@ jobs:
grep -v -E "(os\.environ|getenv|config\[|placeholder|example|test)" | \
grep -E "=\s*['\"]" || echo "No hardcoded secrets found"
- - name: Generate security report
- if: always()
- run: |
- echo "Security Test Report"
- echo "==================="
- echo ""
- if [ -f bandit-report.json ]; then
- echo "Bandit Security Issues:"
- python -c "import json; data=json.load(open('bandit-report.json')); print(f' High: {len([i for i in data.get(\"results\", []) if i[\"issue_severity\"] == \"HIGH\"])}'); print(f' Medium: {len([i for i in data.get(\"results\", []) if i[\"issue_severity\"] == \"MEDIUM\"])}'); print(f' Low: {len([i for i in data.get(\"results\", []) if i[\"issue_severity\"] == \"LOW\"])}')" || true
- fi
- echo ""
- echo "Dependency vulnerabilities: covered by OSV-Scanner (osv-scanner.yml)"
-
- - name: Upload security reports
- if: always()
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
- with:
- name: security-reports
- path: |
- bandit-report.json
- bandit-results.sarif
-
# Real nginx + production uvicorn login regressions (#5787, #6442).
# A separate job rather than a step of security-tests: that job's parallel
# suite alone has grown past 20 minutes on main (its timeout is 40), so a
diff --git a/changelog.d/+bandit-report-integrity.security.md b/changelog.d/+bandit-report-integrity.security.md
new file mode 100644
index 0000000000..73d6599ea2
--- /dev/null
+++ b/changelog.d/+bandit-report-integrity.security.md
@@ -0,0 +1 @@
+Include medium-severity Bandit findings in release qualification and reject incomplete or inconsistent scanner reports.
diff --git a/docs/ci/workflow-status.md b/docs/ci/workflow-status.md
index 33ccf6fb3c..8a58291180 100644
--- a/docs/ci/workflow-status.md
+++ b/docs/ci/workflow-status.md
@@ -29,21 +29,19 @@
<!-- BEGIN GENERATED -->
-**72 workflows:** 1 disabled · 4 stale · 1 manual-only · 66 active
+**77 workflows:** 1 disabled · 2 stale · 1 manual-only · 73 active
## ⚠ Disabled workflows
| Workflow | Disabled where | Last direct run |
|---|---|---|
-| `nuclei.yml` | `release-gate.yml:202` (commented) | never |
+| `nuclei.yml` | `release-gate.yml:219` (commented) | never |
## ⚠ Stale (scheduled but no recent successful run)
| Workflow | Cron | Last successful run |
|---|---|---|
-| `osv-scanner.yml` | `39 12 * * 1` | never |
-| `puppeteer-e2e-tests.yml` | `0 2 * * 0` | never |
-| `release-gate.yml` | `0 2 * * *` | never |
+| `update-npm-dependencies.yml` | `0 8 * * 4` | never |
| `update-precommit-hooks.yml` | `0 8 * * 5` | never |
## ℹ Manual-only by design
@@ -57,11 +55,12 @@
| Workflow | Last activity | Trigger | Live badge |
|---|---|---|---|
| `backwards-compatibility.yml` | last 30 days | workflow_call, PR, push:main, release, schedule(0 2 * * 0), manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/backwards-compatibility.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/backwards-compatibility.yml) |
+| `bandit.yml` | long ago | PR, workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/bandit.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/bandit.yml) |
| `bearer.yml` | last 30 days | PR, manual, workflow_call, schedule(0 4 * * *) | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/bearer.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/bearer.yml) |
| `checkov.yml` | last 30 days | manual, workflow_call | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/checkov.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/checkov.yml) |
| `codeql.yml` | last 30 days | push:main, PR, schedule(45 5 * * 0), workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/codeql.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/codeql.yml) |
| `container-security.yml` | last 30 days | workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/container-security.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/container-security.yml) |
-| `devskim.yml` | last 30 days | manual, workflow_call, schedule(0 10 * * *) | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/devskim.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/devskim.yml) |
+| `devskim.yml` | last 30 days | PR, manual, workflow_call, schedule(0 10 * * *) | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/devskim.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/devskim.yml) |
| `docker-multiarch-test.yml` | last 30 days | workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/docker-multiarch-test.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/docker-multiarch-test.yml) |
| `dockle.yml` | last 30 days | manual, workflow_call, schedule(0 10 * * 2) | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/dockle.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/dockle.yml) |
| `gitleaks-main.yml` | last 30 days | workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/gitleaks-main.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/gitleaks-main.yml) |
@@ -69,7 +68,9 @@
| `hadolint.yml` | last 30 days | PR, manual, workflow_call, schedule(0 9 * * 2) | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/hadolint.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/hadolint.yml) |
| `journal-data-integration.yml` | last 30 days | workflow_call, manual, schedule(0 4 * * 1) | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/journal-data-integration.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/journal-data-integration.yml) |
| `npm-audit.yml` | last 30 days | manual, workflow_call | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/npm-audit.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/npm-audit.yml) |
-| `owasp-zap-scan.yml` | last 30 days | workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/owasp-zap-scan.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/owasp-zap-scan.yml) |
+| `osv-scan-reusable.yml` | never | workflow_call | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/osv-scan-reusable.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/osv-scan-reusable.yml) |
+| `osv-scanner.yml` | last 30 days | workflow_call, PR, merge_group, schedule(39 12 * * 1), manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/osv-scanner.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/osv-scanner.yml) |
+| `owasp-zap-scan.yml` | last 30 days | PR, workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/owasp-zap-scan.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/owasp-zap-scan.yml) |
| `retirejs.yml` | last 30 days | manual, workflow_call, schedule(0 4 * * 1) | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/retirejs.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/retirejs.yml) |
| `security-headers-validation.yml` | last 30 days | workflow_call, schedule(0 3 * * *), manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/security-headers-validation.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/security-headers-validation.yml) |
| `security-tests.yml` | last 30 days | workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/security-tests.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/security-tests.yml) |
@@ -84,14 +85,15 @@
| `ci-gate.yml` | last 30 days | workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/ci-gate.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/ci-gate.yml) |
| `compose-integration-test.yml` | last 30 days | workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/compose-integration-test.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/compose-integration-test.yml) |
| `docker-publish.yml` | last 30 days | workflow_call | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/docker-publish.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/docker-publish.yml) |
-| `docker-tests.yml` | last 30 days | PR, push:main, workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/docker-tests.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/docker-tests.yml) |
+| `docker-tests.yml` | last 30 days | PR, push:main, schedule(23 3 * * *), workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/docker-tests.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/docker-tests.yml) |
| `file-whitelist-check.yml` | last 30 days | PR, workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/file-whitelist-check.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/file-whitelist-check.yml) |
| `mypy-type-check.yml` | last 30 days | PR, workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/mypy-type-check.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/mypy-type-check.yml) |
-| `notes-concurrency.yml` | never | workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/notes-concurrency.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/notes-concurrency.yml) |
+| `notes-concurrency.yml` | last 30 days | workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/notes-concurrency.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/notes-concurrency.yml) |
| `playwright-notes-tests.yml` | last 30 days | PR, workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/playwright-notes-tests.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/playwright-notes-tests.yml) |
| `playwright-webkit-tests.yml` | last 30 days | workflow_call, manual, schedule(0 2 * * *) | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/playwright-webkit-tests.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/playwright-webkit-tests.yml) |
| `pre-commit.yml` | last 30 days | PR, workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/pre-commit.yml) |
| `prerelease-docker.yml` | last 30 days | workflow_call | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/prerelease-docker.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/prerelease-docker.yml) |
+| `puppeteer-e2e-tests.yml` | last 30 days | PR, workflow_call, manual, schedule(0 2 * * 0) | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/puppeteer-e2e-tests.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/puppeteer-e2e-tests.yml) |
| `responsive-ui-tests-enhanced.yml` | last 30 days | workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/responsive-ui-tests-enhanced.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/responsive-ui-tests-enhanced.yml) |
| `security-file-write-check.yml` | last 30 days | PR, workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/security-file-write-check.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/security-file-write-check.yml) |
| `validate-image-pinning.yml` | last 30 days | PR, workflow_call, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/validate-image-pinning.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/validate-image-pinning.yml) |
@@ -101,16 +103,16 @@
| Workflow | Last activity | Trigger | Live badge |
|---|---|---|---|
-| `ci-health-report.yml` | never | schedule(0 6 * * 1), manual, push:main | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/ci-health-report.yml/badge.svg?event=schedule)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/ci-health-report.yml?query=event%3Aschedule) |
+| `ci-health-report.yml` | last 30 days | schedule(0 6 * * 1), manual, push:main | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/ci-health-report.yml/badge.svg?event=schedule)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/ci-health-report.yml?query=event%3Aschedule) |
| `compose-published-smoke.yml` | last 30 days | manual, schedule(0 5 * * 1) | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/compose-published-smoke.yml/badge.svg?event=schedule)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/compose-published-smoke.yml?query=event%3Aschedule) |
| `fuzz.yml` | last 30 days | schedule(0 0 * * 0), manual, PR | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/fuzz.yml/badge.svg?event=schedule)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/fuzz.yml?query=event%3Aschedule) |
| `gitleaks.yml` | last 30 days | PR, manual, schedule(0 3 * * *) | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/gitleaks.yml/badge.svg?event=schedule)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/gitleaks.yml?query=event%3Aschedule) |
| `ossf-scorecard.yml` | last 30 days | branch_protection_rule, schedule(0 8 * * 1), manual, push:main | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/ossf-scorecard.yml/badge.svg?event=schedule)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/ossf-scorecard.yml?query=event%3Aschedule) |
| `osv-scanner-scheduled.yml` | last 30 days | push:main, schedule(41 21 * * 1), manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/osv-scanner-scheduled.yml/badge.svg?event=schedule)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/osv-scanner-scheduled.yml?query=event%3Aschedule) |
+| `release-gate.yml` | last 30 days | workflow_call, manual, schedule(0 2 * * *) | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/release-gate.yml/badge.svg?event=schedule)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/release-gate.yml?query=event%3Aschedule) |
| `sbom.yml` | last 30 days | manual, schedule(0 10 * * 3), release | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/sbom.yml/badge.svg?event=schedule)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/sbom.yml?query=event%3Aschedule) |
| `security-mxss-browser-tests.yml` | last 30 days | PR, manual, schedule(30 2 * * *) | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/security-mxss-browser-tests.yml/badge.svg?event=schedule)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/security-mxss-browser-tests.yml?query=event%3Aschedule) |
| `update-dependencies.yml` | last 30 days | workflow_call, manual, schedule(0 8 * * 3) | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/update-dependencies.yml/badge.svg?event=schedule)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/update-dependencies.yml?query=event%3Aschedule) |
-| `update-npm-dependencies.yml` | last 30 days | workflow_call, manual, schedule(0 8 * * 4) | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/update-npm-dependencies.yml/badge.svg?event=schedule)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/update-npm-dependencies.yml?query=event%3Aschedule) |
| `update-oldest-auto-merge-pr.yml` | last 30 days | schedule(17,47 * * * *), manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/update-oldest-auto-merge-pr.yml/badge.svg?event=schedule)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/update-oldest-auto-merge-pr.yml?query=event%3Aschedule) |
## PR / push checks
@@ -130,18 +132,19 @@
| `mcp-tests.yml` | last 30 days | push:main, PR, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/mcp-tests.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/mcp-tests.yml) |
| `milvus-tests.yml` | last 30 days | push:main, PR, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/milvus-tests.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/milvus-tests.yml) |
| `pr-triage.yml` | last 30 days | PR, pull_request_review | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/pr-triage.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/pr-triage.yml) |
-| `release-cleanup-tests.yml` | never | PR, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/release-cleanup-tests.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/release-cleanup-tests.yml) |
+| `release-cleanup-tests.yml` | last 30 days | PR, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/release-cleanup-tests.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/release-cleanup-tests.yml) |
| `release-package-tests.yml` | last 30 days | PR, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/release-package-tests.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/release-package-tests.yml) |
| `release.yml` | last 30 days | push:main, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/release.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/release.yml) |
| `ui-full-shards.yml` | last 30 days | PR, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/ui-full-shards.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/ui-full-shards.yml) |
| `version_check.yml` | last 30 days | push:main, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/version_check.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/version_check.yml) |
| `welcome-first-time.yml` | last 30 days | PR-target | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/welcome-first-time.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/welcome-first-time.yml) |
+| `windows-database-tests.yml` | last 30 days | PR, push:main, manual | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/windows-database-tests.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/windows-database-tests.yml) |
## Repository-dispatch publishers
| Workflow | Last activity | Trigger | Live badge |
|---|---|---|---|
-| `publish.yml` | last 30 days | repo_dispatch | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/publish.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/publish.yml) |
+| `publish.yml` | 1-3 months ago | repo_dispatch | [![status](https://github.com/LearningCircuit/local-deep-research/actions/workflows/publish.yml/badge.svg)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/publish.yml) |
## Other
diff --git a/requirements/README.md b/requirements/README.md
index e5e2cad186..f46940bf2d 100644
--- a/requirements/README.md
+++ b/requirements/README.md
@@ -12,6 +12,13 @@ Both tool installs require binary wheels. The application wheel and sdist checks
continue to use fresh pip resolution of the shipped package metadata; these CI
tool locks do not constrain application dependencies.
+Bandit 1.9.4 runs in a separate Python 3.12 environment from the binary-only,
+hash-verified `bandit.txt` lock. Its medium/high native JSON and SARIF reports
+must cover every target Python file and agree on findings before upload.
+Scanner dependencies do not modify the application lock or test environment.
+The Bandit regeneration command includes `--allow-unsafe` so setuptools,
+required by the SARIF formatter dependency tree, is also pinned and hashed.
+
Release-note rendering and changelog cleanup also run Towncrier 24.8.0 in
fresh Python 3.12 virtual environments, using the complete binary-only,
hash-verified `towncrier.txt` lock. The sparse release-source checkout includes
diff --git a/requirements/bandit.in b/requirements/bandit.in
new file mode 100644
index 0000000000..e671b84a61
--- /dev/null
+++ b/requirements/bandit.in
@@ -0,0 +1,3 @@
+# Python 3.12 on Linux. Regenerate using pip-tools 7.6.1:
+# pip-compile --allow-unsafe --generate-hashes --strip-extras --no-emit-index-url --no-emit-trusted-host --index-url=https://pypi.org/simple --pip-args=--only-binary=:all: requirements/bandit.in
+bandit[sarif]==1.9.4
diff --git a/requirements/bandit.txt b/requirements/bandit.txt
new file mode 100644
index 0000000000..daeb4193f5
--- /dev/null
+++ b/requirements/bandit.txt
@@ -0,0 +1,124 @@
+#
+# This file is autogenerated by pip-compile with Python 3.12
+# by the following command:
+#
+# pip-compile --allow-unsafe --generate-hashes --index-url=https://pypi.org/simple --no-emit-index-url --no-emit-trusted-host --no-index --pip-args='--only-binary=:all:' --strip-extras requirements/bandit.in
+#
+--only-binary :all:
+
+attrs==26.1.0 \
+ --hash=sha256:c647aa4a12dfbad9333ca4e71fe62ddc36f4e63b2d260a37a8b83d2f043ac309
+ # via
+ # jschema-to-python
+ # sarif-om
+bandit==1.9.4 \
+ --hash=sha256:f89ffa663767f5a0585ea075f01020207e966a9c0f2b9ef56a57c7963a3f6f8e
+ # via -r requirements/bandit.in
+jschema-to-python==1.2.3 \
+ --hash=sha256:8a703ca7604d42d74b2815eecf99a33359a8dccbb80806cce386d5e2dd992b05
+ # via bandit
+jsonpickle==4.1.4 \
+ --hash=sha256:c46024ba4acd8adb9a8b8485d074e141cbfacafe334c2aa982e5b32efabc2f0e
+ # via jschema-to-python
+markdown-it-py==4.2.0 \
+ --hash=sha256:9f7ebbcd14fe59494226453aed97c1070d83f8d24b6fc3a3bcf9a38092641c4a
+ # via rich
+mdurl==0.1.2 \
+ --hash=sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8
+ # via markdown-it-py
+pbr==7.1.3 \
+ --hash=sha256:6583e878a1d97cb135fdc509811f31b9235905cde8d4dacd3dbadf9efc45d745
+ # via
+ # jschema-to-python
+ # sarif-om
+pygments==2.21.0 \
+ --hash=sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9
+ # via rich
+pyyaml==6.0.3 \
+ --hash=sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c \
+ --hash=sha256:0150219816b6a1fa26fb4699fb7daa9caf09eb1999f3b70fb6e786805e80375a \
+ --hash=sha256:02893d100e99e03eda1c8fd5c441d8c60103fd175728e23e431db1b589cf5ab3 \
+ --hash=sha256:02ea2dfa234451bbb8772601d7b8e426c2bfa197136796224e50e35a78777956 \
+ --hash=sha256:0f29edc409a6392443abf94b9cf89ce99889a1dd5376d94316ae5145dfedd5d6 \
+ --hash=sha256:10892704fc220243f5305762e276552a0395f7beb4dbf9b14ec8fd43b57f126c \
+ --hash=sha256:16249ee61e95f858e83976573de0f5b2893b3677ba71c9dd36b9cf8be9ac6d65 \
+ --hash=sha256:1d37d57ad971609cf3c53ba6a7e365e40660e3be0e5175fa9f2365a379d6095a \
+ --hash=sha256:1ebe39cb5fc479422b83de611d14e2c0d3bb2a18bbcb01f229ab3cfbd8fee7a0 \
+ --hash=sha256:214ed4befebe12df36bcc8bc2b64b396ca31be9304b8f59e25c11cf94a4c033b \
+ --hash=sha256:2283a07e2c21a2aa78d9c4442724ec1eb15f5e42a723b99cb3d822d48f5f7ad1 \
+ --hash=sha256:22ba7cfcad58ef3ecddc7ed1db3409af68d023b7f940da23c6c2a1890976eda6 \
+ --hash=sha256:27c0abcb4a5dac13684a37f76e701e054692a9b2d3064b70f5e4eb54810553d7 \
+ --hash=sha256:28c8d926f98f432f88adc23edf2e6d4921ac26fb084b028c733d01868d19007e \
+ --hash=sha256:2e71d11abed7344e42a8849600193d15b6def118602c4c176f748e4583246007 \
+ --hash=sha256:34d5fcd24b8445fadc33f9cf348c1047101756fd760b4dacb5c3e99755703310 \
+ --hash=sha256:37503bfbfc9d2c40b344d06b2199cf0e96e97957ab1c1b546fd4f87e53e5d3e4 \
+ --hash=sha256:3c5677e12444c15717b902a5798264fa7909e41153cdf9ef7ad571b704a63dd9 \
+ --hash=sha256:3ff07ec89bae51176c0549bc4c63aa6202991da2d9a6129d7aef7f1407d3f295 \
+ --hash=sha256:41715c910c881bc081f1e8872880d3c650acf13dfa8214bad49ed4cede7c34ea \
+ --hash=sha256:418cf3f2111bc80e0933b2cd8cd04f286338bb88bdc7bc8e6dd775ebde60b5e0 \
+ --hash=sha256:44edc647873928551a01e7a563d7452ccdebee747728c1080d881d68af7b997e \
+ --hash=sha256:4a2e8cebe2ff6ab7d1050ecd59c25d4c8bd7e6f400f5f82b96557ac0abafd0ac \
+ --hash=sha256:4ad1906908f2f5ae4e5a8ddfce73c320c2a1429ec52eafd27138b7f1cbe341c9 \
+ --hash=sha256:501a031947e3a9025ed4405a168e6ef5ae3126c59f90ce0cd6f2bfc477be31b7 \
+ --hash=sha256:5190d403f121660ce8d1d2c1bb2ef1bd05b5f68533fc5c2ea899bd15f4399b35 \
+ --hash=sha256:5498cd1645aa724a7c71c8f378eb29ebe23da2fc0d7a08071d89469bf1d2defb \
+ --hash=sha256:5cf4e27da7e3fbed4d6c3d8e797387aaad68102272f8f9752883bc32d61cb87b \
+ --hash=sha256:5e0b74767e5f8c593e8c9b5912019159ed0533c70051e9cce3e8b6aa699fcd69 \
+ --hash=sha256:5ed875a24292240029e4483f9d4a4b8a1ae08843b9c54f43fcc11e404532a8a5 \
+ --hash=sha256:5fcd34e47f6e0b794d17de1b4ff496c00986e1c83f7ab2fb8fcfe9616ff7477b \
+ --hash=sha256:5fdec68f91a0c6739b380c83b951e2c72ac0197ace422360e6d5a959d8d97b2c \
+ --hash=sha256:6344df0d5755a2c9a276d4473ae6b90647e216ab4757f8426893b5dd2ac3f369 \
+ --hash=sha256:64386e5e707d03a7e172c0701abfb7e10f0fb753ee1d773128192742712a98fd \
+ --hash=sha256:652cb6edd41e718550aad172851962662ff2681490a8a711af6a4d288dd96824 \
+ --hash=sha256:66291b10affd76d76f54fad28e22e51719ef9ba22b29e1d7d03d6777a9174198 \
+ --hash=sha256:66e1674c3ef6f541c35191caae2d429b967b99e02040f5ba928632d9a7f0f065 \
+ --hash=sha256:6adc77889b628398debc7b65c073bcb99c4a0237b248cacaf3fe8a557563ef6c \
+ --hash=sha256:79005a0d97d5ddabfeeea4cf676af11e647e41d81c9a7722a193022accdb6b7c \
+ --hash=sha256:7c6610def4f163542a622a73fb39f534f8c101d690126992300bf3207eab9764 \
+ --hash=sha256:7f047e29dcae44602496db43be01ad42fc6f1cc0d8cd6c83d342306c32270196 \
+ --hash=sha256:8098f252adfa6c80ab48096053f512f2321f0b998f98150cea9bd23d83e1467b \
+ --hash=sha256:850774a7879607d3a6f50d36d04f00ee69e7fc816450e5f7e58d7f17f1ae5c00 \
+ --hash=sha256:8d1fab6bb153a416f9aeb4b8763bc0f22a5586065f86f7664fc23339fc1c1fac \
+ --hash=sha256:8da9669d359f02c0b91ccc01cac4a67f16afec0dac22c2ad09f46bee0697eba8 \
+ --hash=sha256:8dc52c23056b9ddd46818a57b78404882310fb473d63f17b07d5c40421e47f8e \
+ --hash=sha256:9149cad251584d5fb4981be1ecde53a1ca46c891a79788c0df828d2f166bda28 \
+ --hash=sha256:93dda82c9c22deb0a405ea4dc5f2d0cda384168e466364dec6255b293923b2f3 \
+ --hash=sha256:96b533f0e99f6579b3d4d4995707cf36df9100d67e0c8303a0c55b27b5f99bc5 \
+ --hash=sha256:9c57bb8c96f6d1808c030b1687b9b5fb476abaa47f0db9c0101f5e9f394e97f4 \
+ --hash=sha256:9c7708761fccb9397fe64bbc0395abcae8c4bf7b0eac081e12b809bf47700d0b \
+ --hash=sha256:9f3bfb4965eb874431221a3ff3fdcddc7e74e3b07799e0e84ca4a0f867d449bf \
+ --hash=sha256:a33284e20b78bd4a18c8c2282d549d10bc8408a2a7ff57653c0cf0b9be0afce5 \
+ --hash=sha256:a80cb027f6b349846a3bf6d73b5e95e782175e52f22108cfa17876aaeff93702 \
+ --hash=sha256:b30236e45cf30d2b8e7b3e85881719e98507abed1011bf463a8fa23e9c3e98a8 \
+ --hash=sha256:b3bc83488de33889877a0f2543ade9f70c67d66d9ebb4ac959502e12de895788 \
+ --hash=sha256:b865addae83924361678b652338317d1bd7e79b1f4596f96b96c77a5a34b34da \
+ --hash=sha256:b8bb0864c5a28024fac8a632c443c87c5aa6f215c0b126c449ae1a150412f31d \
+ --hash=sha256:ba1cc08a7ccde2d2ec775841541641e4548226580ab850948cbfda66a1befcdc \
+ --hash=sha256:bdb2c67c6c1390b63c6ff89f210c8fd09d9a1217a465701eac7316313c915e4c \
+ --hash=sha256:c1ff362665ae507275af2853520967820d9124984e0f7466736aea23d8611fba \
+ --hash=sha256:c2514fceb77bc5e7a2f7adfaa1feb2fb311607c9cb518dbc378688ec73d8292f \
+ --hash=sha256:c3355370a2c156cffb25e876646f149d5d68f5e0a3ce86a5084dd0b64a994917 \
+ --hash=sha256:c458b6d084f9b935061bc36216e8a69a7e293a2f1e68bf956dcd9e6cbcd143f5 \
+ --hash=sha256:d0eae10f8159e8fdad514efdc92d74fd8d682c933a6dd088030f3834bc8e6b26 \
+ --hash=sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b \
+ --hash=sha256:eda16858a3cab07b80edaf74336ece1f986ba330fdb8ee0d6c0d68fe82bc96be \
+ --hash=sha256:ee2922902c45ae8ccada2c5b501ab86c36525b883eff4255313a253a3160861c \
+ --hash=sha256:efd7b85f94a6f21e4932043973a7ba2613b059c4a000551892ac9f1d11f5baf3 \
+ --hash=sha256:f7057c9a337546edc7973c0d3ba84ddcdf0daa14533c2065749c9075001090e6 \
+ --hash=sha256:fa160448684b4e94d80416c0fa4aac48967a969efe22931448d853ada8baf926 \
+ --hash=sha256:fc09d0aa354569bc501d4e787133afc08552722d3ab34836a80547331bb5d4a0
+ # via bandit
+rich==15.0.0 \
+ --hash=sha256:33bd4ef74232fb73fe9279a257718407f169c09b78a87ad3d296f548e27de0bb
+ # via bandit
+sarif-om==1.0.4 \
+ --hash=sha256:539ef47a662329b1c8502388ad92457425e95dc0aaaf995fe46f4984c4771911
+ # via bandit
+stevedore==5.9.1 \
+ --hash=sha256:5c8ff3a9f336cc1a06ac0f597bc79d11a2f950bfd32e290ca56b5a301fafafbf
+ # via bandit
+
+# The following packages are considered to be unsafe in a requirements file:
+setuptools==84.0.0 \
+ --hash=sha256:51a52592b3b99e102b609654876bd65f19f999935166d1352678931132b0c670
+ # via pbr
diff --git a/src/local_deep_research/advanced_search_system/filters/followup_relevance_filter.py b/src/local_deep_research/advanced_search_system/filters/followup_relevance_filter.py
index 7a1cb6d382..40537f767c 100644
--- a/src/local_deep_research/advanced_search_system/filters/followup_relevance_filter.py
+++ b/src/local_deep_research/advanced_search_system/filters/followup_relevance_filter.py
@@ -140,6 +140,7 @@ Previous Research Context:
---
"""
+ # This text is an LLM source-selection prompt; it is never executed as SQL.
prompt = f"""
Select the most relevant sources for answering this follow-up question based on the previous research context.
{context_section}
@@ -155,7 +156,7 @@ Instructions:
- Return ONLY a JSON array of source numbers (e.g., [0, 2, 5, 7])
- Do not include any explanation or other text
-Return the indices of relevant sources as a JSON array:"""
+Return the indices of relevant sources as a JSON array:""" # nosec B608
try:
response = invoke_llm_sync(self.model, prompt)
diff --git a/src/local_deep_research/benchmarks/datasets/xbench_deepsearch.py b/src/local_deep_research/benchmarks/datasets/xbench_deepsearch.py
index 58579ccc49..3888054df8 100644
--- a/src/local_deep_research/benchmarks/datasets/xbench_deepsearch.py
+++ b/src/local_deep_research/benchmarks/datasets/xbench_deepsearch.py
@@ -99,7 +99,8 @@ class XBenchDeepSearchDataset(BenchmarkDataset):
)
# Load the dataset from Hugging Face (no authentication needed)
- dataset = load_dataset(dataset_path, split="train")
+ # Operator-selected benchmark records are data inputs; datasets >=5 disables remote loading scripts.
+ dataset = load_dataset(dataset_path, split="train") # nosec B615
# Format for our benchmark system and decrypt
formatted_questions = []
diff --git a/src/local_deep_research/benchmarks/runners.py b/src/local_deep_research/benchmarks/runners.py
index c2370816c9..5baaf2b8ae 100644
--- a/src/local_deep_research/benchmarks/runners.py
+++ b/src/local_deep_research/benchmarks/runners.py
@@ -100,7 +100,8 @@ def run_benchmark(
logger.warning(
"Error using dataset class. Falling back to legacy function."
)
- dataset = load_dataset(
+ # This is the local benchmark registry factory, not a Hugging Face download API.
+ dataset = load_dataset( # nosec B615
dataset_type=dataset_type,
dataset_path=dataset_path,
num_examples=num_examples,
diff --git a/src/local_deep_research/benchmarks/web_api/benchmark_service.py b/src/local_deep_research/benchmarks/web_api/benchmark_service.py
index b2c90c0240..8be4cc4010 100644
--- a/src/local_deep_research/benchmarks/web_api/benchmark_service.py
+++ b/src/local_deep_research/benchmarks/web_api/benchmark_service.py
@@ -766,7 +766,8 @@ class BenchmarkService:
for dataset_name, config in datasets_config.items():
if config.get("count", 0) > 0:
- dataset = load_dataset(
+ # This is the local benchmark registry factory, not a Hugging Face download API.
+ dataset = load_dataset( # nosec B615
dataset_type=dataset_name,
num_examples=config["count"],
seed=config.get("seed"),
diff --git a/src/local_deep_research/database/migrations/versions/0008_fix_research_strategy_fk.py b/src/local_deep_research/database/migrations/versions/0008_fix_research_strategy_fk.py
index 1564aa02ec..06124d7e99 100644
--- a/src/local_deep_research/database/migrations/versions/0008_fix_research_strategy_fk.py
+++ b/src/local_deep_research/database/migrations/versions/0008_fix_research_strategy_fk.py
@@ -55,8 +55,9 @@ def _table_row_count(bind, table_name: str) -> int:
# bearer:disable python_lang_sql_injection
return (
bind.execute(
+ # Only the literal research_strategies table reaches this migration helper.
# nosemgrep: semgrep.rules.sql-string-concatenation, reason: Both migration callers pass the literal research_strategies table name
- text(f"SELECT COUNT(*) FROM {table_name}") # noqa: S608 — hardcoded name
+ text(f"SELECT COUNT(*) FROM {table_name}") # noqa: S608 — hardcoded name # nosec B608
).scalar()
or 0
)
diff --git a/src/local_deep_research/database/migrations/versions/0013_remove_meta_search_engines.py b/src/local_deep_research/database/migrations/versions/0013_remove_meta_search_engines.py
index cd459cc12c..968c304187 100644
--- a/src/local_deep_research/database/migrations/versions/0013_remove_meta_search_engines.py
+++ b/src/local_deep_research/database/migrations/versions/0013_remove_meta_search_engines.py
@@ -177,8 +177,9 @@ def _rewrite_benchmark_search_configs(conn, table: str) -> None:
# trailing prose after the rule id, is silently ignored.
# bearer:disable python_lang_sql_injection
rows = conn.execute(
+ # Only the two literal benchmark table names reach this migration helper.
# nosemgrep: semgrep.rules.sql-string-concatenation, reason: Only benchmark_runs and benchmark_configs literals reach this migration helper
- sa.text(f"SELECT id, search_config FROM {table}") # noqa: S608
+ sa.text(f"SELECT id, search_config FROM {table}") # noqa: S608 # nosec B608
).fetchall()
rewritten = 0
@@ -199,7 +200,8 @@ def _rewrite_benchmark_search_configs(conn, table: str) -> None:
conn.execute(
# nosemgrep: semgrep.rules.sql-string-concatenation, reason: Table comes from two migration literals; row ID and JSON config are bound parameters
sa.text(
- f"UPDATE {table} SET search_config = :config " # noqa: S608
+ # Only the two literal benchmark table names reach this migration helper.
+ f"UPDATE {table} SET search_config = :config " # noqa: S608 # nosec B608
"WHERE id = :id"
),
{"config": json.dumps(config), "id": row_id},
diff --git a/src/local_deep_research/database/migrations/versions/0021_add_note_tables.py b/src/local_deep_research/database/migrations/versions/0021_add_note_tables.py
index fb00b36869..f80c87178c 100644
--- a/src/local_deep_research/database/migrations/versions/0021_add_note_tables.py
+++ b/src/local_deep_research/database/migrations/versions/0021_add_note_tables.py
@@ -333,8 +333,9 @@ def downgrade():
if inspector.has_table(table_name):
try:
count = conn.execute(
+ # The table is selected from the six literal note table names above.
# nosemgrep: semgrep.rules.sql-string-concatenation, reason: Table name comes only from the six literal note tables listed above
- sa.text(f"SELECT COUNT(*) FROM {table_name}") # noqa: S608
+ sa.text(f"SELECT COUNT(*) FROM {table_name}") # noqa: S608 # nosec B608
).scalar()
except Exception:
# Don't collapse the failure into the 'unknown' sentinel
diff --git a/src/local_deep_research/database/migrations/versions/0025_split_context_warning_dismissals.py b/src/local_deep_research/database/migrations/versions/0025_split_context_warning_dismissals.py
index 58ee41ebf2..80e5f964c2 100644
--- a/src/local_deep_research/database/migrations/versions/0025_split_context_warning_dismissals.py
+++ b/src/local_deep_research/database/migrations/versions/0025_split_context_warning_dismissals.py
@@ -47,7 +47,8 @@ def _copy_setting_if_missing(conn, source_key: str, target_key: str) -> None:
conn.execute(
# nosemgrep: semgrep.rules.sql-string-concatenation, reason: Columns are intersected with the fixed _COPYABLE_COLUMNS tuple; setting keys remain bound parameters
sa.text(
- f"INSERT INTO settings (key, {columns_sql}) " # noqa: S608
+ # Column names are fixed migration metadata; setting keys remain bound parameters.
+ f"INSERT INTO settings (key, {columns_sql}) " # noqa: S608 # nosec B608
f"SELECT :target_key, {columns_sql} FROM settings "
"WHERE key = :source_key "
"AND NOT EXISTS (SELECT 1 FROM settings WHERE key = :target_key)"
diff --git a/src/local_deep_research/database/migrations/versions/0031_reconcile_corrupted_settings.py b/src/local_deep_research/database/migrations/versions/0031_reconcile_corrupted_settings.py
index 5e31fdb71e..4f733b8826 100644
--- a/src/local_deep_research/database/migrations/versions/0031_reconcile_corrupted_settings.py
+++ b/src/local_deep_research/database/migrations/versions/0031_reconcile_corrupted_settings.py
@@ -87,7 +87,8 @@ REPAIR_DEFAULTS = {
"app.debug": False,
"app.enable_notifications": True,
"app.enable_web": True,
- "app.host": "0.0.0.0", # noqa: S104 - frozen packaged default
+ # Frozen packaged bind default; this migration does not open a listening socket.
+ "app.host": "0.0.0.0", # noqa: S104 - frozen packaged default # nosec B104
"app.port": 5000,
"app.theme": "system",
"app.web_interface": True,
diff --git a/src/local_deep_research/security/network_utils.py b/src/local_deep_research/security/network_utils.py
index 4c75dd0c9f..5e81c042d0 100644
--- a/src/local_deep_research/security/network_utils.py
+++ b/src/local_deep_research/security/network_utils.py
@@ -98,7 +98,8 @@ def is_private_ip(hostname: str) -> bool:
False
"""
# Known localhost values
- if hostname in ("localhost", "127.0.0.1", "[::1]", "0.0.0.0"):
+ # Recognize a localhost spelling; no socket is bound here.
+ if hostname in ("localhost", "127.0.0.1", "[::1]", "0.0.0.0"): # nosec B104
return True
# Handle bracketed IPv6
diff --git a/src/local_deep_research/security/notification_validator.py b/src/local_deep_research/security/notification_validator.py
index 25295acd88..827608add1 100644
--- a/src/local_deep_research/security/notification_validator.py
+++ b/src/local_deep_research/security/notification_validator.py
@@ -640,7 +640,8 @@ class NotificationURLValidator:
"localhost",
"127.0.0.1",
"::1",
- "0.0.0.0",
+ # Recognize and validate a local address; no socket is bound here.
+ "0.0.0.0", # nosec B104
"::",
):
return True
diff --git a/src/local_deep_research/security/safe_requests.py b/src/local_deep_research/security/safe_requests.py
index cadb61a8d6..51e074c795 100644
--- a/src/local_deep_research/security/safe_requests.py
+++ b/src/local_deep_research/security/safe_requests.py
@@ -583,7 +583,8 @@ def safe_get(
with dns_pinning.pinned_request(
url, allow_localhost, allow_private_ips
):
- response = requests.get(url, params=params, **kwargs)
+ # The wrapper sets timeout in kwargs before the first request and retains it for redirects.
+ response = requests.get(url, params=params, **kwargs) # nosec B113
# Follow redirects manually with SSRF validation on each hop.
# Each hop uses a fresh requests.get() call without a session,
@@ -655,7 +656,8 @@ def safe_get(
with dns_pinning.pinned_request(
redirect_url, allow_localhost, allow_private_ips
):
- response = requests.get(redirect_url, **kwargs)
+ # The wrapper sets timeout in kwargs before the first request and retains it for redirects.
+ response = requests.get(redirect_url, **kwargs) # nosec B113
redirects_followed += 1
if (
@@ -765,7 +767,8 @@ def safe_post(
with dns_pinning.pinned_request(
url, allow_localhost, allow_private_ips
):
- response = requests.post(url, data=data, json=json, **kwargs)
+ # The wrapper sets timeout in kwargs before the first request and retains it for redirects.
+ response = requests.post(url, data=data, json=json, **kwargs) # nosec B113
# Follow redirects manually with SSRF validation on each hop.
# Each hop uses a fresh request without a session, so cookies
@@ -848,10 +851,12 @@ def safe_post(
# 301/302/303: convert to GET, drop body
data = None
json = None
- response = requests.get(redirect_url, **kwargs)
+ # The wrapper sets timeout in kwargs before the first request and retains it for redirects.
+ response = requests.get(redirect_url, **kwargs) # nosec B113
else:
# 307/308: preserve current method and body
- response = requests.post(
+ # The wrapper sets timeout in kwargs before the first request and retains it for redirects.
+ response = requests.post( # nosec B113
redirect_url, data=data, json=json, **kwargs
)
redirects_followed += 1
diff --git a/src/local_deep_research/security/url_builder.py b/src/local_deep_research/security/url_builder.py
index 6f5a947c61..bb220b0f6a 100644
--- a/src/local_deep_research/security/url_builder.py
+++ b/src/local_deep_research/security/url_builder.py
@@ -30,7 +30,8 @@ def normalize_bind_address(host: str) -> str:
URL-friendly hostname
"""
# Convert bind-all addresses to localhost for URLs
- if host in ("0.0.0.0", "::"):
+ # Replace a bind-all address with localhost for a client URL.
+ if host in ("0.0.0.0", "::"): # nosec B104
return "localhost"
return host
diff --git a/src/local_deep_research/utilities/llm_utils.py b/src/local_deep_research/utilities/llm_utils.py
index a8d83d1085..f932591b8c 100644
--- a/src/local_deep_research/utilities/llm_utils.py
+++ b/src/local_deep_research/utilities/llm_utils.py
@@ -344,7 +344,8 @@ def get_server_url(settings_snapshot: Optional[Dict[str, Any]] = None) -> str:
)
# Use localhost for 0.0.0.0 bindings as that's what users will use
- if host == "0.0.0.0":
+ # Replace a bind-all address with localhost for a client URL.
+ if host == "0.0.0.0": # nosec B104
host = "127.0.0.1"
scheme = "https" if use_https else "http"
diff --git a/src/local_deep_research/web/utils/vite_helper.py b/src/local_deep_research/web/utils/vite_helper.py
index ba73935d4b..0d117eb857 100644
--- a/src/local_deep_research/web/utils/vite_helper.py
+++ b/src/local_deep_research/web/utils/vite_helper.py
@@ -262,7 +262,8 @@ class ViteHelper:
"""
if self.is_dev:
# Development mode - use Vite dev server
- return Markup(
+ # Development entry names come from trusted template calls; this is a development-only asset tag.
+ return Markup( # nosec B704
f'<script type="module" src="http://localhost:5173/{entry_point}"></script>'
)
@@ -331,7 +332,8 @@ class ViteHelper:
# Include the main JS file
js_tag = f'<script type="module" src="{file_path}"></script>'
- return Markup(css_tags + js_tag)
+ # Manifest asset paths are verified and URL-quoted before these fixed tags are assembled.
+ return Markup(css_tags + js_tag) # nosec B704
def _fallback_assets(self, state=None, entry_point=None, problem=None):
"""Fallback markup used when the Vite manifest or a requested entry
@@ -408,7 +410,8 @@ class ViteHelper:
)
detail = "using existing static files as fallback"
- return Markup(
+ # Diagnostic detail is selected from fixed module messages; paths and entry names stay in logs.
+ return Markup( # nosec B704
"\n<!-- Vite build not found - run 'npm run build' to generate production assets -->\n"
f"<!-- {detail} -->\n"
)
@@ -853,7 +856,8 @@ class ViteHelper:
"""Body-level banner shown when the frontend was never built."""
if not self.assets_are_missing():
return Markup("")
- return Markup(_FALLBACK_BANNER)
+ # This banner is a fixed module literal and contains no request or manifest data.
+ return Markup(_FALLBACK_BANNER) # nosec B704
def init_for_fastapi(self, static_dir, jinja2_templates):
"""Initialize the helper for FastAPI (no Flask app dependency).
diff --git a/src/local_deep_research/web_search_engines/rate_limiting/llm/wrapper.py b/src/local_deep_research/web_search_engines/rate_limiting/llm/wrapper.py
index fd683e6f02..37ad948fd6 100644
--- a/src/local_deep_research/web_search_engines/rate_limiting/llm/wrapper.py
+++ b/src/local_deep_research/web_search_engines/rate_limiting/llm/wrapper.py
@@ -149,7 +149,8 @@ def create_rate_limited_llm_wrapper(base_llm, provider: Optional[str] = None):
base_url = str(self.base_llm.base_url)
if any(
local in base_url
- for local in ["localhost", "127.0.0.1", "0.0.0.0"]
+ # Classify a configured local service URL; no listening socket is opened.
+ for local in ["localhost", "127.0.0.1", "0.0.0.0"] # nosec B104
):
logger.debug(
"Skipping rate limiting for local URL: "
diff --git a/tests/ci/standalone/test_bandit_integration.py b/tests/ci/standalone/test_bandit_integration.py
new file mode 100644
index 0000000000..3d0637ea58
--- /dev/null
+++ b/tests/ci/standalone/test_bandit_integration.py
@@ -0,0 +1,121 @@
+"""Exercise native Bandit reports using harmless, never-executed source."""
+
+# allow: no-sut-import — scans fixtures and invokes the standalone policy.
+
+import json
+from pathlib import Path
+import shutil
+import subprocess
+import sys
+import tempfile
+import unittest
+
+ROOT = Path(__file__).resolve().parents[3]
+
+
[email protected](shutil.which("bandit"), "Native Bandit runs in scanner CI")
+class NativeScannerTests(unittest.TestCase):
+ def scan(self, source):
+ directory = tempfile.TemporaryDirectory()
+ self.addCleanup(directory.cleanup)
+ root = Path(directory.name)
+ target = root / "src"
+ target.mkdir()
+ (target / "probe.py").write_text(source, encoding="utf-8")
+ report, sarif = root / "report.json", root / "report.sarif"
+ for format, path in (("json", report), ("sarif", sarif)):
+ run = subprocess.run(
+ [
+ "bandit",
+ "-r",
+ str(target),
+ "--severity-level",
+ "medium",
+ "--exit-zero",
+ "-f",
+ format,
+ "-o",
+ str(path),
+ ],
+ capture_output=True,
+ text=True,
+ timeout=30,
+ check=False,
+ )
+ self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
+ checked = subprocess.run(
+ [
+ sys.executable,
+ str(ROOT / ".github/scripts/check_bandit_report.py"),
+ str(report),
+ str(sarif),
+ "--source",
+ str(target),
+ ],
+ capture_output=True,
+ text=True,
+ timeout=10,
+ check=False,
+ )
+ return json.loads(report.read_text(encoding="utf-8")), checked
+
+ def test_medium_and_high_findings_survive_native_sarif(self):
+ report, checked = self.scan(
+ "import subprocess\ncommand = input()\n"
+ "subprocess.run(command, shell=True)\n"
+ "open('/tmp/bandit-fixture')\n"
+ "hosts = (\n '127.0.0.1',\n '0.0.0.0',\n)\n"
+ )
+ self.assertEqual(checked.returncode, 0, checked.stdout + checked.stderr)
+ self.assertEqual(
+ {row["issue_severity"] for row in report["results"]},
+ {"HIGH", "MEDIUM"},
+ )
+ self.assertTrue(
+ {"B108", "B602"}.issubset(
+ {row["test_id"] for row in report["results"]}
+ )
+ )
+
+ def test_reviewed_rule_families_still_detect_unsafe_examples(self):
+ report, checked = self.scan(
+ "import requests\nfrom datasets import load_dataset\n"
+ "from markupsafe import Markup\n"
+ "name = input()\nquery = f'SELECT value FROM {name}'\n"
+ "host = '0.0.0.0'\nrequests.get('https://example.invalid')\n"
+ "Markup(input())\nload_dataset('fixture/data')\n"
+ )
+ self.assertEqual(checked.returncode, 0, checked.stdout + checked.stderr)
+ rules = {row["test_id"] for row in report["results"]}
+ self.assertTrue(
+ {"B104", "B113", "B608", "B615", "B704"}.issubset(rules)
+ )
+
+ def test_narrow_annotation_keeps_other_rules_and_statements(self):
+ report, checked = self.scan(
+ "import requests\nfrom markupsafe import Markup\n"
+ "requests.get('https://example.invalid', verify=False) # nosec B113\n"
+ "def render(value):\n"
+ " reviewed = Markup(value) # nosec B704\n"
+ " return Markup(value)\n"
+ )
+ self.assertEqual(checked.returncode, 0, checked.stdout + checked.stderr)
+ rules = [row["test_id"] for row in report["results"]]
+ self.assertIn("B501", rules)
+ self.assertNotIn("B113", rules)
+ self.assertEqual(rules.count("B704"), 1)
+
+ def test_complete_clean_scan_is_valid(self):
+ report, checked = self.scan("value = 1\n")
+ self.assertEqual(report["results"], [])
+ self.assertEqual(checked.returncode, 0, checked.stdout + checked.stderr)
+
+ def test_parse_failure_is_rejected_even_with_exit_zero(self):
+ report, checked = self.scan("broken (\n")
+ self.assertTrue(report["errors"])
+ self.assertEqual(checked.returncode, 1)
+ self.assertIn("scan errors", checked.stdout)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/ci/standalone/test_bandit_report.py b/tests/ci/standalone/test_bandit_report.py
new file mode 100644
index 0000000000..adae322762
--- /dev/null
+++ b/tests/ci/standalone/test_bandit_report.py
@@ -0,0 +1,152 @@
+"""Standalone policy checks for complete native Bandit reports."""
+
+# allow: no-sut-import — imports only the standalone report policy.
+
+import copy
+import importlib.util
+from pathlib import Path
+import tempfile
+import unittest
+
+ROOT = Path(__file__).resolve().parents[3]
+SPEC = importlib.util.spec_from_file_location(
+ "bandit_policy", ROOT / ".github/scripts/check_bandit_report.py"
+)
+POLICY = importlib.util.module_from_spec(SPEC)
+SPEC.loader.exec_module(POLICY)
+
+
+class ReportTests(unittest.TestCase):
+ def setUp(self):
+ self.directory = tempfile.TemporaryDirectory()
+ self.addCleanup(self.directory.cleanup)
+ self.source = Path(self.directory.name)
+ self.filename = self.source / "probe %.py"
+ self.filename.write_text("value = 1\n", encoding="utf-8")
+ metrics = {"_totals": {"loc": 1}, str(self.filename): {"loc": 1}}
+ self.report = {"errors": [], "results": [], "metrics": metrics}
+ self.sarif = {
+ "version": "2.1.0",
+ "runs": [
+ {
+ "tool": {"driver": {"name": "Bandit", "version": "1.9.4"}},
+ "results": [],
+ "invocations": [{"executionSuccessful": True}],
+ "properties": {"metrics": copy.deepcopy(metrics)},
+ }
+ ],
+ }
+
+ def check(self):
+ return POLICY.validate(self.report, self.sarif, self.source)
+
+ def finding(self, severity="MEDIUM"):
+ self.report["results"] = [
+ {
+ "test_id": "B108",
+ "filename": str(self.filename),
+ "line_number": 1,
+ "line_range": [1],
+ "issue_severity": severity,
+ }
+ ]
+ self.sarif["runs"][0]["tool"]["driver"]["rules"] = [{"id": "B108"}]
+ self.sarif["runs"][0]["results"] = [
+ {
+ "ruleId": "B108",
+ "level": POLICY.LEVELS.get(severity, "note"),
+ "properties": {"issue_severity": severity},
+ "locations": [
+ {
+ "physicalLocation": {
+ "artifactLocation": {"uri": self.filename.as_uri()},
+ "region": {"startLine": 1},
+ }
+ }
+ ],
+ }
+ ]
+
+ def test_clean_scan_and_native_uri_encoding(self):
+ self.assertEqual(self.check()[0], 1)
+ self.finding()
+ self.assertEqual(self.check()[1], {"MEDIUM": 1})
+
+ def test_native_medium_level_uses_sarif_warning_default(self):
+ self.finding()
+ self.sarif["runs"][0]["results"][0].pop("level")
+ self.assertEqual(self.check()[1], {"MEDIUM": 1})
+
+ def test_errors_and_missing_error_status_fail(self):
+ for value in (None, [{"reason": "syntax error"}]):
+ with self.subTest(value=value):
+ self.report["errors"] = value
+ with self.assertRaisesRegex(ValueError, "scan errors"):
+ self.check()
+
+ def test_unscanned_source_file_fails(self):
+ (self.source / "unscanned.py").write_text(
+ "value = 2\n", encoding="utf-8"
+ )
+ with self.assertRaisesRegex(ValueError, "every target"):
+ self.check()
+
+ def test_no_source_metrics_fail(self):
+ self.report["metrics"] = {"_totals": {"loc": 0}}
+ with self.assertRaisesRegex(ValueError, "any source code"):
+ self.check()
+
+ def test_reports_must_cover_same_source(self):
+ self.sarif["runs"][0]["properties"]["metrics"]["_totals"]["loc"] = 2
+ with self.assertRaisesRegex(ValueError, "different source"):
+ self.check()
+
+ def test_dropped_or_duplicated_sarif_findings_fail(self):
+ self.finding()
+ rows = self.sarif["runs"][0]["results"]
+ for changes in ([], rows * 2):
+ with self.subTest(rows=len(changes)):
+ self.sarif["runs"][0]["results"] = changes
+ with self.assertRaisesRegex(ValueError, "findings differ"):
+ self.check()
+
+ def test_sarif_level_cannot_downgrade_medium_finding(self):
+ self.finding()
+ self.sarif["runs"][0]["results"][0]["level"] = "note"
+ with self.assertRaisesRegex(ValueError, "inconsistent severity"):
+ self.check()
+
+ def test_failed_execution_and_error_notifications_fail(self):
+ run = self.sarif["runs"][0]
+ for invocation in (
+ {},
+ {"executionSuccessful": False},
+ {
+ "executionSuccessful": True,
+ "toolConfigurationNotifications": [{"level": "error"}],
+ },
+ {
+ "executionSuccessful": True,
+ "toolExecutionNotifications": [{"level": "error"}],
+ },
+ ):
+ with self.subTest(invocation=invocation):
+ run["invocations"] = [invocation]
+ with self.assertRaises(ValueError):
+ self.check()
+
+ def test_finding_requires_rule_and_scanned_local_location(self):
+ self.finding()
+ run = self.sarif["runs"][0]
+ run["tool"]["driver"]["rules"] = []
+ with self.assertRaisesRegex(ValueError, "rule descriptor"):
+ self.check()
+ self.finding()
+ location = run["results"][0]["locations"][0]["physicalLocation"]
+ location["artifactLocation"]["uri"] = "https://example.invalid/probe.py"
+ with self.assertRaisesRegex(ValueError, "non-local"):
+ self.check()
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/ci/standalone/test_bandit_reviewed_context.py b/tests/ci/standalone/test_bandit_reviewed_context.py
new file mode 100644
index 0000000000..91a4715085
--- /dev/null
+++ b/tests/ci/standalone/test_bandit_reviewed_context.py
@@ -0,0 +1,56 @@
+"""Preserve the trust assumptions behind contextual Bandit annotations."""
+
+# allow: no-sut-import — validates the reviewed dependency and template inputs.
+
+import ast
+from pathlib import Path
+import re
+import tomllib
+import unittest
+
+ROOT = Path(__file__).resolve().parents[3]
+
+
+class ReviewedContextTests(unittest.TestCase):
+ def test_dataset_loader_stays_above_the_reviewed_security_floor(self):
+ project = tomllib.loads(
+ (ROOT / "pyproject.toml").read_text(encoding="utf-8")
+ )
+ requirements = [
+ row
+ for row in project["project"]["dependencies"]
+ if row.startswith("datasets")
+ ]
+ self.assertEqual(len(requirements), 1)
+ constraint = re.fullmatch(
+ r"datasets>=(\d+)\.(\d+)\.(\d+),<6", requirements[0], re.ASCII
+ )
+ self.assertIsNotNone(
+ constraint, "A new datasets constraint needs annotation review"
+ )
+ self.assertGreaterEqual(tuple(map(int, constraint.groups())), (5, 0, 1))
+
+ def test_development_asset_entries_are_trusted_template_literals(self):
+ calls = 0
+ for path in (ROOT / "src/local_deep_research/web/templates").rglob(
+ "*.html"
+ ):
+ template = path.read_text(encoding="utf-8")
+ for arguments in re.findall(
+ r"\bvite_asset\s*\((.*?)\)", template, re.DOTALL
+ ):
+ expression = ast.parse(
+ f"vite_asset({arguments})", mode="eval"
+ ).body
+ for argument in [
+ *expression.args,
+ *(keyword.value for keyword in expression.keywords),
+ ]:
+ self.assertIsInstance(argument, ast.Constant, str(path))
+ self.assertIsInstance(argument.value, str, str(path))
+ calls += 1
+ self.assertGreater(calls, 0, "No asset-template callers were checked")
+
+
+if __name__ == "__main__":
+ unittest.main()