codewatch-scan 0.1.0__py3-none-any.whl

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.
Files changed (136) hide show
  1. codewatch/__init__.py +0 -0
  2. codewatch/__main__.py +14 -0
  3. codewatch/asgi.py +16 -0
  4. codewatch/settings.py +175 -0
  5. codewatch/urls.py +40 -0
  6. codewatch/wsgi.py +16 -0
  7. codewatch_scan-0.1.0.dist-info/METADATA +81 -0
  8. codewatch_scan-0.1.0.dist-info/RECORD +136 -0
  9. codewatch_scan-0.1.0.dist-info/WHEEL +5 -0
  10. codewatch_scan-0.1.0.dist-info/entry_points.txt +4 -0
  11. codewatch_scan-0.1.0.dist-info/licenses/LICENSE +21 -0
  12. codewatch_scan-0.1.0.dist-info/top_level.txt +2 -0
  13. core/__init__.py +0 -0
  14. core/analyzers/__init__.py +19 -0
  15. core/analyzers/accessibility.py +199 -0
  16. core/analyzers/base.py +192 -0
  17. core/analyzers/body_models.py +154 -0
  18. core/analyzers/codewatch_checks.py +394 -0
  19. core/analyzers/constant_branches.py +251 -0
  20. core/analyzers/containers.py +316 -0
  21. core/analyzers/coverage.py +131 -0
  22. core/analyzers/dependencies.py +347 -0
  23. core/analyzers/drf_serializers.py +65 -0
  24. core/analyzers/else_branches.py +106 -0
  25. core/analyzers/extra.py +400 -0
  26. core/analyzers/flask_resources.py +65 -0
  27. core/analyzers/inline_scripts.py +50 -0
  28. core/analyzers/jinja_sandboxes.py +63 -0
  29. core/analyzers/match_statements.py +148 -0
  30. core/analyzers/multi_tools.py +888 -0
  31. core/analyzers/php_template_sinks.py +444 -0
  32. core/analyzers/project_checks.py +150 -0
  33. core/analyzers/python_tools.py +333 -0
  34. core/analyzers/route_converters.py +237 -0
  35. core/analyzers/slices.py +94 -0
  36. core/analyzers/starred_targets.py +42 -0
  37. core/analyzers/stored_fields.py +386 -0
  38. core/analyzers/summaries.py +1387 -0
  39. core/analyzers/template_sinks.py +162 -0
  40. core/api.py +360 -0
  41. core/apps.py +6 -0
  42. core/benchmark.py +955 -0
  43. core/bundled/catalog/codewatch/rules/javascript-crypto.yml +224 -0
  44. core/bundled/catalog/codewatch/rules/javascript-injection.yml +116 -0
  45. core/bundled/catalog/codewatch/rules/javascript-taint.yml +1539 -0
  46. core/bundled/catalog/codewatch/rules/javascript-web.yml +562 -0
  47. core/bundled/catalog/codewatch/rules/php-web.yml +719 -0
  48. core/bundled/catalog/codewatch/rules/python-crypto.yml +203 -0
  49. core/bundled/catalog/codewatch/rules/python-django.yml +267 -0
  50. core/bundled/catalog/codewatch/rules/python-injection.yml +115 -0
  51. core/bundled/catalog/codewatch/rules/python-web.yml +3382 -0
  52. core/bundled/catalog/custom/mappings.json +360 -0
  53. core/bundled/catalog/custom/overrides.json +4 -0
  54. core/bundled/catalog/custom/rules/django-settings.yml +19 -0
  55. core/bundled/catalog/imported/changes.json +5 -0
  56. core/bundled/catalog/imported/docs.json +1143 -0
  57. core/bundled/catalog/imported/meta.json +54 -0
  58. core/bundled/catalog/imported/rules.json +85421 -0
  59. core/bundled/catalog/imported/standards.json +11191 -0
  60. core/bundled/tools/analyzers.lock +786 -0
  61. core/bundled/tools/axe-scan.mjs +45 -0
  62. core/bundled/tools/checkov.lock +2463 -0
  63. core/bundled/tools/codewatch-checks.mjs +99 -0
  64. core/bundled/tools/eslint-a11y.config.js +16 -0
  65. core/bundled/tools/eslint-quality.config.js +63 -0
  66. core/bundled/tools/eslint-typed.config.js +18 -0
  67. core/bundled/tools/package-lock.json +6102 -0
  68. core/bundled/tools/package.json +32 -0
  69. core/bundled/tools/rule-metadata.mjs +56 -0
  70. core/bundled/tools/semgrep.lock +1232 -0
  71. core/bundled/tools/stylelint.config.json +11 -0
  72. core/catalog/__init__.py +190 -0
  73. core/catalog/build.py +84 -0
  74. core/catalog/merge.py +122 -0
  75. core/catalog/sources.py +418 -0
  76. core/catalog/standards.py +119 -0
  77. core/catalog/update.py +99 -0
  78. core/catalog_views.py +115 -0
  79. core/client.py +645 -0
  80. core/collect.py +518 -0
  81. core/duplicates.py +60 -0
  82. core/fingerprint.py +25 -0
  83. core/folders.py +73 -0
  84. core/gate.py +77 -0
  85. core/git.py +149 -0
  86. core/jobs.py +86 -0
  87. core/management/__init__.py +0 -0
  88. core/management/commands/__init__.py +0 -0
  89. core/management/commands/addproject.py +40 -0
  90. core/management/commands/buildcatalog.py +15 -0
  91. core/management/commands/scan.py +74 -0
  92. core/management/commands/updatecatalog.py +14 -0
  93. core/mcp_server.py +140 -0
  94. core/middleware.py +17 -0
  95. core/migrations/0001_initial.py +115 -0
  96. core/migrations/0002_auth_tokens_a11y.py +60 -0
  97. core/migrations/0003_default_admin.py +43 -0
  98. core/migrations/0004_project_members.py +28 -0
  99. core/migrations/0005_uploads_and_sources.py +55 -0
  100. core/migrations/0006_thresholds.py +28 -0
  101. core/migrations/0007_also_reported_by.py +18 -0
  102. core/migrations/0008_new_code_period.py +18 -0
  103. core/migrations/0009_resolution_safe.py +18 -0
  104. core/migrations/0010_analysis_progress.py +18 -0
  105. core/migrations/0011_overall_gate_conditions.py +20 -0
  106. core/migrations/__init__.py +0 -0
  107. core/models.py +323 -0
  108. core/network.py +41 -0
  109. core/paths.py +29 -0
  110. core/ratings.py +67 -0
  111. core/runner.py +168 -0
  112. core/templates/core/account.html +30 -0
  113. core/templates/core/analysis.html +49 -0
  114. core/templates/core/base.html +121 -0
  115. core/templates/core/form_table.html +12 -0
  116. core/templates/core/gate_badge.html +1 -0
  117. core/templates/core/index.html +26 -0
  118. core/templates/core/issues.html +38 -0
  119. core/templates/core/login.html +13 -0
  120. core/templates/core/new_project.html +27 -0
  121. core/templates/core/password_change.html +10 -0
  122. core/templates/core/project.html +40 -0
  123. core/templates/core/rating.html +1 -0
  124. core/templates/core/ratings.html +32 -0
  125. core/templates/core/rule.html +33 -0
  126. core/templates/core/rules.html +42 -0
  127. core/templates/core/scan_progress.html +2 -0
  128. core/templates/core/settings.html +36 -0
  129. core/templates/core/source.html +15 -0
  130. core/templates/core/standards.html +30 -0
  131. core/templates/core/user_edit.html +15 -0
  132. core/templates/core/users.html +18 -0
  133. core/templatetags/__init__.py +0 -0
  134. core/templatetags/codewatch.py +42 -0
  135. core/tool_setup.py +68 -0
  136. core/views.py +564 -0
