codewatch-scan 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codewatch_scan-0.1.0/LICENSE +21 -0
- codewatch_scan-0.1.0/MANIFEST.in +6 -0
- codewatch_scan-0.1.0/PKG-INFO +81 -0
- codewatch_scan-0.1.0/README.md +324 -0
- codewatch_scan-0.1.0/catalog/codewatch/rules/javascript-crypto.yml +224 -0
- codewatch_scan-0.1.0/catalog/codewatch/rules/javascript-injection.yml +116 -0
- codewatch_scan-0.1.0/catalog/codewatch/rules/javascript-taint.yml +1539 -0
- codewatch_scan-0.1.0/catalog/codewatch/rules/javascript-web.yml +562 -0
- codewatch_scan-0.1.0/catalog/codewatch/rules/php-web.yml +719 -0
- codewatch_scan-0.1.0/catalog/codewatch/rules/python-crypto.yml +203 -0
- codewatch_scan-0.1.0/catalog/codewatch/rules/python-django.yml +267 -0
- codewatch_scan-0.1.0/catalog/codewatch/rules/python-injection.yml +115 -0
- codewatch_scan-0.1.0/catalog/codewatch/rules/python-web.yml +3382 -0
- codewatch_scan-0.1.0/catalog/custom/mappings.json +360 -0
- codewatch_scan-0.1.0/catalog/custom/overrides.json +4 -0
- codewatch_scan-0.1.0/catalog/custom/rules/django-settings.yml +19 -0
- codewatch_scan-0.1.0/catalog/imported/changes.json +5 -0
- codewatch_scan-0.1.0/catalog/imported/docs.json +1143 -0
- codewatch_scan-0.1.0/catalog/imported/meta.json +54 -0
- codewatch_scan-0.1.0/catalog/imported/rules.json +85421 -0
- codewatch_scan-0.1.0/catalog/imported/standards.json +11191 -0
- codewatch_scan-0.1.0/codewatch/__init__.py +0 -0
- codewatch_scan-0.1.0/codewatch/__main__.py +14 -0
- codewatch_scan-0.1.0/codewatch/asgi.py +16 -0
- codewatch_scan-0.1.0/codewatch/settings.py +175 -0
- codewatch_scan-0.1.0/codewatch/urls.py +40 -0
- codewatch_scan-0.1.0/codewatch/wsgi.py +16 -0
- codewatch_scan-0.1.0/codewatch_scan.egg-info/PKG-INFO +81 -0
- codewatch_scan-0.1.0/codewatch_scan.egg-info/SOURCES.txt +169 -0
- codewatch_scan-0.1.0/codewatch_scan.egg-info/dependency_links.txt +1 -0
- codewatch_scan-0.1.0/codewatch_scan.egg-info/entry_points.txt +4 -0
- codewatch_scan-0.1.0/codewatch_scan.egg-info/requires.txt +21 -0
- codewatch_scan-0.1.0/codewatch_scan.egg-info/top_level.txt +2 -0
- codewatch_scan-0.1.0/core/__init__.py +0 -0
- codewatch_scan-0.1.0/core/analyzers/__init__.py +19 -0
- codewatch_scan-0.1.0/core/analyzers/accessibility.py +199 -0
- codewatch_scan-0.1.0/core/analyzers/base.py +192 -0
- codewatch_scan-0.1.0/core/analyzers/body_models.py +154 -0
- codewatch_scan-0.1.0/core/analyzers/codewatch_checks.py +394 -0
- codewatch_scan-0.1.0/core/analyzers/constant_branches.py +251 -0
- codewatch_scan-0.1.0/core/analyzers/containers.py +316 -0
- codewatch_scan-0.1.0/core/analyzers/coverage.py +131 -0
- codewatch_scan-0.1.0/core/analyzers/dependencies.py +347 -0
- codewatch_scan-0.1.0/core/analyzers/drf_serializers.py +65 -0
- codewatch_scan-0.1.0/core/analyzers/else_branches.py +106 -0
- codewatch_scan-0.1.0/core/analyzers/extra.py +400 -0
- codewatch_scan-0.1.0/core/analyzers/flask_resources.py +65 -0
- codewatch_scan-0.1.0/core/analyzers/inline_scripts.py +50 -0
- codewatch_scan-0.1.0/core/analyzers/jinja_sandboxes.py +63 -0
- codewatch_scan-0.1.0/core/analyzers/match_statements.py +148 -0
- codewatch_scan-0.1.0/core/analyzers/multi_tools.py +888 -0
- codewatch_scan-0.1.0/core/analyzers/php_template_sinks.py +444 -0
- codewatch_scan-0.1.0/core/analyzers/project_checks.py +150 -0
- codewatch_scan-0.1.0/core/analyzers/python_tools.py +333 -0
- codewatch_scan-0.1.0/core/analyzers/route_converters.py +237 -0
- codewatch_scan-0.1.0/core/analyzers/slices.py +94 -0
- codewatch_scan-0.1.0/core/analyzers/starred_targets.py +42 -0
- codewatch_scan-0.1.0/core/analyzers/stored_fields.py +386 -0
- codewatch_scan-0.1.0/core/analyzers/summaries.py +1387 -0
- codewatch_scan-0.1.0/core/analyzers/template_sinks.py +162 -0
- codewatch_scan-0.1.0/core/api.py +360 -0
- codewatch_scan-0.1.0/core/apps.py +6 -0
- codewatch_scan-0.1.0/core/benchmark.py +955 -0
- codewatch_scan-0.1.0/core/catalog/__init__.py +190 -0
- codewatch_scan-0.1.0/core/catalog/build.py +84 -0
- codewatch_scan-0.1.0/core/catalog/merge.py +122 -0
- codewatch_scan-0.1.0/core/catalog/sources.py +418 -0
- codewatch_scan-0.1.0/core/catalog/standards.py +119 -0
- codewatch_scan-0.1.0/core/catalog/update.py +99 -0
- codewatch_scan-0.1.0/core/catalog_views.py +115 -0
- codewatch_scan-0.1.0/core/client.py +645 -0
- codewatch_scan-0.1.0/core/collect.py +518 -0
- codewatch_scan-0.1.0/core/duplicates.py +60 -0
- codewatch_scan-0.1.0/core/fingerprint.py +25 -0
- codewatch_scan-0.1.0/core/folders.py +73 -0
- codewatch_scan-0.1.0/core/gate.py +77 -0
- codewatch_scan-0.1.0/core/git.py +149 -0
- codewatch_scan-0.1.0/core/jobs.py +86 -0
- codewatch_scan-0.1.0/core/management/__init__.py +0 -0
- codewatch_scan-0.1.0/core/management/commands/__init__.py +0 -0
- codewatch_scan-0.1.0/core/management/commands/addproject.py +40 -0
- codewatch_scan-0.1.0/core/management/commands/buildcatalog.py +15 -0
- codewatch_scan-0.1.0/core/management/commands/scan.py +74 -0
- codewatch_scan-0.1.0/core/management/commands/updatecatalog.py +14 -0
- codewatch_scan-0.1.0/core/mcp_server.py +140 -0
- codewatch_scan-0.1.0/core/middleware.py +17 -0
- codewatch_scan-0.1.0/core/migrations/0001_initial.py +115 -0
- codewatch_scan-0.1.0/core/migrations/0002_auth_tokens_a11y.py +60 -0
- codewatch_scan-0.1.0/core/migrations/0003_default_admin.py +43 -0
- codewatch_scan-0.1.0/core/migrations/0004_project_members.py +28 -0
- codewatch_scan-0.1.0/core/migrations/0005_uploads_and_sources.py +55 -0
- codewatch_scan-0.1.0/core/migrations/0006_thresholds.py +28 -0
- codewatch_scan-0.1.0/core/migrations/0007_also_reported_by.py +18 -0
- codewatch_scan-0.1.0/core/migrations/0008_new_code_period.py +18 -0
- codewatch_scan-0.1.0/core/migrations/0009_resolution_safe.py +18 -0
- codewatch_scan-0.1.0/core/migrations/0010_analysis_progress.py +18 -0
- codewatch_scan-0.1.0/core/migrations/0011_overall_gate_conditions.py +20 -0
- codewatch_scan-0.1.0/core/migrations/__init__.py +0 -0
- codewatch_scan-0.1.0/core/models.py +323 -0
- codewatch_scan-0.1.0/core/network.py +41 -0
- codewatch_scan-0.1.0/core/paths.py +29 -0
- codewatch_scan-0.1.0/core/ratings.py +67 -0
- codewatch_scan-0.1.0/core/runner.py +168 -0
- codewatch_scan-0.1.0/core/templates/core/account.html +30 -0
- codewatch_scan-0.1.0/core/templates/core/analysis.html +49 -0
- codewatch_scan-0.1.0/core/templates/core/base.html +121 -0
- codewatch_scan-0.1.0/core/templates/core/form_table.html +12 -0
- codewatch_scan-0.1.0/core/templates/core/gate_badge.html +1 -0
- codewatch_scan-0.1.0/core/templates/core/index.html +26 -0
- codewatch_scan-0.1.0/core/templates/core/issues.html +38 -0
- codewatch_scan-0.1.0/core/templates/core/login.html +13 -0
- codewatch_scan-0.1.0/core/templates/core/new_project.html +27 -0
- codewatch_scan-0.1.0/core/templates/core/password_change.html +10 -0
- codewatch_scan-0.1.0/core/templates/core/project.html +40 -0
- codewatch_scan-0.1.0/core/templates/core/rating.html +1 -0
- codewatch_scan-0.1.0/core/templates/core/ratings.html +32 -0
- codewatch_scan-0.1.0/core/templates/core/rule.html +33 -0
- codewatch_scan-0.1.0/core/templates/core/rules.html +42 -0
- codewatch_scan-0.1.0/core/templates/core/scan_progress.html +2 -0
- codewatch_scan-0.1.0/core/templates/core/settings.html +36 -0
- codewatch_scan-0.1.0/core/templates/core/source.html +15 -0
- codewatch_scan-0.1.0/core/templates/core/standards.html +30 -0
- codewatch_scan-0.1.0/core/templates/core/user_edit.html +15 -0
- codewatch_scan-0.1.0/core/templates/core/users.html +18 -0
- codewatch_scan-0.1.0/core/templatetags/__init__.py +0 -0
- codewatch_scan-0.1.0/core/templatetags/codewatch.py +42 -0
- codewatch_scan-0.1.0/core/tool_setup.py +68 -0
- codewatch_scan-0.1.0/core/views.py +564 -0
- codewatch_scan-0.1.0/docs/pypi.md +38 -0
- codewatch_scan-0.1.0/pyproject.toml +83 -0
- codewatch_scan-0.1.0/setup.cfg +4 -0
- codewatch_scan-0.1.0/setup.py +37 -0
- codewatch_scan-0.1.0/tests/test_a11y.py +109 -0
- codewatch_scan-0.1.0/tests/test_auth.py +71 -0
- codewatch_scan-0.1.0/tests/test_benchmark.py +444 -0
- codewatch_scan-0.1.0/tests/test_benchmark_fetch.py +34 -0
- codewatch_scan-0.1.0/tests/test_benchmark_reports.py +51 -0
- codewatch_scan-0.1.0/tests/test_catalog.py +265 -0
- codewatch_scan-0.1.0/tests/test_check.py +116 -0
- codewatch_scan-0.1.0/tests/test_client.py +126 -0
- codewatch_scan-0.1.0/tests/test_detection.py +4453 -0
- codewatch_scan-0.1.0/tests/test_else_branches.py +29 -0
- codewatch_scan-0.1.0/tests/test_export_misses.py +121 -0
- codewatch_scan-0.1.0/tests/test_javascript_express.py +139 -0
- codewatch_scan-0.1.0/tests/test_javascript_fetched_data.py +67 -0
- codewatch_scan-0.1.0/tests/test_new_project.py +139 -0
- codewatch_scan-0.1.0/tests/test_packaging.py +80 -0
- codewatch_scan-0.1.0/tests/test_php_templates.py +176 -0
- codewatch_scan-0.1.0/tests/test_php_web.py +84 -0
- codewatch_scan-0.1.0/tests/test_python_gap_notes.py +506 -0
- codewatch_scan-0.1.0/tests/test_python_nosql.py +94 -0
- codewatch_scan-0.1.0/tests/test_python_own_code.py +126 -0
- codewatch_scan-0.1.0/tests/test_python_tools_config.py +51 -0
- codewatch_scan-0.1.0/tests/test_research_report.py +81 -0
- codewatch_scan-0.1.0/tests/test_reviewed.py +213 -0
- codewatch_scan-0.1.0/tests/test_scan.py +215 -0
- codewatch_scan-0.1.0/tests/test_security.py +356 -0
- codewatch_scan-0.1.0/tests/test_triage.py +19 -0
- codewatch_scan-0.1.0/tests/test_units.py +645 -0
- codewatch_scan-0.1.0/tools/analyzers.lock +786 -0
- codewatch_scan-0.1.0/tools/axe-scan.mjs +45 -0
- codewatch_scan-0.1.0/tools/checkov.lock +2463 -0
- codewatch_scan-0.1.0/tools/codewatch-checks.mjs +99 -0
- codewatch_scan-0.1.0/tools/eslint-a11y.config.js +16 -0
- codewatch_scan-0.1.0/tools/eslint-quality.config.js +63 -0
- codewatch_scan-0.1.0/tools/eslint-typed.config.js +18 -0
- codewatch_scan-0.1.0/tools/package-lock.json +6102 -0
- codewatch_scan-0.1.0/tools/package.json +32 -0
- codewatch_scan-0.1.0/tools/rule-metadata.mjs +56 -0
- codewatch_scan-0.1.0/tools/semgrep.lock +1232 -0
- codewatch_scan-0.1.0/tools/stylelint.config.json +11 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shwan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# The source distribution carries what setup.py bundles into a wheel (see core/paths.py).
|
|
2
|
+
graft catalog
|
|
3
|
+
include tools/package.json tools/package-lock.json tools/*.lock tools/*.config.js tools/*.config.json tools/*.mjs
|
|
4
|
+
include docs/pypi.md
|
|
5
|
+
graft core/templates
|
|
6
|
+
global-exclude __pycache__ *.py[cod]
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codewatch-scan
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Security and quality checks for Python web apps (Django, Flask, FastAPI) and the JavaScript they ship
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/shwan-ps5/codewatch
|
|
7
|
+
Project-URL: Source, https://github.com/shwan-ps5/codewatch
|
|
8
|
+
Project-URL: Issues, https://github.com/shwan-ps5/codewatch/issues
|
|
9
|
+
Project-URL: Benchmarks, https://github.com/shwan-ps5/codewatch/blob/detection-gaps/docs/benchmarks.md
|
|
10
|
+
Keywords: security,sast,static-analysis,semgrep,django,flask,fastapi,code-quality
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Framework :: Django
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Topic :: Security
|
|
19
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
20
|
+
Requires-Python: >=3.12
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: Django<6,>=5.2
|
|
24
|
+
Requires-Dist: ruff==0.17.3
|
|
25
|
+
Requires-Dist: radon==6.0.1
|
|
26
|
+
Requires-Dist: bandit==1.9.4
|
|
27
|
+
Requires-Dist: lizard==1.24.3
|
|
28
|
+
Requires-Dist: pip-audit==2.10.1
|
|
29
|
+
Requires-Dist: complexipy==8.3.0
|
|
30
|
+
Requires-Dist: basedpyright==1.40.2
|
|
31
|
+
Requires-Dist: detect-secrets==1.5.0
|
|
32
|
+
Requires-Dist: markdown-it-py
|
|
33
|
+
Requires-Dist: PyYAML
|
|
34
|
+
Requires-Dist: defusedxml
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: pytest; extra == "dev"
|
|
37
|
+
Requires-Dist: pytest-django; extra == "dev"
|
|
38
|
+
Requires-Dist: pytest-xdist; extra == "dev"
|
|
39
|
+
Requires-Dist: coverage; extra == "dev"
|
|
40
|
+
Provides-Extra: mcp
|
|
41
|
+
Requires-Dist: mcp<2,>=1.30; extra == "mcp"
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
# codewatch-scan
|
|
45
|
+
|
|
46
|
+
Security and quality checks for Python web apps (Django, Flask, FastAPI) and the JavaScript they ship, built on
|
|
47
|
+
open-source analyzers (Semgrep with codewatch's own taint rules, ruff, bandit, ESLint, checkov, detect-secrets,
|
|
48
|
+
pip-audit and more). It runs locally and uploads nothing.
|
|
49
|
+
|
|
50
|
+
**Alpha.** The rules are still being written, and the commands and output may change. On real Python CVE fixes it
|
|
51
|
+
was never tuned on, it finds about 28% (11 of 40, in verdict mode). Benchmarks, method and caveats are at
|
|
52
|
+
[github.com/shwan-ps5/codewatch](https://github.com/shwan-ps5/codewatch#how-well-it-works).
|
|
53
|
+
|
|
54
|
+
## Install
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pipx install codewatch-scan # or: pip install codewatch-scan, in a virtualenv
|
|
58
|
+
codewatch setup # Semgrep and checkov (each in its own venv) and the Node analyzers
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`codewatch setup` installs every analyzer at the version and hash codewatch is tested with, into
|
|
62
|
+
`~/.local/share/codewatch/tools` (`CODEWATCH_TOOLS` moves it). The Node analyzers need Node.js 20 or later.
|
|
63
|
+
Linux and macOS; on Windows, use the Docker image from the repository.
|
|
64
|
+
|
|
65
|
+
## Use
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
cd your-repo
|
|
69
|
+
codewatch check --all # every file; issues are listed, blocking ones marked !
|
|
70
|
+
codewatch check # only the files you changed, and only issues on changed lines block
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The exit code is 1 when a bug, a vulnerability or a blocker/critical issue blocks, and 2 when an analyzer failed or
|
|
74
|
+
isn't installed, so the files weren't fully checked. `codewatch init --hook pre-commit` installs a git hook
|
|
75
|
+
that checks each commit's staged files.
|
|
76
|
+
|
|
77
|
+
The self-hosted server (history, new-code tracking, quality gates) also ships in this package
|
|
78
|
+
(`python -m codewatch migrate`, then `python -m codewatch runserver`), but the repository's Docker image is the
|
|
79
|
+
easier way to run it.
|
|
80
|
+
|
|
81
|
+
Licence: MIT.
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
# codewatch
|
|
2
|
+
|
|
3
|
+
[](https://github.com/shwan-ps5/codewatch/actions/workflows/codewatch.yml)
|
|
4
|
+
|
|
5
|
+
> **Work in Progress** — usable for local scanning, but the data model, CLI, API and UI may change without notice. Expect rough edges.
|
|
6
|
+
|
|
7
|
+
Self-hosted code-quality server: branch analysis, new-code tracking, quality gates, coverage, duplication, dependency CVEs, security hotspots and accessibility checks, built on open-source analyzers. Django + SQLite, no containers or JVM.
|
|
8
|
+
|
|
9
|
+
Scans normally run **on the developer's machine** against the local working copy (private repos never leave it) and upload the results. The server can also clone and scan a repository URL itself.
|
|
10
|
+
|
|
11
|
+
## How well it works
|
|
12
|
+
|
|
13
|
+
The fairest numbers are from code the rules were never tuned on, so they come first. Detection is "found" in
|
|
14
|
+
verdict mode, i.e. findings that claim a vulnerability.
|
|
15
|
+
|
|
16
|
+
| Measure (never used to write or tune rules) | Result |
|
|
17
|
+
|---|---|
|
|
18
|
+
| Python CVE fix pairs, blind, round 2: 40 back-end cases (half of them, run once on 2026-11-28) | 11 of 40 found (28%), 3 still flagged after the fix; review mode 20 found, 9 still flagged |
|
|
19
|
+
| Python front-end CVE fix pairs, blind, round 2: 10 cases (the same half) | 1 of 10 found; review mode 6 found, 4 still flagged |
|
|
20
|
+
| Python CVE fix pairs, blind, round 1 | 2 of 5 found, 1 still flagged after its fix |
|
|
21
|
+
| SecurityEval Copilot answers, Python (held out) | finds 34%, false alarms 0% |
|
|
22
|
+
| SecurityEval InCoder answers, Python (held out) | finds 31%, false alarms 0% |
|
|
23
|
+
| Vulnerable-Code-Snippets, JS/TS (held out) | 11 of 22 flagged |
|
|
24
|
+
| Ordinary apps, three blind sets of four (Django, FastAPI, Express, NestJS) | false alarms in 2, 2 and 4 of the 4 apps |
|
|
25
|
+
|
|
26
|
+
On the Python CVE pairs the rules were tuned on, codewatch finds 70 of 109 (64%). On advisories it has never
|
|
27
|
+
seen, it finds 28% (11 of 40; with this few cases, roughly 15-44%). So most of the tuned number is the tuning,
|
|
28
|
+
not the general ability. The blind run had other benchmarks running at the same time, and under load Semgrep can
|
|
29
|
+
give up on slow rules, so a case or two may have dropped out. That doesn't come close to closing the gap. On ordinary apps it hasn't seen, expect some false alarms;
|
|
30
|
+
[docs/rule-trust.md](docs/rule-trust.md) shows, rule by rule, how often each one is right on the CVE pairs and
|
|
31
|
+
how often it fires on clean apps. Everything is in [Benchmarks](#benchmarks).
|
|
32
|
+
|
|
33
|
+
**Scope.** Python web apps (Django, Flask, FastAPI) are the focus and where the rules are strongest. The
|
|
34
|
+
JavaScript/TypeScript and PHP rules are earlier-stage (22 of 103 and 75 of 341 CVE pairs found). Other languages
|
|
35
|
+
get the Semgrep registry and complexity checks only.
|
|
36
|
+
|
|
37
|
+
## Quick start: check a repository
|
|
38
|
+
|
|
39
|
+
No server needed. Every analyzer runs locally on the files, and nothing is uploaded.
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pipx install codewatch-scan # the package; the command is codewatch
|
|
43
|
+
codewatch setup # Semgrep, checkov and the Node analyzers at their pinned versions (Node.js 20+)
|
|
44
|
+
codewatch check --all # every file; issues are listed, blocking ones marked !
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`check` exits 1 when something blocks and 2 when an analyzer failed or isn't installed, so a missing tool never
|
|
48
|
+
passes as a clean result. Or in Docker, with every analyzer in the image:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
docker build -t codewatch https://github.com/shwan-ps5/codewatch.git
|
|
52
|
+
docker run --rm -v "$PWD:/src" codewatch check --all # every file; issues are listed, blocking ones marked !
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
As a GitHub Actions step, after `actions/checkout` (pin a commit SHA):
|
|
56
|
+
|
|
57
|
+
```yaml
|
|
58
|
+
- uses: shwan-ps5/codewatch@<commit sha>
|
|
59
|
+
with:
|
|
60
|
+
strict: "false" # "true": any open issue fails the job
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
As a [pre-commit](https://pre-commit.com) hook, run in the Docker image on the files a commit changes:
|
|
64
|
+
|
|
65
|
+
```yaml
|
|
66
|
+
- repo: https://github.com/shwan-ps5/codewatch
|
|
67
|
+
rev: <commit sha>
|
|
68
|
+
hooks:
|
|
69
|
+
- id: codewatch
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Or from a clone: `pip install -e .`, `make tools`, then `venv/bin/codewatch check --all`. The server below adds
|
|
73
|
+
history, new-code tracking, ratings and the quality gate. To run the server in Docker:
|
|
74
|
+
`docker run -d -p 8100:8100 -v codewatch-data:/data -e CODEWATCH_ALLOWED_HOSTS=your.host --entrypoint /opt/codewatch/docker-serve.sh codewatch`.
|
|
75
|
+
|
|
76
|
+
## Server setup
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
git clone https://github.com/shwan-ps5/codewatch && cd codewatch
|
|
80
|
+
python3 -m venv venv && venv/bin/pip install -e '.[dev,mcp]'
|
|
81
|
+
make tools # Node analyzers, semgrep and checkov (own venvs), headless Chromium (needs Node 20+)
|
|
82
|
+
venv/bin/python manage.py migrate
|
|
83
|
+
make run # http://127.0.0.1:8100
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Log in as **admin**: `migrate` prints where its first password is (`~/.cache/codewatch/admin-password.txt`, readable only by you), or set `CODEWATCH_ADMIN_PASSWORD` before the first `migrate`. You'll be asked to change it straight away. Add users under **Users**. Optional: `cppcheck` (apt) for C/C++.
|
|
87
|
+
|
|
88
|
+
For anything beyond localhost, put it behind HTTPS and set `CODEWATCH_ALLOWED_HOSTS` (comma-separated host names) and `CODEWATCH_HTTPS=1` (secure cookies, HSTS). The secret key is generated once into `~/.cache/codewatch/secret_key` unless `CODEWATCH_SECRET_KEY` is set; `CODEWATCH_DEBUG=1` turns on Django's debug pages, never on a shared server. Ten wrong passwords in a row lock a username out for 15 minutes.
|
|
89
|
+
|
|
90
|
+
What the server does on users' behalf is limited to what they could do themselves: their projects clone with none of the server's git credentials, reach only public addresses (repository, accessibility pages) and use only Semgrep registry rulesets; checkouts lose their symlinks, and a repository's own virtualenv and package builds are never run (pip-audit checks pinned requirements as written). Projects an administrator owns, or added with `manage.py addproject`, may use the server's credentials, its local network and local paths. Analyzers still read repository content, so for untrusted code run the server in a container.
|
|
91
|
+
|
|
92
|
+
## Scanning from your working copy
|
|
93
|
+
|
|
94
|
+
Each developer installs the client (same checkout, `pip install -e .` plus `make tools`) and creates a token on their **Account** page.
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
export CODEWATCH_URL=https://codewatch.example
|
|
98
|
+
export CODEWATCH_TOKEN=cw_... # scan-scope token; never commit it
|
|
99
|
+
|
|
100
|
+
cd ~/dev/my-app
|
|
101
|
+
codewatch init --hook pre-push # writes codewatch-project.json, installs the hook
|
|
102
|
+
codewatch coverage # run tests with coverage -> coverage.xml
|
|
103
|
+
codewatch scan # analyse and upload; creates the project if it doesn't exist
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`codewatch scan` works without any config: the project key defaults to the folder name and the main branch to origin's HEAD branch. Uncommitted and untracked (non-ignored) files are included, and the branch name comes from git, so every branch gets its own results and quality gate, visible before it is merged.
|
|
107
|
+
|
|
108
|
+
`codewatch-project.json` (commit it):
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"projectKey": "my-app",
|
|
113
|
+
"projectName": "My App",
|
|
114
|
+
"mainBranch": "main",
|
|
115
|
+
"serverUrl": "https://codewatch.example",
|
|
116
|
+
"testCommand": "venv/bin/pytest --cov --cov-report=xml",
|
|
117
|
+
"coverageReport": "coverage.xml",
|
|
118
|
+
"disabledAnalyzers": ["semgrep"]
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
All keys are optional. `serverUrl` is used only if you trust it: `codewatch init --url` records the server you give it in `~/.config/codewatch/servers.txt` (add others there, or set `CODEWATCH_URL`). The file is part of the repository, so a branch could otherwise send your token and code anywhere. The token only goes over HTTPS, except to localhost. Without `testCommand`, `codewatch coverage` runs `coverage run -m pytest` with the project's `venv/`/`.venv/` Python, or `npm test` under c8 for Node projects.
|
|
123
|
+
|
|
124
|
+
### Git hook
|
|
125
|
+
|
|
126
|
+
`codewatch init --hook pre-push` installs a hook that runs `codewatch coverage` (a test failure stops the push) and then `codewatch scan`. By default a failing quality gate is only reported; `--strict` makes it block the push. An existing hook is never overwritten.
|
|
127
|
+
|
|
128
|
+
`codewatch init --hook pre-commit` installs a hook that runs `codewatch check` on the staged files instead: every analyzer on just those files, locally, with nothing uploaded and none of the code run. A bug, a vulnerability or a blocker/critical issue **on a line the commit changes** stops it; older issues in the same files are listed but don't block (`git commit --no-verify` skips the hook). An analyzer that fails also stops it (exit 2), since the files weren't fully checked. Run it by hand too: `codewatch check` (the changed files), `codewatch check path/to/file.py`, or `--all-lines` to block on every issue in the named files. The project's settings come from the server when one is configured, else the defaults. Checks that need the whole project are left out: the dependency audit, coverage and live accessibility pages. Cross-file taint (input reaching a sink through a helper in another file) needs both files in the check, so the full `codewatch scan` remains the complete answer.
|
|
129
|
+
|
|
130
|
+
### Sharing a project
|
|
131
|
+
|
|
132
|
+
The project owner adds people under **Settings → Members**:
|
|
133
|
+
|
|
134
|
+
- **Contributor**: can upload scans of their own clone with their own token, and resolve issues.
|
|
135
|
+
- **Viewer**: can see results only.
|
|
136
|
+
|
|
137
|
+
Administrators see every project.
|
|
138
|
+
|
|
139
|
+
### codewatch on its own code
|
|
140
|
+
|
|
141
|
+
Every push runs [a workflow](.github/workflows/codewatch.yml) that installs the pinned analyzers, runs the lint and the tests, and then `codewatch check --all --strict`: every analyzer over the whole repository, where **any** open issue fails the run, whatever its kind or severity. No thresholds are raised for codewatch. The findings judged safe or false positives after reading them are in [`codewatch-reviews.json`](codewatch-reviews.json), each with its reason, and the run's summary page lists them, so those exceptions are public and can be questioned. The other exceptions are inline comments that switch a rule off for one line (`noqa`, `nosec`, `nosemgrep`, secret-scanner allowlists), each with its reason beside it or on the line above; moving the security ones into the reviews file is the next step. A review that no longer matches any finding fails the run, so the file can't keep reasons for code that has gone. `codewatch check` honours that file in any project, and the pre-commit hook gives the same answer locally before a commit leaves the machine.
|
|
142
|
+
|
|
143
|
+
## Languages
|
|
144
|
+
|
|
145
|
+
| Language / target | What runs |
|
|
146
|
+
|---|---|
|
|
147
|
+
| **Python** (incl. Django, Flask, FastAPI) | ruff (bugs, smells, Django rules), bandit (security), basedpyright (type errors such as None access and wrong arguments), radon (cyclomatic complexity, maintainability index), complexipy (cognitive complexity), semgrep registry rules (incl. Django/Flask/FastAPI security), pip-audit (dependency CVEs), codewatch checks |
|
|
148
|
+
| **JavaScript / TypeScript** | ESLint core rules plus eslint-plugin-security, lizard (complexity), semgrep, codewatch checks; jsx-a11y for JSX/TSX; known advisories for the versions pinned in package-lock.json, yarn.lock and pnpm-lock.yaml (looked up in OSV; development-only packages are hotspots) |
|
|
149
|
+
| **HTML / Django & Jinja templates** | html-validate accessibility rules (template tags are blanked, Alpine/Vue bindings understood) |
|
|
150
|
+
| **CSS** | stylelint (invalid values, unknown properties, duplicates) |
|
|
151
|
+
| **Live pages** | axe-core in headless Chromium: WCAG 2.2 AA including colour contrast |
|
|
152
|
+
| **C / C++** | cppcheck, lizard, semgrep |
|
|
153
|
+
| **Dockerfile, Terraform, Kubernetes, GitHub Actions** | checkov |
|
|
154
|
+
| **Any file** | detect-secrets (hard-coded secrets), jscpd (duplication) |
|
|
155
|
+
| **PHP** | semgrep registry rules, lizard, and codewatch taint rules (request data from superglobals and the common frameworks' request objects into SQL, OS commands, eval, file paths, HTML, redirects, outgoing URLs and `unserialize`, within one function); views in .phtml, CakePHP .ctp, Drupal .module/.theme and PHP .tpl files are scanned as PHP, and Twig, Blade, Latte and Smarty templates are read for values printed unescaped |
|
|
156
|
+
| **Java, Go, Ruby, Kotlin, Rust, C#…** | semgrep registry rules and lizard complexity only, for now |
|
|
157
|
+
|
|
158
|
+
codewatch's own checks (Python and JS/TS): **string literals repeated more than N times** in a file (default 3), and **regexes vulnerable to catastrophic backtracking (ReDoS)**, analysed with recheck. Complexity is checked two ways: cyclomatic complexity (radon for Python, lizard for other languages) is flagged above 10 and cognitive complexity (complexipy) above 15; either is critical above twice its threshold. Thresholds are per project.
|
|
159
|
+
|
|
160
|
+
codewatch also ships its own Semgrep rules (`catalog/codewatch/rules/`). Taint rules follow request data (Flask, Django, FastAPI, Starlette, Express, Koa, browser URL APIs) into SQL, NoSQL, OS commands, file paths, templates and HTML, redirects and `Location` headers, outgoing URLs (SSRF), regular expressions, XML parsers, deserializers, template engines (SSTI), LDAP/XPath queries and the session, and stop at validation such as an allowlist check, `int()`, `re.escape()` or a `startswith` guard that returns. Pattern rules catch flaws visible without a request source: quoted values formatted into SQL, tar extraction without a filter, template auto-escaping switched off, recursive merges open to prototype pollution, weak hashes used for passwords or signatures, weak ciphers and static IVs, disabled TLS verification, hard-coded JWT secrets, stack traces sent in responses, CORS that echoes any origin with credentials, HMAC signatures compared with `==`, and credential cookies without the Secure flag. Hotspot rules flag uploads stored under the client's file name without a type check, exception messages from a broad `except` sent to the client, a whole request body written to a model (mass assignment), redirects built from the request's own path, state-changing routes without the authentication middleware or login decorator their neighbours use, uploads without size limits, cookie protection switched off and secrets written to logs.
|
|
161
|
+
|
|
162
|
+
Issue types: bug, vulnerability, **security hotspot** (security-sensitive code to review), code smell, accessibility. When several tools report the same problem on the same line, it becomes one issue that lists the others ("also reported by").
|
|
163
|
+
|
|
164
|
+
**New code**: on a branch, everything changed since its merge-base with the main branch (plus uncommitted/untracked files for local scans); on main, everything since the previous analysis by default. Because that window restarts with every scan, a run of small commits can each fall under the 20-line minimum for coverage and duplication checks. Set **New code on the main branch** in project settings to `30d` (since the newest analysis at least 30 days old) or to a tag, branch or commit such as `v1.4` to keep the window open across scans; a ref that doesn't resolve or isn't in main's history falls back to the previous analysis. Issues are fingerprinted by rule + file + source text, so they keep their identity, and any won't-fix / false-positive resolution, when code moves.
|
|
165
|
+
|
|
166
|
+
## Ratings and the quality gate
|
|
167
|
+
|
|
168
|
+
Each analysis gets A–E ratings, overall and on new code: **reliability**, **security** and **accessibility** (worst open issue of that type), **maintainability** (the worse of the SQALE technical-debt ratio and the worst open code smell) and **security review** (share of hotspots reviewed), combined into a 0–100 **health score**. The `/ratings/` page explains the formulas.
|
|
169
|
+
|
|
170
|
+
The default quality gate, mostly on new code, plus a floor for the whole codebase so a first scan (which has no new code) can't pass a project full of old problems:
|
|
171
|
+
|
|
172
|
+
| Condition | Default |
|
|
173
|
+
|---|---|
|
|
174
|
+
| New issues | none that are blocker/critical, no bugs, no vulnerabilities, maintainability A |
|
|
175
|
+
| Security hotspots | security review A (≥ 80% reviewed) |
|
|
176
|
+
| Coverage | ≥ 80% |
|
|
177
|
+
| Duplication | ≤ 3% |
|
|
178
|
+
| Small changes | coverage/duplication skipped under 20 new lines |
|
|
179
|
+
| Dependency CVEs | no critical ones (overall) |
|
|
180
|
+
| Accessibility | no new accessibility issues |
|
|
181
|
+
| Whole codebase | reliability, security, security review and maintainability ratings C or better |
|
|
182
|
+
|
|
183
|
+
Every condition can be changed per project under **Settings**.
|
|
184
|
+
|
|
185
|
+
## Rule catalogue
|
|
186
|
+
|
|
187
|
+
`/rules/` is a public, searchable catalogue of every rule (about 4,100), with what's wrong, how to fix it and examples where the source documentation is freely licensed (ruff, bandit, ESLint, stylelint, jsx-a11y), plus MITRE CWE descriptions, mitigations and example code for security rules. Each rule links to its origin and its standards: CWE, OWASP Top 10 (2025), WCAG 2.2, PEPs. `/standards/` shows coverage of the CWE Top 25, OWASP Top 10 and WCAG A/AA by language, with gaps marked.
|
|
188
|
+
|
|
189
|
+
The catalogue has three parts:
|
|
190
|
+
|
|
191
|
+
- `catalog/codewatch/rules/*.yml`: codewatch's own built-in rules (taint rules for Flask/Django/FastAPI request data reaching SQL, shell, eval, file paths, XPath, LDAP, redirects, sessions and HTML responses; weak hashes, insecure cookies, XXE; Django views without method restrictions; `|safe`/`autoescape off` in templates; Angular sanitizer bypasses, NoSQL injection and substring URL allowlists in JS/TS; uploads, error details and mass assignment in both). They ship with codewatch and run in every scan.
|
|
192
|
+
|
|
193
|
+
The rest of the catalogue has two layers:
|
|
194
|
+
|
|
195
|
+
- `catalog/imported/` is generated from the analyzers' own metadata and from MITRE, W3C and the Semgrep registry, and is **replaced on every import**. Rules from restrictively licensed sources (Semgrep registry, cppcheck's GPL messages) are recorded by ID, classification and CWE only.
|
|
196
|
+
- `catalog/custom/` is **never touched by an import**:
|
|
197
|
+
- `rules/*.yml`: your own checks in [Semgrep rule syntax](https://semgrep.dev/docs/writing-rules/rule-syntax). They run in every scan, including local `codewatch scan` runs (the server sends them with the project config). Add `metadata.cwe`, `owasp` and `references` and they appear in the catalogue and coverage.
|
|
198
|
+
- `mappings.json`: extra CWE / WCAG / OWASP mappings for rules whose tool doesn't publish them, and `equivalent` groups of rules that perform the same check.
|
|
199
|
+
- `overrides.json`: change a rule's severity, type or title, or disable it.
|
|
200
|
+
|
|
201
|
+
Admins can press **Update rules now** (optionally upgrading the analyzers first) on `/rules/`. Updates also run automatically every `CODEWATCH_CATALOG_UPDATE_DAYS` days (default 7, `0` disables; set `CODEWATCH_CATALOG_UPGRADE_TOOLS=1` to include analyzer upgrades), or from cron with `manage.py updatecatalog [--upgrade-tools]`. A server's imports go to its cache directory; `manage.py buildcatalog` refreshes the snapshot committed in `catalog/imported/`.
|
|
202
|
+
|
|
203
|
+
## Benchmarks
|
|
204
|
+
|
|
205
|
+
`codewatch benchmark` scans third-party code with published ground truth, pinned to a commit (never executed), and writes results to `benchmarks/results/`. Two modes are scored: **verdict** counts only findings that claim a vulnerability (data reaching a dangerous call, or a definite flaw such as a weak hash or an insecure cookie), which is what the Security rating uses; **review** adds security hotspots, i.e. everything a reviewer is asked to look at.
|
|
206
|
+
|
|
207
|
+
Not tuned on (held out, or blind: scanned once, never used to adjust rules):
|
|
208
|
+
|
|
209
|
+
| Suite | Verdict | Review |
|
|
210
|
+
|---|---|---|
|
|
211
|
+
| SecurityEval Copilot answers, manually labelled (held out) | finds 34%, false alarms 0% | finds 51%, false alarms 6% |
|
|
212
|
+
| SecurityEval InCoder answers, manually labelled (held out) | finds 31%, false alarms 0% | finds 47%, false alarms 0% |
|
|
213
|
+
| [Vulnerable-Code-Snippets](https://github.com/snoopysecurity/Vulnerable-Code-Snippets): 22 JS/TS snippets (held out) | 11 of 22 flagged | 13 of 22 flagged |
|
|
214
|
+
| Blind CVE fix pairs, round 2, half of the Python ones (run once on 2026-11-28): 40 back end, 10 front end | back end 11 of 40 found, 3 still flagged; front end 1 of 10 | back end 20 of 40, 9 still flagged; front end 6 of 10, 4 still flagged |
|
|
215
|
+
| Blind CVE fix pairs, first round (never looked at before this run): 5 Python, 4 JS/TS | Python 2 of 5 found, 1 still flagged; JS 1 of 4, 1 still flagged | same, JS 2 still flagged |
|
|
216
|
+
| Blind ordinary apps (Django, FastAPI, Express, NestJS; expected clean) | false alarms in 2 of 4 apps (12 findings, 10 in the Express app) | |
|
|
217
|
+
| Second blind set of ordinary apps (Django, FastAPI, Express, NestJS), after two learning sets | false alarms in 2 of 4 apps (34 findings, 28 in the Django app); 2 real at code level | |
|
|
218
|
+
| Third blind set of ordinary apps (Django, FastAPI, Express, NestJS), after three learning sets | false alarms in 4 of 4 apps (24 findings, 13 in the Express app); 2 real | |
|
|
219
|
+
|
|
220
|
+
Tuned on (rules were written or adjusted from these, so they flatter codewatch):
|
|
221
|
+
|
|
222
|
+
| Suite | Verdict | Review |
|
|
223
|
+
|---|---|---|
|
|
224
|
+
| [OWASP Benchmark for Python](https://github.com/OWASP-Benchmark/BenchmarkPython): 1,230 labelled cases, 14 CWEs | finds 100%, false alarms 0% | finds 100%, false alarms 35% |
|
|
225
|
+
| [SecurityEval](https://github.com/s2e-lab/SecurityEval): 121 insecure Python samples filed by CWE | 50 of 121 flagged | 77 of 121 flagged |
|
|
226
|
+
| [OWASP Juice Shop](https://github.com/juice-shop/juice-shop): 35 marked vulnerable challenges (JS/TS) | 15 of 35 flagged | 17 of 35 flagged |
|
|
227
|
+
| [vulnerable-node SAST seeds](https://github.com/cr0hn/vulnerable-node/tree/master/sast): 12 seeds and 2 clean controls (JS) | finds 92%, false alarms 0% | finds 100%, false alarms 50% |
|
|
228
|
+
| CVE fix pairs, Python: 109 advisories and fixes in web apps (vulnerable commit, then its fix) | 70 of 109 found, 10 still flagged after the fix | 74 of 109 found, 21 still flagged |
|
|
229
|
+
| CVE fix pairs, Python front end: 32 advisories fixed in templates or front-end JS | 4 of 32 found | 16 of 32 found, 8 still flagged |
|
|
230
|
+
| CVE fix pairs, JS/TS: 103 advisories in web apps | 22 of 103 found, 9 still flagged | 46 of 103 found, 32 still flagged |
|
|
231
|
+
| CVE fix pairs, PHP: 341 advisories in PHP apps and CMSs | 75 of 341 found, 27 still flagged | 83 of 341 found, 36 still flagged |
|
|
232
|
+
| CVE fix pairs whose input isn't an HTTP request (desktop, bot, agent and MCP tool input): 15 Python, 38 JS/TS | 5 of 53 found, 2 still flagged | 16 of 53 found, 11 still flagged |
|
|
233
|
+
|
|
234
|
+
The CVE pairs are real projects' advisories: a finding of the advisory's weakness near the lines its fix changed counts as found (or one the fix makes go away, when the fixed side's scan finished every rule), and one that survives the fix as a false alarm. The non-blind pairs were used to adjust rules (which ones, and for what, is in `benchmarks/suites.json`); the blind ones and the blind apps were scanned once, at the end, without adjusting anything, and read case by case the JS blind "find" is the same noise on both sides of its fix. The blind apps show that zero false alarms on the apps used for tuning doesn't carry over: fixed-prefix relative redirects, requests to fixed hosts with an encoded query, and JSON written to an event stream were all flagged. The first two shapes are now handled, learned from five other ordinary apps (flaskbb, outline, proshop-v2 and two Express boilerplates, listed in `PLAN.md`), and five more in the second blind set's frameworks (wger, taiga, dispatch, immich, linkwarden: 86 false alarms down to 1); the second blind set, chosen and pinned before any scan, says it mostly doesn't: the Express and NestJS apps were clean, but the Django app had 28 false alarms of shapes the learning apps never showed (a project's own redirect allowlist function, a `reverse()` URL with a query string appended, session writes as trust-boundary findings, SHA-1 keyed with the secret key). The third blind set, after a third learning set aimed at Django, did worse by apps: Python is now close (3 false alarms in two apps) but every JavaScript app brought shapes of its own (SVG badges and RSS feeds rendered by escaping libraries, cache and Redis lookups keyed by request data, an opt-in TLS bypass, a cookie made secure through config). A fourth learning set, mostly Express apps, took JavaScript's false alarms there from 37 to 27. The focus is now Python web apps and the JavaScript they ship. The CVE pairs have grown from advisories GitHub reviewed (PyPI, npm) and, since 2026-11-03, from advisories it never reviews, which is where apps that aren't published as packages get theirs, since 2026-11-13 from Python and JS/TS app CVEs that have no GitHub advisory at all (read from the CVE list), and since 2026-11-20 from security fixes apps made without any advisory or CVE (found through GitHub's commit search; ids `FIX-OWNER-REPO-SHA`): each fix read and accepted or rejected with a reason, and a third of the accepted ones split off as blind before any scan. The table above is the nightly run of 2026-11-28. PHP has had rules since 2026-11-14, written from the first 197 reviewed PHP app and CMS pairs (where Semgrep's registry rules alone found none); `cve-pairs-php` has since grown to 342, the rest scored only after the rules were written. The blind CVE suites of this round (60 Python and JS/TS suites with 219 cases, and 36 PHP suites with 226) and a fourth blind set of Python apps with JavaScript front ends wait for the end of the round. The pairs without an HTTP request are kept apart because codewatch has no sources for that input yet. Of the Python pairs' still-flagged fixes, the ones read as incomplete fixes are counted as real findings. Details: `PLAN.md` for where things stand, `docs/plan-log.md` for every step and the case behind it.
|
|
235
|
+
|
|
236
|
+
The score on OWASP is detection minus false alarms (OWASP Benchmark's own measure), averaged over categories. "Held out" suites were never used to write or tune rules, so they are the fairer measure; the others were. The Copilot and InCoder answers respond to the same prompts as SecurityEval's own samples, which were used for rules, so their numbers are not fully independent.
|
|
237
|
+
|
|
238
|
+
Semgrep's open-source engine follows data within one function and loses it at slices, `match` statements, dict keys and constant-folded branches. codewatch scans a line-for-line rewritten copy of Python files (dead constant branches blanked, slices made indexes, constant container keys made attributes, `match` made `if`), and summarises functions before the main scan: the taint rules run with function parameters as sources to find which parameters reach a sink, then again with calls to those functions as extra sinks, up to three calls deep. A call only counts where the function is visible (same file, or an import that resolves to the defining file), so same-named functions elsewhere don't connect. When only some files count (a CVE pair's changed files and what renders or imports them), the summaries cover just those files and the project files they import, transitively, including modules named in dotted strings such as Django's `ROOT_URLCONF`, and the main scan gives each rule a minute on those files rather than skipping one when rules run past Semgrep's usual five seconds. A parameter that reaches a sink in a function nothing in the project calls (a library entry point, a handler registered elsewhere) is reported as a hotspot, since the danger depends on what its callers pass (unless it is typed as a number, boolean, UUID or date). Data coming out of helpers is followed too: a pass with `return` as the sink finds functions that return request data (`def get_param(name): return request.args.get(name)`), and calls to them become sources where they are visible; what a helper looks up with the request value (a model by id, a decoded token) and a view's response don't count. Request data stored in `self.x`/`this.x` in one method is followed into the others in that file. The opposite case is followed as well: a call to a project function that never returns its argument (`err = require_access(file, user)` returning a fixed message) doesn't pass the request data on, per parameter in Python and per function in JavaScript.
|
|
239
|
+
|
|
240
|
+
Request data means more than `request`: Flask route parameters (`<name>`; converters such as `<int:id>` are typed on the copy so they don't count), Django function views' URL arguments where their `urls.py` route passes free text (`<path:name>`, `(?P<name>.*)`; not `<int:pk>` or `\d+`), FastAPI parameters typed as text and the text fields of a project's Pydantic/SQLModel body models (and of the models nested in them, or a body model passed whole to a function), Django class-based views' `self.request` and `self.kwargs`, a Django REST framework ViewSet's lookup argument (`pk`, or its `lookup_field`) in its detail methods unless `lookup_value_regex` allows only digits, Flask-AppBuilder and Flask-Admin `@expose` routes' arguments, Frappe's `frappe.form_dict`, the arguments of `@frappe.whitelist()` methods (not numeric ones) and a script report's `filters`, and NestJS `@Body()`/`@Query()`/`@Param()`/`@Headers()` parameters (not with a parse pipe or a number/boolean/Date type). For XSS only, a Django model's text field also counts when the project fills it from request data (`Model.objects.create(field=...)`, `obj.field = ...`, a ModelForm or ModelSerializer, followed through the project's own helpers): reading it back in the model's admin, its own methods, or after `Model.objects...`/`get_object_or_404(Model, ...)` is stored XSS where it reaches `mark_safe`, `format_html`'s format string or a response.
|
|
241
|
+
|
|
242
|
+
A route parameter is request data where it's declared, so `name = secure_filename(name)` clears it. Templates are read too: request data passed to a variable a template prints with `|safe` or under `autoescape off` is reported as XSS at the `render_template`/`render` call (not for a form field, a value escaped or sanitized first, or an admin-only view). A template that prints request values itself at the start of a link (`href="{{ request.args.next }}"`) or inside an event handler is reported there, since autoescaping doesn't stop a `javascript:` URL. Inline `<script>` blocks in templates are scanned as JavaScript, on the template's own lines.
|
|
243
|
+
|
|
244
|
+
Most SecurityEval samples are plain functions with no request source, which caps verdict-mode detection there; much of the rest is design flaws (off-by-one, missing authentication, race conditions) outside what pattern and taint rules can see. Log injection is reported as a hotspot rather than a vulnerability, because whether a forged log line matters depends on the log format. Other known limits: Juice Shop measures detection only, since its unmarked code isn't labelled safe, and many of its challenges are business-logic flaws (missing ownership checks, weak security questions) that no static analyzer can recognise.
|
|
245
|
+
|
|
246
|
+
### Compared with CodeQL
|
|
247
|
+
|
|
248
|
+
GitHub's CodeQL (2.27.4, its default code-scanning queries for verdict and security-extended for review) was run once on the same CVE pairs, scored by the same fix spots, on 2026-11-14. Cases found, then still flagged after the fix; only cases both tools scored, and only under an OSI-approved licence (16 of 229 skipped):
|
|
249
|
+
|
|
250
|
+
| Suite | Cases | CodeQL | codewatch verdict | codewatch review |
|
|
251
|
+
|---|---|---|---|---|
|
|
252
|
+
| Python web apps | 76 | 23 found, 11 still flagged | 47 found, 12 still flagged | 49 found, 16 still flagged |
|
|
253
|
+
| Python front end | 31 | 4, 1 | 4, 0 | 14, 8 |
|
|
254
|
+
| JS/TS web apps | 65 | 8, 1 | 8, 6 | 23, 19 |
|
|
255
|
+
| Input that isn't an HTTP request (Python, JS/TS) | 32 | 2, 2 (review 3) | 2, 0 | 9, 6 |
|
|
256
|
+
|
|
257
|
+
On Python web apps codewatch finds about twice as many (19 found by both, 28 by codewatch only, 4 by CodeQL only) with about as many false alarms. On JavaScript the two tie in verdict mode with different cases (2 in common), and CodeQL leaves fewer findings on fixed code; the six only it finds are mostly path traversal, codewatch's weakest JavaScript area. CodeQL's results are a measurement only: no rule was written from them. CodeQL's terms allow it only on code under an OSI-approved licence (anything else needs a paid GitHub licence), so `benchmarks/codeql_compare.py` scans a case only when its licence is one; CodeQL itself is not part of codewatch and has to be installed separately (the script's docstring says how). Details in `docs/plan-log.md`, step 71.
|
|
258
|
+
|
|
259
|
+
Meta's Pysa (open source, follows data across functions) was tried on 2026-11-28 as a second comparison, and not
|
|
260
|
+
run on the pairs. Pysa 0.10 now needs Pyrefly for types, and its bundled Flask models name Werkzeug classes
|
|
261
|
+
removed in Werkzeug 2.1. On a ten-line Flask app with a shell command and a file path built from `request.args`,
|
|
262
|
+
it reported neither, even with current source models added. Its four reports were all inside Flask's own code. A
|
|
263
|
+
fair comparison needs Pysa models written for each framework, which is a project of its own.
|
|
264
|
+
|
|
265
|
+
## Claude / MCP
|
|
266
|
+
|
|
267
|
+
Create a token for Claude on your Account page (a **read** token lets it list and resolve issues; a **scan** token can also start server-side scans), then:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
claude mcp add codewatch -e CODEWATCH_URL=http://127.0.0.1:8100 -e CODEWATCH_TOKEN=cw_... \
|
|
271
|
+
-- /path/to/codewatch/venv/bin/codewatch-mcp
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Tools: `list_projects`, `quality_gate`, `list_issues` (filter by branch, new code, type, severity, tool, path), `list_security_hotspots`, `get_issue` (with source snippet and rule summary), `get_rule` (explanation, fix guidance and examples), `resolve_issue`, `start_server_scan`. Paths are repo-relative, so the agent can fix issues in its local checkout and rescan with `codewatch scan`.
|
|
275
|
+
|
|
276
|
+
## HTTP API
|
|
277
|
+
|
|
278
|
+
All endpoints take `Authorization: Bearer <token>`.
|
|
279
|
+
|
|
280
|
+
| Method | Path | |
|
|
281
|
+
|---|---|---|
|
|
282
|
+
| GET | `/api/projects/` | projects you can see, with latest analysis per branch |
|
|
283
|
+
| GET | `/api/projects/<key>/status/?branch=` | latest analysis: gate, metrics, tools |
|
|
284
|
+
| GET | `/api/projects/<key>/issues/?branch=&new=1&type=&severity=&tool=&path=&status=&limit=&offset=` | issues, most severe first |
|
|
285
|
+
| GET | `/api/issues/<id>/?context=5` | one issue with source snippet and its rule |
|
|
286
|
+
| GET | `/api/rules/<rule id>/` | catalogue rule with explanation and CWE fix guidance |
|
|
287
|
+
| POST | `/api/issues/<id>/resolve/` | `{"status": "false_positive" \| "wont_fix" \| "reopen", "comment": ""}` |
|
|
288
|
+
| GET | `/api/projects/<key>/config/` | scan settings used by the client (scan scope) |
|
|
289
|
+
| POST | `/api/projects/<key>/analyses/` | upload a `codewatch scan` payload (scan scope; gzip JSON) |
|
|
290
|
+
| POST | `/api/projects/<key>/scan/` | server-side scan: `{"branch", "repo_url" (new projects), "name"}`, optional `coverage` file (scan scope) |
|
|
291
|
+
|
|
292
|
+
## Server-side scans
|
|
293
|
+
|
|
294
|
+
Create the project in the UI with a repository URL, use `manage.py addproject KEY URL`, or `POST /api/projects/<key>/scan/`. An administrator can instead pick a repository folder on the server from **New project**: the page lists folders under `CODEWATCH_BROWSE_ROOT` (the home directory by default; names only, hidden folders left out), takes the title and key from the folder's name, and creates a scan token for `codewatch-scan` in that working copy, shown once on the project's page. The project list has a **Scan** button for each project the server can scan. Branches are scanned from a bare mirror in `~/.cache/codewatch/`, never touching a working copy, one scan of a project at a time and at most `CODEWATCH_MAX_SCANS` (4) across the server. Public repositories work for everyone; the server's own git credentials, server-local paths and hosts on its network only for projects an administrator owns (or added with `addproject`).
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
venv/bin/python manage.py scan my-app --all-branches --fail-on-gate
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## Development
|
|
301
|
+
|
|
302
|
+
Start with [CONTRIBUTING.md](CONTRIBUTING.md). [docs/architecture.md](docs/architecture.md) explains how a scan flows,
|
|
303
|
+
[docs/writing-rules.md](docs/writing-rules.md) where a rule change goes and the tests it needs, and
|
|
304
|
+
[docs/benchmarks.md](docs/benchmarks.md) how to reproduce every number here. Work lands on `detection-gaps`, the default
|
|
305
|
+
branch. `main` is fast-forwarded from it weekly, after a clean nightly run.
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
make test # pytest across all CPUs (pytest-xdist); accessibility tests are skipped if tools/ isn't installed
|
|
309
|
+
make lint
|
|
310
|
+
make lock # new analyzer versions into tools/*.lock (hashed); review, re-run the benchmarks, commit
|
|
311
|
+
venv/bin/python benchmarks/devtools.py bench [SUITE...] # score suites, in parallel
|
|
312
|
+
venv/bin/python benchmarks/devtools.py repos DIR... # Semgrep findings on whole projects, in parallel
|
|
313
|
+
venv/bin/python benchmarks/devtools.py cases GHSA-... # only the CVE pairs a change targets, nothing written
|
|
314
|
+
venv/bin/python benchmarks/devtools.py copy FILE.py # the rewritten copy of a Python file that Semgrep scans
|
|
315
|
+
venv/bin/python benchmarks/smoke.py # the CVE pairs CI re-scores on every push
|
|
316
|
+
venv/bin/python benchmarks/rule_trust.py > docs/rule-trust.md # per-rule evidence from the latest nightly
|
|
317
|
+
benchmarks/nightly.sh [BRANCH] # the full verification, unattended, with a dated report
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Benchmarks and `repos` scan in a third of the CPUs' worth of processes (`CODEWATCH_BENCH_WORKERS`), each Semgrep run with its share of the CPUs: results are identical to one-at-a-time runs, and all suites take about four hours on a 20-thread machine (the CVE pairs, each cloned and scanned twice, nearly all of it). `nightly.sh` checks the branch tip out in its own worktree, runs lint, tests, every suite that isn't blind and the apps listed in `~/.config/codewatch/nightly-apps.txt`, and writes `~/.cache/codewatch/nightly/DATE/summary.txt` (what changed since the last report); a systemd user timer can run it overnight. `make tools` installs the analyzers at the versions and hashes in `tools/*.lock` and `tools/package-lock.json`.
|
|
321
|
+
|
|
322
|
+
## License
|
|
323
|
+
|
|
324
|
+
MIT, see [LICENSE](LICENSE). Analyzers and imported rule metadata keep their own licenses.
|