@@ -0,0 +1,49 @@
1
+ {% extends "core/base.html" %}{% load codewatch %}
2
+ {% block title %}{{ analysis.branch }} · {{ project.name }}{% endblock %}
3
+ {% block crumbs %}<li><a href="{% url 'project' project.key %}">{{ project.name }}</a></li><li aria-current="page">{{ analysis.branch }}</li>{% endblock %}
4
+ {% block content %}
5
+ <h1>{{ analysis.branch }} <code>{{ analysis.commit|slice:":8" }}</code></h1>
6
+ {% if analysis.status == "failed" %}<section class="card" role="alert"><h2 class="fail">Analysis failed</h2><pre>{{ analysis.error }}</pre></section>{% endif %}
7
+ <section aria-labelledby="scores-h"><h2 id="scores-h" class="sr-only">Ratings</h2>
8
+ <div class="scores">
9
+ <div class="card"><span class="label">Health score</span>{% with g=m.health_score|score_grade %}<span><span class="rating big rating-{{ g }}" role="img" aria-label="Health {{ g }}">{{ g }}</span> {{ m.health_score|num }} / 100</span>{% endwith %}<a class="sub" href="{% url 'ratings' %}">How it's calculated</a></div>
10
+ <div class="card"><span class="label">Reliability</span><span>{% include "core/rating.html" with value=m.reliability_rating what="Reliability" big=1 %} {{ m.bugs|num }} bugs</span><span class="sub">New code: {{ m.new_reliability_rating|grade }}</span></div>
11
+ <div class="card"><span class="label">Security</span><span>{% include "core/rating.html" with value=m.security_rating what="Security" big=1 %} {{ m.vulnerabilities|num }} vulnerabilities</span><span class="sub">New code: {{ m.new_security_rating|grade }}</span></div>
12
+ <div class="card"><span class="label">Security review</span><span>{% include "core/rating.html" with value=m.security_review_rating what="Security review" big=1 %} {{ m.security_hotspots|num }} open hotspots</span><span class="sub">New code: {{ m.new_security_review_rating|grade }}</span></div>
13
+ <div class="card"><span class="label">Maintainability</span><span>{% include "core/rating.html" with value=m.maintainability_rating what="Maintainability" big=1 %} {{ m.debt_ratio_percent|num }}% debt</span><span><a href="{% url 'issues' project.key analysis.pk %}?type=code_smell">{{ m.code_smells|num }} code smells</a></span><span class="sub">New code: {{ m.new_maintainability_rating|grade }}{% if m.new_code_smells %}, <a href="{% url 'issues' project.key analysis.pk %}?type=code_smell&amp;new=1">{{ m.new_code_smells|num }} new code smells</a>{% endif %}</span></div>
14
+ <div class="card"><span class="label">Accessibility</span><span>{% include "core/rating.html" with value=m.accessibility_rating what="Accessibility" big=1 %} {{ m.accessibility_issues|num }} issues</span><span class="sub">New code: {{ m.new_accessibility_rating|grade }}</span></div>
15
+ <div class="card"><span class="label">Coverage</span><span>{{ m.coverage|num }}{% if m.coverage is not None %}%{% endif %}</span><span class="sub">New code: {{ m.new_coverage|num }}{% if m.new_coverage is not None %}%{% endif %}</span></div>
16
+ <div class="card"><span class="label">Duplication</span><span>{{ m.duplicated_lines_percent|num }}{% if m.duplicated_lines_percent is not None %}%{% endif %}</span><span class="sub">New code: {{ m.new_duplicated_lines_percent|num }}{% if m.new_duplicated_lines_percent is not None %}%{% endif %}</span></div>
17
+ </div></section>
18
+ <section class="card" aria-labelledby="gate-h"><h2 id="gate-h">Quality gate: {% include "core/gate_badge.html" %}</h2>
19
+ <p class="muted">{% if analysis.reference_commit %}New code = changes since <code>{{ analysis.reference_commit|slice:":8" }}</code> on {{ analysis.reference_branch }}.{% else %}No reference yet, so there is no new code on this analysis.{% endif %}
20
+ {% if analysis.dirty %} Scanned with uncommitted local changes.{% endif %}
21
+ {% if analysis.origin == "client" %} Uploaded by codewatch-scan{% if analysis.scanned_by %} from {{ analysis.scanned_by.username }}'s working copy{% endif %}: the server didn't run this scan, so its results and gate are as reported.{% endif %}</p>
22
+ <table><caption class="sr-only">Quality gate conditions</caption>
23
+ <thead><tr><th scope="col">Metric</th><th scope="col">Fails when</th><th scope="col">Value</th><th scope="col">Status</th></tr></thead><tbody>
24
+ {% for d in gate %}<tr><th scope="row">{{ d.metric|label }}</th>
25
+ <td>{% if d.is_rating %}{% if d.op == "gt" %}worse than{% else %}better than{% endif %} {{ d.threshold|grade }}{% else %}{% if d.op == "gt" %}greater than{% else %}less than{% endif %} {{ d.threshold|num }}{% endif %}</td>
26
+ <td>{% if d.is_rating and d.value is not None %}{% include "core/rating.html" with value=d.value what=d.metric|label %}{% else %}{{ d.value|num }}{% endif %}</td>
27
+ <td class="{% if d.status == 'error' %}fail{% elif d.status == 'ok' %}pass{% else %}muted{% endif %}">{% if d.status == 'error' %}Failed{% if d.link %}: <a href="{{ d.link }}">see the issues</a>{% endif %}{% elif d.status == 'ok' %}OK{% elif d.status == 'too_few_lines' %}Skipped: under 20 new lines{% else %}No value{% endif %}</td></tr>{% endfor %}
28
+ </tbody></table></section>
29
+ <div class="grid">
30
+ <div class="card"><table><caption>By severity</caption><thead><tr><th scope="col">Severity</th><th scope="col">New</th><th scope="col">Overall</th></tr></thead><tbody>
31
+ {% for s, all, new in severities %}<tr><th scope="row" class="sev sev-{{ s }}">{{ s }}</th>
32
+ <td><a href="{% url 'issues' project.key analysis.pk %}?severity={{ s }}&amp;new=1" aria-label="{{ new|num }} new {{ s }} issues">{{ new|num }}</a></td>
33
+ <td><a href="{% url 'issues' project.key analysis.pk %}?severity={{ s }}" aria-label="{{ all|num }} {{ s }} issues overall">{{ all|num }}</a></td></tr>{% endfor %}</tbody></table></div>
34
+ <div class="card"><table><caption>By type</caption><thead><tr><th scope="col">Type</th><th scope="col">New</th><th scope="col">Overall</th></tr></thead><tbody>
35
+ {% for t, all, new in types %}<tr><th scope="row">{{ t|label }}</th>
36
+ <td><a href="{% url 'issues' project.key analysis.pk %}?type={{ t }}&amp;new=1" aria-label="{{ new|num }} new {{ t|label }} issues">{{ new|num }}</a></td>
37
+ <td><a href="{% url 'issues' project.key analysis.pk %}?type={{ t }}" aria-label="{{ all|num }} {{ t|label }} issues overall">{{ all|num }}</a></td></tr>{% endfor %}</tbody></table></div>
38
+ <div class="card"><table><caption>By tool</caption><thead><tr><th scope="col">Tool</th><th scope="col">New</th><th scope="col">Overall</th></tr></thead><tbody>
39
+ {% for t, all, new in by_tool %}<tr><th scope="row">{{ t }}</th>
40
+ <td><a href="{% url 'issues' project.key analysis.pk %}?tool={{ t }}&amp;new=1" aria-label="{{ new }} new {{ t }} issues">{{ new }}</a></td>
41
+ <td><a href="{% url 'issues' project.key analysis.pk %}?tool={{ t }}" aria-label="{{ all }} {{ t }} issues overall">{{ all }}</a></td></tr>{% endfor %}</tbody></table></div>
42
+ </div>
43
+ <div class="grid">
44
+ <div class="card"><table><caption>Metrics</caption><thead><tr><th scope="col">Metric</th><th scope="col">Value</th></tr></thead><tbody>{% for k, v in other_metrics %}<tr><th scope="row">{{ k|label }}</th><td>{{ v|num }}</td></tr>{% endfor %}</tbody></table></div>
45
+ <div class="card"><table><caption>Analyzers</caption><thead><tr><th scope="col">Tool</th><th scope="col">Status</th><th scope="col">Issues</th><th scope="col">Time</th></tr></thead><tbody>
46
+ {% for name, t in analysis.tools.items %}<tr><th scope="row">{{ name }}</th><td class="{% if t.status == 'error' %}fail{% elif t.status == 'ok' %}pass{% else %}muted{% endif %}">{{ t.status|label }}{% if t.detail %}<span class="helptext">{{ t.detail|truncatechars:200 }}</span>{% endif %}</td><td>{{ t.issues|default:"" }}</td><td>{% if t.seconds is not None %}{{ t.seconds }}s{% endif %}</td></tr>{% endfor %}
47
+ </tbody></table></div>
48
+ </div>
49
+ {% endblock %}
@@ -0,0 +1,121 @@
1
+ {% load codewatch %}<!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
5
+ <title>{% block title %}codewatch{% endblock %}</title>
6
+ <style>
7
+ :root { --bg:#fafafa; --fg:#1d1d1f; --muted:#4b5563; --card:#fff; --line:#d1d5db; --accent:#1d4ed8;
8
+ --ok:#166534; --bad:#b91c1c; --warn:#92400e; --code:#f3f4f6; --hl:#fef3c7; --badge-fg:#fff; --focus:#1d4ed8; }
9
+ @media (prefers-color-scheme: dark) { :root { --bg:#0f1115; --fg:#e5e7eb; --muted:#a8b0bd; --card:#171a21;
10
+ --line:#3a414f; --accent:#93c5fd; --ok:#4ade80; --bad:#fca5a5; --warn:#fcd34d; --code:#11141a; --hl:#3a2f12;
11
+ --badge-fg:#0f1115; --focus:#93c5fd; } }
12
+ * { box-sizing:border-box; }
13
+ body { margin:0; font:15px/1.5 system-ui,sans-serif; background:var(--bg); color:var(--fg); }
14
+ .skip { position:absolute; left:-999px; top:8px; background:var(--card); padding:8px 12px; z-index:10; }
15
+ .skip:focus { left:8px; }
16
+ .sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
17
+ header { padding:10px 20px; border-bottom:1px solid var(--line); display:flex; gap:16px; align-items:center; flex-wrap:wrap; }
18
+ header .brand { font-weight:700; }
19
+ header nav ul { list-style:none; margin:0; padding:0; display:flex; gap:14px; flex-wrap:wrap; align-items:center; }
20
+ nav.crumbs ol { list-style:none; margin:0; padding:0; display:flex; gap:6px; flex-wrap:wrap; }
21
+ nav.crumbs li + li::before { content:"/"; margin-right:6px; color:var(--muted); }
22
+ .spacer { flex:1; }
23
+ main { padding:20px; max-width:1200px; margin:0 auto; }
24
+ h1 { font-size:1.5rem; margin:0 0 16px; } h2 { font-size:1.15rem; margin:0 0 10px; }
25
+ a { color:var(--accent); text-decoration:underline; text-underline-offset:2px; }
26
+ :focus-visible { outline:3px solid var(--focus); outline-offset:2px; }
27
+ table { width:100%; border-collapse:collapse; background:var(--card); }
28
+ caption { text-align:left; font-weight:600; padding:0 0 8px; font-size:1.05rem; }
29
+ th, td { padding:6px 10px; border-bottom:1px solid var(--line); text-align:left; vertical-align:top; }
30
+ thead th { font-weight:600; color:var(--muted); font-size:13px; }
31
+ .card { background:var(--card); border:1px solid var(--line); border-radius:8px; padding:16px; margin-bottom:16px; overflow-x:auto; }
32
+ .grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(280px,1fr)); gap:16px; }
33
+ .pass { color:var(--ok); font-weight:600; } .fail { color:var(--bad); font-weight:600; } .muted { color:var(--muted); }
34
+ .sev { display:inline-block; min-width:64px; font-size:13px; font-weight:600; }
35
+ .sev-blocker,.sev-critical { color:var(--bad); } .sev-major { color:var(--warn); } .sev-minor,.sev-info { color:var(--muted); }
36
+ .new { background:var(--accent); color:var(--badge-fg); border-radius:3px; padding:0 5px; font-size:12px; font-weight:600; }
37
+ code, pre { font-family:ui-monospace,monospace; font-size:13px; }
38
+ .src td, .src th { padding:0 8px; border:0; } .src th { font-weight:normal; } .src .ln { color:var(--muted); text-align:right; user-select:none; width:1%; }
39
+ .src pre { margin:0; white-space:pre-wrap; } .src tr.has { background:var(--hl); }
40
+ .src .iss td { padding:4px 8px 6px 60px; background:var(--code); }
41
+ form.inline { display:inline; }
42
+ ul.folders { columns:3 220px; padding-left:18px; } ul.folders li { break-inside:avoid; }
43
+ input, select, textarea, button { font:inherit; color:inherit; background:var(--card); border:1px solid var(--muted); border-radius:4px; padding:4px 8px; }
44
+ button { cursor:pointer; } button.link { border:0; background:none; color:var(--accent); text-decoration:underline; padding:0; }
45
+ .filters { display:flex; gap:10px; flex-wrap:wrap; align-items:end; margin-bottom:12px; }
46
+ .filters label { display:flex; flex-direction:column; font-size:13px; }
47
+ .filters label.check { flex-direction:row; gap:6px; align-items:center; }
48
+ .messages { list-style:none; padding:0; margin:0 0 16px; }
49
+ .messages li { padding:8px 12px; border-radius:6px; border:1px solid var(--line); background:var(--card); margin-bottom:6px; }
50
+ .messages .error { border-color:var(--bad); }
51
+ .form-table th { width:220px; color:var(--fg); font-weight:600; }
52
+ .form-grid { display:grid; gap:0; }
53
+ .form-row { display:grid; grid-template-columns:220px 1fr; gap:12px; padding:8px 0; border-bottom:1px solid var(--line); }
54
+ .form-label { font-weight:600; } .form-field fieldset { border:0; padding:0; margin:0; }
55
+ @media (max-width: 640px) { .form-row { grid-template-columns:1fr; gap:4px; } }
56
+ .helptext { display:block; color:var(--muted); font-size:13px; }
57
+ .errorlist { color:var(--bad); margin:0; padding-left:18px; }
58
+ .rating { display:inline-flex; align-items:center; justify-content:center; min-width:1.9em; height:1.9em; border-radius:50%; font-weight:700; color:#111; }
59
+ .rating-A { background:#a7f3d0; } .rating-B { background:#d9f99d; } .rating-C { background:#fde68a; }
60
+ .rating-D { background:#fed7aa; } .rating-E { background:#fecaca; } .rating-– { background:var(--code); color:var(--fg); }
61
+ .rating.big { min-width:2.6em; height:2.6em; font-size:1.3rem; }
62
+ .scores { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:12px; margin-bottom:16px; }
63
+ .scores .card { margin:0; display:flex; flex-direction:column; gap:6px; }
64
+ .scores .label { font-weight:600; } .scores .sub { color:var(--muted); font-size:13px; }
65
+ .tags { display:flex; gap:6px; flex-wrap:wrap; list-style:none; padding:0; margin:0; }
66
+ .tags li { background:var(--code); border:1px solid var(--line); border-radius:4px; padding:0 6px; font-size:13px; }
67
+ .doc pre { background:var(--code); padding:10px; overflow-x:auto; border-radius:6px; }
68
+ .doc code { background:var(--code); padding:0 3px; border-radius:3px; }
69
+ .doc h2 { font-size:1.05rem; } .doc h3 { font-size:1rem; }
70
+ pre.token { white-space:pre-wrap; }
71
+ .token { font-size:15px; padding:10px; background:var(--code); border:1px dashed var(--line); word-break:break-all; }
72
+ </style>
73
+ </head>
74
+ <body>
75
+ <a class="skip" href="#main">Skip to content</a>
76
+ <header>
77
+ <a class="brand" href="{% url 'index' %}">codewatch</a>
78
+ {% block crumbs_wrap %}<nav class="crumbs" aria-label="Breadcrumb"><ol>{% block crumbs %}{% endblock %}</ol></nav>{% endblock %}
79
+ <span class="spacer"></span>
80
+ <nav aria-label="Account"><ul>
81
+ <li><a href="{% url 'rules' %}">Rules</a></li>
82
+ <li><a href="{% url 'standards' %}">Standards</a></li>
83
+ {% if user.is_authenticated %}
84
+ <li><a href="{% url 'new_project' %}">New project</a></li>
85
+ {% if user.is_superuser %}<li><a href="{% url 'users' %}">Users</a></li>{% endif %}
86
+ <li><a href="{% url 'account' %}">{{ user.username }}</a></li>
87
+ <li><form class="inline" method="post" action="{% url 'logout' %}">{% csrf_token %}<button class="link">Log out</button></form></li>
88
+ {% else %}
89
+ <li><a href="{% url 'login' %}">Log in</a></li>
90
+ {% endif %}
91
+ </ul></nav>
92
+ </header>
93
+ <main id="main" tabindex="-1">
94
+ {% if messages %}<ul class="messages" role="status">{% for m in messages %}<li class="{{ m.tags }}">{{ m }}</li>{% endfor %}</ul>{% endif %}
95
+ {% block content %}{% endblock %}
96
+ </main>
97
+ <script>
98
+ // Sections marked data-live (a running scan's progress) are fetched again every few seconds and swapped in place;
99
+ // once the page no longer has one (the scan finished), it reloads for the results.
100
+ (function () {
101
+ const live = () => document.querySelectorAll("[data-live]");
102
+ const toggle = document.getElementById("live-updates");
103
+ if (!live().length) return;
104
+ const timer = setInterval(async () => {
105
+ if (toggle && !toggle.checked) return;
106
+ let doc;
107
+ try {
108
+ const resp = await fetch(location.href, {credentials: "same-origin"});
109
+ if (!resp.ok) return;
110
+ doc = new DOMParser().parseFromString(await resp.text(), "text/html");
111
+ } catch (e) { return; }
112
+ for (const el of live()) {
113
+ const fresh = doc.getElementById(el.id);
114
+ if (!fresh) { clearInterval(timer); location.reload(); return; }
115
+ el.replaceChildren(...fresh.childNodes);
116
+ }
117
+ }, 4000);
118
+ })();
119
+ </script>
120
+ </body>
121
+ </html>
@@ -0,0 +1,12 @@
1
+ {% if form.non_field_errors %}<div role="alert">{{ form.non_field_errors }}</div>{% endif %}
2
+ {% for field in form.hidden_fields %}{{ field }}{% endfor %}
3
+ <div class="form-grid">
4
+ {% for field in form.visible_fields %}
5
+ <div class="form-row">
6
+ <div class="form-label">{% if field.use_fieldset %}<span aria-hidden="true">{{ field.label }}</span>{% else %}{{ field.label_tag }}{% endif %}</div>
7
+ <div class="form-field">{% if field.use_fieldset %}<fieldset><legend class="sr-only">{{ field.label }}</legend>{{ field }}</fieldset>{% else %}{{ field }}{% endif %}
8
+ {% if field.help_text %}<span class="helptext" id="{{ field.auto_id }}_helptext">{{ field.help_text }}</span>{% endif %}
9
+ {% if field.errors %}<div role="alert">{{ field.errors }}</div>{% endif %}</div>
10
+ </div>
11
+ {% endfor %}
12
+ </div>
@@ -0,0 +1 @@
1
+ {% if not analysis %}<span class="muted">–</span>{% elif analysis.status == "failed" %}<span class="fail">Error</span>{% elif analysis.status == "running" %}<span class="muted">Running</span>{% elif analysis.gate_passed %}<span class="pass">Passed</span>{% else %}<span class="fail">Failed</span>{% endif %}{% if analysis.origin == "client" and analysis.status == "success" %} <span class="muted" title="Uploaded by codewatch-scan: the server didn't run this scan">(self-reported)</span>{% endif %}
@@ -0,0 +1,26 @@
1
+ {% extends "core/base.html" %}{% load codewatch %}
2
+ {% block crumbs_wrap %}{% endblock %}
3
+ {% block content %}
4
+ <h1>Projects</h1>
5
+ <div class="card" id="projects"{% if any_running %} data-live{% endif %}><table>
6
+ <caption class="sr-only">Projects and their main-branch status</caption>
7
+ <thead><tr><th scope="col">Project</th><th scope="col">Health</th><th scope="col">Reliability</th><th scope="col">Security</th><th scope="col">Maintainability</th><th scope="col">Quality gate</th><th scope="col">Coverage</th><th scope="col">Duplication</th><th scope="col">Last analysis</th><th scope="col"><span class="sr-only">Actions</span></th></tr></thead>
8
+ <tbody>
9
+ {% for p, a, scannable, running in projects %}{% with m=a.metrics_dict %}
10
+ <tr><th scope="row"><a href="{% url 'project' p.key %}">{{ p.name }}</a><br><span class="muted">{{ p.main_branch|default:"–" }}</span></th>
11
+ <td>{% if m.health_score is not None %}{% with g=m.health_score|score_grade %}<span class="rating rating-{{ g }}" role="img" aria-label="Health {{ g }}">{{ g }}</span>{% endwith %} {{ m.health_score|num }}{% else %}–{% endif %}</td>
12
+ <td>{% include "core/rating.html" with value=m.reliability_rating what="Reliability" %}</td>
13
+ <td>{% include "core/rating.html" with value=m.security_rating what="Security" %}</td>
14
+ <td>{% include "core/rating.html" with value=m.maintainability_rating what="Maintainability" %}</td>
15
+ <td>{% include "core/gate_badge.html" with analysis=a %}</td>
16
+ <td>{{ m.coverage|num }}{% if m.coverage is not None %}%{% endif %}</td>
17
+ <td>{{ m.duplicated_lines_percent|num }}{% if m.duplicated_lines_percent is not None %}%{% endif %}</td>
18
+ <td>{% if running %}{% with current=running.steps|last %}<strong>Scanning</strong>{% if current %}: {{ current.step|cut:"Running " }}{% endif %}{% endwith %}<br>{% endif %}{% if a %}{{ a.started_at|timesince }} ago{% elif not running %}<span class="muted">never</span>{% endif %}</td>
19
+ <td>{% if scannable %}<form class="inline" method="post" action="{% url 'scan' p.key %}">{% csrf_token %}<input type="hidden" name="next" value="{% url 'index' %}"><button aria-label="Scan {{ p.name }}">Scan</button></form>{% endif %}</td></tr>
20
+ {% endwith %}{% empty %}
21
+ <tr><td colspan="10" class="muted">No projects yet. <a href="{% url 'new_project' %}">Add one</a>.</td></tr>
22
+ {% endfor %}
23
+ </tbody></table></div>
24
+ {% if any_running %}<p><label><input type="checkbox" id="live-updates" checked> Update this page as scans run</label></p>{% endif %}
25
+ <p class="muted"><a href="{% url 'ratings' %}">How ratings and the health score are calculated</a></p>
26
+ {% endblock %}
@@ -0,0 +1,38 @@
1
+ {% extends "core/base.html" %}{% load codewatch %}
2
+ {% block title %}Issues · {{ analysis.branch }} · {{ project.name }}{% endblock %}
3
+ {% block crumbs %}<li><a href="{% url 'project' project.key %}">{{ project.name }}</a></li><li><a href="{% url 'analysis' project.key analysis.pk %}">{{ analysis.branch }}</a></li><li aria-current="page">Issues</li>{% endblock %}
4
+ {% block content %}
5
+ <h1>Issues on {{ analysis.branch }}</h1>
6
+ <form class="filters" method="get" aria-label="Filter issues">
7
+ <label class="check"><input type="checkbox" name="new" value="1" {% if f.new %}checked{% endif %}> New code only</label>
8
+ <label>Status<select name="status">
9
+ <option value="open" {% if status == "open" %}selected{% endif %}>Open</option>
10
+ <option value="resolved" {% if status == "resolved" %}selected{% endif %}>Resolved</option>
11
+ <option value="all" {% if status == "all" %}selected{% endif %}>All</option></select></label>
12
+ <label>Severity<select name="severity"><option value="">Any</option>{% for s in severities %}<option {% if f.severity == s %}selected{% endif %}>{{ s }}</option>{% endfor %}</select></label>
13
+ <label>Type<select name="type"><option value="">Any</option>{% for t in types %}<option value="{{ t }}" {% if f.type == t %}selected{% endif %}>{{ t|label }}</option>{% endfor %}</select></label>
14
+ <label>Tool<select name="tool"><option value="">Any</option>{% for t in tools %}<option {% if f.tool == t %}selected{% endif %}>{{ t }}</option>{% endfor %}</select></label>
15
+ <label>Path contains<input name="path" value="{{ f.path|default:'' }}"></label>
16
+ <button>Filter</button>
17
+ </form>
18
+ <p role="status">{{ page.paginator.count }} issue{{ page.paginator.count|pluralize }}</p>
19
+ <div class="card"><table>
20
+ <caption class="sr-only">Issues</caption>
21
+ <thead><tr><th scope="col">Severity</th><th scope="col">Issue</th><th scope="col">Location</th><th scope="col">Rule</th>{% if can_resolve %}<th scope="col">Resolution</th>{% endif %}</tr></thead>
22
+ <tbody>
23
+ {% for i in page %}
24
+ <tr><td><span class="sev sev-{{ i.severity }}">{{ i.severity }}</span><br><span class="muted">{{ i.type|label }}</span></td>
25
+ <td>{% if i.is_new %}<span class="new">new</span> {% endif %}{{ i.message }}{% if i.also_reported_by %}<br><span class="muted">Also reported by {{ i.also_reported_by|join:", " }}</span>{% endif %}{% if i.resolution %}<br><span class="muted">{{ i.resolution.get_status_display }}{% if i.resolution.comment %}: {{ i.resolution.comment }}{% endif %}</span>{% endif %}</td>
26
+ <td>{% if "://" in i.path %}<a href="{{ i.path }}" rel="noopener noreferrer">{{ i.path }}</a>{% else %}<a href="{% url 'source' project.key analysis.pk %}?path={{ i.path|urlencode }}#L{{ i.line }}">{{ i.path }}{% if i.line %}:{{ i.line }}{% endif %}</a>{% endif %}</td>
27
+ <td>{% rule_for i as r %}{% if r %}<a href="{% url 'rule' r.id %}">{{ r.title }}</a><br>{% endif %}<a href="?{{ query }}&amp;rule={{ i.rule|urlencode }}" aria-label="Filter by rule {{ i.tool }}:{{ i.rule }}"><code>{{ i.tool }}:{{ i.rule }}</code></a></td>
28
+ {% if can_resolve %}<td><form class="inline" method="post" action="{% url 'resolve' project.key %}">{% csrf_token %}
29
+ <input type="hidden" name="fingerprint" value="{{ i.fingerprint }}"><input type="hidden" name="next" value="{{ request.get_full_path }}">
30
+ {% if i.resolution %}<input type="hidden" name="status" value="reopen"><button>Reopen</button>
31
+ {% else %}<label class="sr-only" for="res-{{ i.pk }}">Resolution for issue at {{ i.path }}:{{ i.line }}</label><select id="res-{{ i.pk }}" name="status">{% for v, l in resolution_choices %}<option value="{{ v }}">{{ l }}</option>{% endfor %}</select> <button>Resolve</button>{% endif %}
32
+ </form></td>{% endif %}</tr>
33
+ {% empty %}<tr><td colspan="5" class="muted">No issues match.</td></tr>{% endfor %}
34
+ </tbody></table></div>
35
+ {% if page.has_other_pages %}<nav aria-label="Pagination"><p>{% if page.has_previous %}<a href="?{{ query }}&amp;page={{ page.previous_page_number }}">Previous page</a>{% endif %}
36
+ Page {{ page.number }} of {{ page.paginator.num_pages }}
37
+ {% if page.has_next %}<a href="?{{ query }}&amp;page={{ page.next_page_number }}">Next page</a>{% endif %}</p></nav>{% endif %}
38
+ {% endblock %}
@@ -0,0 +1,13 @@
1
+ {% extends "core/base.html" %}
2
+ {% block title %}Log in · codewatch{% endblock %}
3
+ {% block crumbs_wrap %}{% endblock %}
4
+ {% block content %}
5
+ <h1>Log in</h1>
6
+ <div class="card" style="max-width:480px">
7
+ <form method="post">{% csrf_token %}
8
+ {% include "core/form_table.html" %}
9
+ <input type="hidden" name="next" value="{{ next }}">
10
+ <p><button>Log in</button></p>
11
+ </form>
12
+ </div>
13
+ {% endblock %}
@@ -0,0 +1,27 @@
1
+ {% extends "core/base.html" %}
2
+ {% block title %}New project · codewatch{% endblock %}
3
+ {% block crumbs %}<li aria-current="page">New project</li>{% endblock %}
4
+ {% block content %}
5
+ <h1>New project</h1>
6
+ {% if browse %}
7
+ <section class="card" aria-labelledby="pick-h" style="max-width:820px">
8
+ <h2 id="pick-h">Choose a folder on this machine</h2>
9
+ <p>In <code>{{ browse.absolute }}</code>{% if browse.parent is not None %} · <a href="?folder={{ browse.parent|urlencode }}">Up one folder</a>{% endif %}
10
+ {% if browse.repository %} · <a href="?use={{ browse.path|urlencode }}&amp;folder={{ browse.path|urlencode }}"><strong>Use this folder</strong></a>{% endif %}</p>
11
+ {% if browse.folders %}<ul class="folders">
12
+ {% for f in browse.folders %}<li><a href="?folder={{ f.path|urlencode }}">{{ f.name }}</a>{% if f.repository %} <span class="muted">git</span> · <a href="?use={{ f.path|urlencode }}&amp;folder={{ browse.path|urlencode }}" aria-label="Use {{ f.name }}">Use</a>{% endif %}</li>
13
+ {% endfor %}</ul>{% else %}<p class="muted">No folders here.</p>{% endif %}
14
+ <p class="muted">Folders marked git can be scanned. The title and key come from the folder's name; change them below if you like.</p>
15
+ </section>
16
+ {% endif %}
17
+ <section class="card" aria-labelledby="server-h" style="max-width:820px">
18
+ <h2 id="server-h">{% if picked %}Create {{ picked.name }}{% else %}Let the server clone and scan a repository{% endif %}</h2>
19
+ {% if picked %}<p>The server scans the committed branches of <code>{{ picked.repo_url }}</code>. A scan token for scanning your working copy, uncommitted changes included, is created with the project and shown once on its page.</p>{% endif %}
20
+ <form method="post">{% csrf_token %}{% include "core/form_table.html" %}<p><button>Create and scan</button></p></form>
21
+ </section>
22
+ <section class="card" aria-labelledby="local-h">
23
+ <h2 id="local-h">Or scan your local copy without creating the project here</h2>
24
+ <p>Create a token on your <a href="{% url 'account' %}">account page</a>, then run this in your working copy. The project is created on the first upload:</p>
25
+ <pre class="token">CODEWATCH_URL={{ request.scheme }}://{{ request.get_host }} CODEWATCH_TOKEN=cw_… codewatch-scan --project my-key</pre>
26
+ </section>
27
+ {% endblock %}
@@ -0,0 +1,10 @@
1
+ {% extends "core/base.html" %}
2
+ {% block title %}Change password · codewatch{% endblock %}
3
+ {% block crumbs %}<li><a href="{% url 'account' %}">Account</a></li><li aria-current="page">Change password</li>{% endblock %}
4
+ {% block content %}
5
+ <h1>Change password</h1>
6
+ {% if user.profile.must_change_password %}<p role="alert">You must set a new password before continuing.</p>{% endif %}
7
+ <div class="card" style="max-width:640px">
8
+ <form method="post">{% csrf_token %}{% include "core/form_table.html" %}<p><button>Change password</button></p></form>
9
+ </div>
10
+ {% endblock %}
@@ -0,0 +1,40 @@
1
+ {% extends "core/base.html" %}{% load codewatch %}
2
+ {% block title %}{{ project.name }} · codewatch{% endblock %}
3
+ {% block crumbs %}<li aria-current="page">{{ project.name }}</li>{% endblock %}
4
+ {% block content %}
5
+ <h1>{{ project.name }}</h1>
6
+ <p class="muted">{% if project.repo_url %}Server-side scans from <code>{{ project.repo_url }}</code>.{% else %}Scanned from local copies with <code>codewatch-scan --project {{ project.key }}</code>.{% endif %}
7
+ {% if can_admin %} <a href="{% url 'settings' project.key %}">Project settings</a>{% endif %}</p>
8
+ {% if new_token %}<section class="card" aria-labelledby="token-h">
9
+ <h2 id="token-h">Scan your working copy</h2>
10
+ <p>A scan token was created with this project. Copy it now: it is not shown again (revoke it on your <a href="{% url 'account' %}">account page</a>). In {% if project.repo_url %}<code>{{ project.repo_url }}</code>{% else %}your working copy{% endif %}, run:</p>
11
+ <pre class="token">CODEWATCH_URL={{ request.scheme }}://{{ request.get_host }} CODEWATCH_TOKEN={{ new_token }} codewatch-scan --project {{ project.key }}</pre>
12
+ </section>
13
+ {% endif %}{% if running %}<section class="card" aria-labelledby="running-h">
14
+ <h2 id="running-h">Scan in progress</h2>
15
+ <div id="scan-progress" data-live>{% for a in running %}{% include "core/scan_progress.html" %}{% endfor %}</div>
16
+ <p><label><input type="checkbox" id="live-updates" checked> Update this page as the scan runs</label></p>
17
+ </section>{% endif %}
18
+ <div class="card"><table>
19
+ <caption>Branches</caption>
20
+ <thead><tr><th scope="col">Branch</th><th scope="col">Commit</th><th scope="col">Quality gate</th><th scope="col">New issues</th><th scope="col">Issues</th><th scope="col">New coverage</th><th scope="col">Analysed</th>{% if can_scan and project.repo_url %}<th scope="col"><span class="sr-only">Actions</span></th>{% endif %}</tr></thead>
21
+ <tbody>
22
+ {% for a in latest %}{% with m=a.metrics_dict %}
23
+ <tr><th scope="row"><a href="{% url 'analysis' project.key a.pk %}">{{ a.branch }}</a>{% if a.branch == project.main_branch %} <span class="muted">(main)</span>{% endif %}</th>
24
+ <td><code>{{ a.commit|slice:":8" }}</code>{% if a.dirty %} <span class="muted">+ local changes</span>{% endif %}</td><td>{% include "core/gate_badge.html" with analysis=a %}</td>
25
+ <td>{{ m.new_issues|num }}</td><td>{{ m.issues|num }}</td><td>{{ m.new_coverage|num }}{% if m.new_coverage is not None %}%{% endif %}</td>
26
+ <td>{{ a.started_at|timesince }} ago{% if a.scanned_by %} by {{ a.scanned_by.username }}{% endif %}</td>
27
+ {% if can_scan and project.repo_url %}<td><form class="inline" method="post" action="{% url 'scan' project.key %}">{% csrf_token %}<input type="hidden" name="branch" value="{{ a.branch }}"><button aria-label="Rescan {{ a.branch }}">Rescan</button></form></td>{% endif %}</tr>
28
+ {% endwith %}{% empty %}<tr><td colspan="8" class="muted">No analyses yet.</td></tr>{% endfor %}
29
+ {% if can_scan and project.repo_url %}{% for b in unscanned %}
30
+ <tr><th scope="row">{{ b }}</th><td colspan="6" class="muted">Not analysed</td>
31
+ <td><form class="inline" method="post" action="{% url 'scan' project.key %}">{% csrf_token %}<input type="hidden" name="branch" value="{{ b }}"><button aria-label="Scan {{ b }}">Scan</button></form></td></tr>
32
+ {% endfor %}{% endif %}
33
+ </tbody></table></div>
34
+ <div class="card"><table>
35
+ <caption>History</caption>
36
+ <thead><tr><th scope="col">Started</th><th scope="col">Branch</th><th scope="col">Commit</th><th scope="col">Source</th><th scope="col">Status</th><th scope="col">Quality gate</th></tr></thead>
37
+ <tbody>
38
+ {% for a in history %}<tr><th scope="row"><a href="{% url 'analysis' project.key a.pk %}">{{ a.started_at|date:"Y-m-d H:i" }}</a></th><td>{{ a.branch }}</td><td><code>{{ a.commit|slice:":8" }}</code></td><td>{% if a.origin == "client" %}local scan{% if a.scanned_by %} by {{ a.scanned_by.username }}{% endif %}{% else %}server{% endif %}</td><td>{{ a.status }}</td><td>{% include "core/gate_badge.html" with analysis=a %}</td></tr>{% endfor %}
39
+ </tbody></table></div>
40
+ {% endblock %}
@@ -0,0 +1 @@
1
+ {% load codewatch %}<span class="rating rating-{{ value|grade }}{% if big %} big{% endif %}" role="img" aria-label="{{ what }} rating {{ value|grade }}">{{ value|grade }}</span>
@@ -0,0 +1,32 @@
1
+ {% extends "core/base.html" %}{% load codewatch %}
2
+ {% block title %}Ratings · codewatch{% endblock %}
3
+ {% block crumbs %}<li aria-current="page">Ratings</li>{% endblock %}
4
+ {% block content %}
5
+ <h1>How ratings work</h1>
6
+ <p>Every analysis gets ratings from A (best) to E, overall and for new code. Issues marked won't fix, false positive or safe don't count.</p>
7
+ <section class="card" aria-labelledby="sev-h"><h2 id="sev-h">Reliability, security and accessibility</h2>
8
+ <p>Rated by the worst open issue of that type (bugs, vulnerabilities including vulnerable dependencies, and accessibility issues):</p>
9
+ <table><caption class="sr-only">Severity ratings</caption><thead><tr><th scope="col">Rating</th><th scope="col">Worst open issue</th></tr></thead><tbody>
10
+ <tr><td>{% include "core/rating.html" with value=1 what="" %}</td><td>None</td></tr>
11
+ <tr><td>{% include "core/rating.html" with value=2 what="" %}</td><td>Minor or info</td></tr>
12
+ <tr><td>{% include "core/rating.html" with value=3 what="" %}</td><td>Major</td></tr>
13
+ <tr><td>{% include "core/rating.html" with value=4 what="" %}</td><td>Critical</td></tr>
14
+ <tr><td>{% include "core/rating.html" with value=5 what="" %}</td><td>Blocker</td></tr>
15
+ </tbody></table></section>
16
+ <section class="card" aria-labelledby="maint-h"><h2 id="maint-h">Maintainability</h2>
17
+ <p>The worse of two ratings. The worst open code smell, rated as reliability and security are (a critical smell, such as a function more than twice the complexity threshold, is D), so that many smells in a large project can't hide behind its size. And the technical-debt ratio from the open <a href="https://www.sqale.org/">SQALE method</a>: the estimated time to fix all code smells, divided by the estimated time to write the code ({{ minutes_per_line }} minutes per line of code; for new code, per changed line).</p>
18
+ <p>Fix estimates per code smell: {% for s, m in remediation.items %}{{ s }} {{ m }} min{% if not forloop.last %}, {% endif %}{% endfor %}.</p>
19
+ <table><caption class="sr-only">Debt ratio ratings</caption><thead><tr><th scope="col">Rating</th><th scope="col">Debt ratio</th></tr></thead><tbody>
20
+ {% for limit, r in debt_limits %}<tr><td>{% include "core/rating.html" with value=r what="" %}</td><td>up to {{ limit }}%</td></tr>{% endfor %}
21
+ <tr><td>{% include "core/rating.html" with value=5 what="" %}</td><td>above 50%</td></tr>
22
+ </tbody></table></section>
23
+ <section class="card" aria-labelledby="review-h"><h2 id="review-h">Security review</h2>
24
+ <p>Security hotspots are security-sensitive code that needs a human decision. This rating is the share of hotspots that have been reviewed (marked safe, won't fix or false positive after checking):</p>
25
+ <table><caption class="sr-only">Review ratings</caption><thead><tr><th scope="col">Rating</th><th scope="col">Reviewed</th></tr></thead><tbody>
26
+ {% for limit, r in review_limits %}<tr><td>{% include "core/rating.html" with value=r what="" %}</td><td>at least {{ limit }}%</td></tr>{% endfor %}
27
+ <tr><td>{% include "core/rating.html" with value=5 what="" %}</td><td>below 30%</td></tr>
28
+ </tbody></table></section>
29
+ <section class="card" aria-labelledby="health-h"><h2 id="health-h">Health score</h2>
30
+ <p>The average of the reliability, security, security review and maintainability ratings, plus accessibility when an accessibility analyzer ran, with A = {{ score.1 }}, B = {{ score.2 }}, C = {{ score.3 }}, D = {{ score.4 }} and E = {{ score.5 }}. Shown as a letter: A from 90, B from 75, C from 60, D from 40, otherwise E.</p>
31
+ </section>
32
+ {% endblock %}
@@ -0,0 +1,33 @@
1
+ {% extends "core/base.html" %}{% load codewatch %}
2
+ {% block title %}{{ rule.title }} · Rules{% endblock %}
3
+ {% block crumbs %}<li><a href="{% url 'rules' %}">Rules</a></li><li aria-current="page">{{ rule.id }}</li>{% endblock %}
4
+ {% block content %}
5
+ <h1>{{ rule.title }}</h1>
6
+ <p><code>{{ rule.id }}</code>{% if rule.origin != "imported" %} · <strong>{{ rule.origin }}</strong> rule{% endif %}{% if rule.overridden %} · overridden locally{% endif %}</p>
7
+ {% if rule.summary %}<p>{{ rule.summary }}</p>{% endif %}
8
+ <div class="card"><table class="form-table">
9
+ <caption class="sr-only">Rule details</caption>
10
+ <tbody>
11
+ <tr><th scope="row">Type</th><td>{{ rule.type|label }}</td></tr>
12
+ <tr><th scope="row">Default severity</th><td><span class="sev sev-{{ rule.severity }}">{{ rule.severity }}</span></td></tr>
13
+ <tr><th scope="row">Languages</th><td>{{ rule.languages|join:", " }}</td></tr>
14
+ <tr><th scope="row">Source</th><td>{{ rule.tool }}{% if rule.docs %}: <a href="{{ rule.docs }}" rel="noopener noreferrer">original documentation</a>{% endif %} ({{ rule.license }})</td></tr>
15
+ {% if rule.owasp %}<tr><th scope="row">OWASP Top 10</th><td><ul class="tags">{% for o in rule.owasp %}<li><a href="{% url 'rules' %}?owasp={{ o|urlencode }}">{{ o }}</a></li>{% endfor %}</ul></td></tr>{% endif %}
16
+ {% if rule.wcag %}<tr><th scope="row">WCAG 2.2</th><td><ul class="tags">{% for w in rule.wcag %}<li><a href="{% url 'rules' %}?wcag={{ w }}">{{ w }}</a></li>{% endfor %}</ul></td></tr>{% endif %}
17
+ {% if same_as %}<tr><th scope="row">Same check as</th><td><ul class="tags">{% for s in same_as %}<li><a href="{% url 'rule' s.id %}">{{ s.id }}</a></li>{% endfor %}</ul><span class="helptext">When several tools report this on the same line, codewatch shows one issue.</span></td></tr>{% endif %}
18
+ {% if rule.mapped_by %}<tr><th scope="row">Mapping</th><td>Some standards mappings were added by codewatch, because the analyzer doesn't publish them.</td></tr>{% endif %}
19
+ </tbody></table></div>
20
+ {% if doc %}<section class="card" aria-labelledby="doc-h"><h2 id="doc-h">What's wrong and how to fix it</h2>
21
+ <div class="doc">{{ doc }}</div>
22
+ <p class="muted">From the {{ rule.tool }} documentation ({{ rule.license }}){% if rule.docs %}; <a href="{{ rule.docs }}" rel="noopener noreferrer">read the original</a>{% endif %}.</p></section>{% endif %}
23
+ {% for c in cwes %}<section class="card" aria-labelledby="cwe-{{ c.id }}-h"><h2 id="cwe-{{ c.id }}-h">CWE-{{ c.id }}: {{ c.name }}</h2>
24
+ {% if c.description %}<h3>What's wrong</h3><p>{{ c.description }}</p>{% endif %}
25
+ {% if c.extended %}<p>{{ c.extended|linebreaksbr }}</p>{% endif %}
26
+ {% if c.mitigations %}<h3>How to fix it</h3><ul>{% for m in c.mitigations %}<li>{% if m.phase %}<strong>{{ m.phase }}:</strong> {% endif %}{{ m.text|linebreaksbr }}</li>{% endfor %}</ul>{% endif %}
27
+ {% for ex in c.examples %}<h3>Example {{ forloop.counter }}</h3>{% if ex.intro %}<p>{{ ex.intro }}</p>{% endif %}
28
+ {% for code in ex.code %}<p class="muted">{{ code.nature|default:"Example" }} code{% if code.language %} ({{ code.language }}){% endif %}:</p><pre class="token">{{ code.code }}</pre>{% endfor %}
29
+ {% if ex.body %}<p>{{ ex.body }}</p>{% endif %}{% endfor %}
30
+ <p class="muted">From <a href="{{ c.url }}" rel="noopener noreferrer">MITRE CWE-{{ c.id }}</a>, used under the CWE Terms of Use.</p></section>{% endfor %}
31
+ {% if rule.references %}<section class="card" aria-labelledby="refs-h"><h2 id="refs-h">References</h2>
32
+ <ul>{% for ref in rule.references %}<li><a href="{{ ref.url }}" rel="noopener noreferrer">{{ ref.label }}</a></li>{% endfor %}</ul></section>{% endif %}
33
+ {% endblock %}
@@ -0,0 +1,42 @@
1
+ {% extends "core/base.html" %}{% load codewatch %}
2
+ {% block title %}Rules · codewatch{% endblock %}
3
+ {% block crumbs %}<li aria-current="page">Rules</li>{% endblock %}
4
+ {% block content %}
5
+ <h1>Rule catalogue</h1>
6
+ <p>{{ total }} rules from open-source analyzers, each linked to its source documentation and to the standards it maps to: <a href="https://cwe.mitre.org/">MITRE CWE</a>, the <a href="https://owasp.org/Top10/2025/">OWASP Top 10 (2025)</a>, <a href="https://www.w3.org/TR/WCAG22/">WCAG 2.2</a> and Python PEPs. See <a href="{% url 'standards' %}">standards coverage</a> for gaps. The catalogue is also published as <code>catalog/rules.json</code> in the codewatch repository.</p>
7
+ <section class="card" aria-labelledby="source-h"><h2 id="source-h">Sources and updates</h2>
8
+ <p>{% if meta.imported_at %}Imported {{ meta.imported_at }} ({{ meta.rules }} rules; CWE {{ meta.standards.cwe }}, WCAG {{ meta.standards.wcag }}, OWASP {{ meta.standards.owasp }}).{% else %}Not imported yet.{% endif %}
9
+ {% if changes.at %}Last import added {{ changes.added|length }} and removed {{ changes.removed|length }} rules.{% endif %}
10
+ {% if meta.failed_sources %}<span class="fail">Failed sources: {{ meta.failed_sources|join:", " }}.</span>{% endif %}
11
+ Imported rules are refreshed automatically every {{ interval_days }} days. Custom rules, mappings and overrides in <code>catalog/custom/</code> are never changed by an import.</p>
12
+ {% if status.state %}<p role="status">Update status: <strong>{{ status.state }}</strong>{% if status.finished_at %} at {{ status.finished_at }}{% endif %}{% if status.error %}: {{ status.error|truncatechars:200 }}{% endif %}</p>{% endif %}
13
+ {% if user.is_superuser %}<form method="post" action="{% url 'update_rules' %}" class="filters">{% csrf_token %}
14
+ <button>Update rules now</button><button name="upgrade" value="1">Upgrade analyzers and update rules</button></form>{% endif %}
15
+ </section>
16
+ <form class="filters" method="get" aria-label="Filter rules">
17
+ <label>Search<input name="q" value="{{ f.q|default:'' }}"></label>
18
+ <label>Tool<select name="tool"><option value="">Any</option>{% for t, n in tools %}<option value="{{ t }}" {% if f.tool == t %}selected{% endif %}>{{ t }} ({{ n }})</option>{% endfor %}</select></label>
19
+ <label>Language<select name="language"><option value="">Any</option>{% for c, n in languages %}<option value="{{ c }}" {% if f.language == c %}selected{% endif %}>{{ n }}</option>{% endfor %}</select></label>
20
+ <label>Origin<select name="origin"><option value="">Any</option>{% for o, n, c in origins %}<option value="{{ o }}" {% if f.origin == o %}selected{% endif %}>{{ n }} ({{ c }})</option>{% endfor %}</select></label>
21
+ <label class="check"><input type="checkbox" name="duplicates" value="1" {% if f.duplicates %}checked{% endif %}> Has equivalents</label>
22
+ <label>Type<select name="type"><option value="">Any</option>{% for t in types %}<option value="{{ t }}" {% if f.type == t %}selected{% endif %}>{{ t|label }}</option>{% endfor %}</select></label>
23
+ <label>CWE<input name="cwe" inputmode="numeric" size="6" value="{{ f.cwe|default:'' }}"></label>
24
+ <label>OWASP<select name="owasp"><option value="">Any</option>{% for c in standards.owasp.categories %}<option value="{{ c.id }}" {% if f.owasp == c.id %}selected{% endif %}>{{ c.id }} {{ c.name }}</option>{% endfor %}</select></label>
25
+ <label>WCAG SC<input name="wcag" size="6" value="{{ f.wcag|default:'' }}"></label>
26
+ <button>Filter</button>
27
+ </form>
28
+ <p role="status">{{ page.paginator.count }} matching rule{{ page.paginator.count|pluralize }}</p>
29
+ <div class="card"><table>
30
+ <caption class="sr-only">Rules</caption>
31
+ <thead><tr><th scope="col">Rule</th><th scope="col">Type</th><th scope="col">Languages</th><th scope="col">Standards</th></tr></thead>
32
+ <tbody>
33
+ {% for r in page %}<tr><th scope="row"><a href="{% url 'rule' r.id %}">{{ r.title }}</a><br><code class="muted">{{ r.id }}</code></th>
34
+ <td>{{ r.type|label }}<br><span class="sev sev-{{ r.severity }}">{{ r.severity }}</span>{% if r.origin != "imported" %}<br><span class="muted">{{ r.origin }}</span>{% endif %}</td>
35
+ <td>{{ r.languages|join:", " }}</td>
36
+ <td><ul class="tags">{% for c in r.cwe|slice:":4" %}<li>CWE-{{ c }}</li>{% endfor %}{% for o in r.owasp|slice:":3" %}<li>{{ o }}</li>{% endfor %}{% for w in r.wcag|slice:":3" %}<li>WCAG {{ w }}</li>{% endfor %}</ul></td></tr>
37
+ {% empty %}<tr><td colspan="4" class="muted">No rules match.</td></tr>{% endfor %}
38
+ </tbody></table></div>
39
+ {% if page.has_other_pages %}<nav aria-label="Pagination"><p>{% if page.has_previous %}<a href="?{{ query }}&amp;page={{ page.previous_page_number }}">Previous page</a>{% endif %}
40
+ Page {{ page.number }} of {{ page.paginator.num_pages }}
41
+ {% if page.has_next %}<a href="?{{ query }}&amp;page={{ page.next_page_number }}">Next page</a>{% endif %}</p></nav>{% endif %}
42
+ {% endblock %}
@@ -0,0 +1,2 @@
1
+ {% with steps=a.steps %}<p><strong>{{ a.branch }}</strong>, started {{ a.started_at|timesince }} ago: {% if steps %}{% with current=steps|last %}{{ current.step }} (for {{ current.at|timesince }}){% endwith %}{% else %}preparing the checkout{% endif %}</p>
2
+ {% if steps|length > 1 %}<p class="muted">Finished: {% for s in steps %}{% if not forloop.last %}{{ s.step|cut:"Running " }}{% if forloop.revcounter > 2 %}, {% endif %}{% endif %}{% endfor %}</p>{% endif %}{% endwith %}
@@ -0,0 +1,36 @@
1
+ {% extends "core/base.html" %}
2
+ {% block title %}Settings · {{ project.name }}{% endblock %}
3
+ {% block crumbs %}<li><a href="{% url 'project' project.key %}">{{ project.name }}</a></li><li aria-current="page">Settings</li>{% endblock %}
4
+ {% block content %}
5
+ <h1>Settings for {{ project.name }}</h1>
6
+ <form method="post">{% csrf_token %}
7
+ <section class="card" aria-labelledby="proj-h"><h2 id="proj-h">Project</h2>{% include "core/form_table.html" %}</section>
8
+ <section class="card" aria-labelledby="gate-h"><h2 id="gate-h">Quality gate</h2>
9
+ <p class="muted">The gate fails when any condition is met. Conditions on metrics an analysis didn't produce are skipped.</p>
10
+ {{ formset.management_form }}
11
+ <table><caption class="sr-only">Gate conditions</caption>
12
+ <thead><tr><th scope="col">Metric</th><th scope="col">Fails when</th><th scope="col">Threshold</th><th scope="col">Delete</th></tr></thead><tbody>
13
+ {% for f in formset %}<tr>{{ f.id }}
14
+ <td><label class="sr-only" for="{{ f.metric.auto_id }}">Metric</label>{{ f.metric }}</td>
15
+ <td><label class="sr-only" for="{{ f.op.auto_id }}">Fails when</label>{{ f.op }}</td>
16
+ <td><label class="sr-only" for="{{ f.threshold.auto_id }}">Threshold</label>{{ f.threshold }}</td>
17
+ <td><label class="sr-only" for="{{ f.DELETE.auto_id }}">Delete condition</label>{{ f.DELETE }}</td></tr>{% endfor %}
18
+ </tbody></table></section>
19
+ <p><button>Save settings</button></p>
20
+ </form>
21
+ <section class="card" aria-labelledby="members-h"><h2 id="members-h">Members</h2>
22
+ <p class="muted">Owner: {{ project.owner.username|default:"none" }}. Contributors can upload scans with their own token and resolve issues; viewers can only see results.</p>
23
+ <table><caption class="sr-only">Project members</caption>
24
+ <thead><tr><th scope="col">User</th><th scope="col">Role</th><th scope="col"><span class="sr-only">Actions</span></th></tr></thead><tbody>
25
+ {% for m in members %}<tr><th scope="row">{{ m.user.username }}</th><td>{{ m.get_role_display }}</td>
26
+ <td><form class="inline" method="post" action="{% url 'members' project.key %}">{% csrf_token %}<input type="hidden" name="remove" value="{{ m.pk }}"><button aria-label="Remove {{ m.user.username }}">Remove</button></form></td></tr>
27
+ {% empty %}<tr><td colspan="3" class="muted">No members yet.</td></tr>{% endfor %}
28
+ </tbody></table>
29
+ <form method="post" action="{% url 'members' project.key %}" class="filters" style="margin-top:12px">{% csrf_token %}
30
+ <label>Username{{ member_form.username }}</label><label>Role{{ member_form.role }}</label><button>Add member</button>
31
+ </form></section>
32
+ <section class="card" aria-labelledby="danger-h"><h2 id="danger-h">Delete project</h2>
33
+ <form method="post" action="{% url 'delete_project' project.key %}" class="filters">{% csrf_token %}
34
+ <label>Type <code>{{ project.key }}</code> to confirm<input name="confirm" autocomplete="off"></label><button>Delete project</button>
35
+ </form></section>
36
+ {% endblock %}
@@ -0,0 +1,15 @@
1
+ {% extends "core/base.html" %}{% load codewatch %}
2
+ {% block title %}{{ path }} · {{ project.name }}{% endblock %}
3
+ {% block crumbs %}<li><a href="{% url 'project' project.key %}">{{ project.name }}</a></li><li><a href="{% url 'analysis' project.key analysis.pk %}">{{ analysis.branch }}</a></li><li aria-current="page">{{ path }}</li>{% endblock %}
4
+ {% block content %}
5
+ <h1><code>{{ path }}</code></h1>
6
+ {% if file_issues %}<section class="card" aria-label="File-level issues">{% for i in file_issues %}<p><span class="sev sev-{{ i.severity }}">{{ i.severity }}</span> {% if i.is_new %}<span class="new">new</span> {% endif %}{{ i.message }} <code class="muted">{{ i.tool }}:{{ i.rule }}</code></p>{% endfor %}</section>{% endif %}
7
+ <div class="card"><table class="src">
8
+ <caption class="sr-only">Source of {{ path }} with issues shown below the affected lines</caption>
9
+ <tbody>
10
+ {% for n, text, issues in lines %}
11
+ <tr id="L{{ n }}" {% if issues %}class="has"{% endif %}><th scope="row" class="ln">{{ n }}</th><td><pre>{{ text }}</pre></td></tr>
12
+ {% for i in issues %}<tr class="iss"><td colspan="2"><span class="sev sev-{{ i.severity }}">{{ i.severity }}</span> {% if i.is_new %}<span class="new">new</span> {% endif %}{{ i.message }} <code class="muted">{{ i.tool }}:{{ i.rule }}</code></td></tr>{% endfor %}
13
+ {% endfor %}
14
+ </tbody></table></div>
15
+ {% endblock %}