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.
- codewatch/__init__.py +0 -0
- codewatch/__main__.py +14 -0
- codewatch/asgi.py +16 -0
- codewatch/settings.py +175 -0
- codewatch/urls.py +40 -0
- codewatch/wsgi.py +16 -0
- codewatch_scan-0.1.0.dist-info/METADATA +81 -0
- codewatch_scan-0.1.0.dist-info/RECORD +136 -0
- codewatch_scan-0.1.0.dist-info/WHEEL +5 -0
- codewatch_scan-0.1.0.dist-info/entry_points.txt +4 -0
- codewatch_scan-0.1.0.dist-info/licenses/LICENSE +21 -0
- codewatch_scan-0.1.0.dist-info/top_level.txt +2 -0
- core/__init__.py +0 -0
- core/analyzers/__init__.py +19 -0
- core/analyzers/accessibility.py +199 -0
- core/analyzers/base.py +192 -0
- core/analyzers/body_models.py +154 -0
- core/analyzers/codewatch_checks.py +394 -0
- core/analyzers/constant_branches.py +251 -0
- core/analyzers/containers.py +316 -0
- core/analyzers/coverage.py +131 -0
- core/analyzers/dependencies.py +347 -0
- core/analyzers/drf_serializers.py +65 -0
- core/analyzers/else_branches.py +106 -0
- core/analyzers/extra.py +400 -0
- core/analyzers/flask_resources.py +65 -0
- core/analyzers/inline_scripts.py +50 -0
- core/analyzers/jinja_sandboxes.py +63 -0
- core/analyzers/match_statements.py +148 -0
- core/analyzers/multi_tools.py +888 -0
- core/analyzers/php_template_sinks.py +444 -0
- core/analyzers/project_checks.py +150 -0
- core/analyzers/python_tools.py +333 -0
- core/analyzers/route_converters.py +237 -0
- core/analyzers/slices.py +94 -0
- core/analyzers/starred_targets.py +42 -0
- core/analyzers/stored_fields.py +386 -0
- core/analyzers/summaries.py +1387 -0
- core/analyzers/template_sinks.py +162 -0
- core/api.py +360 -0
- core/apps.py +6 -0
- core/benchmark.py +955 -0
- core/bundled/catalog/codewatch/rules/javascript-crypto.yml +224 -0
- core/bundled/catalog/codewatch/rules/javascript-injection.yml +116 -0
- core/bundled/catalog/codewatch/rules/javascript-taint.yml +1539 -0
- core/bundled/catalog/codewatch/rules/javascript-web.yml +562 -0
- core/bundled/catalog/codewatch/rules/php-web.yml +719 -0
- core/bundled/catalog/codewatch/rules/python-crypto.yml +203 -0
- core/bundled/catalog/codewatch/rules/python-django.yml +267 -0
- core/bundled/catalog/codewatch/rules/python-injection.yml +115 -0
- core/bundled/catalog/codewatch/rules/python-web.yml +3382 -0
- core/bundled/catalog/custom/mappings.json +360 -0
- core/bundled/catalog/custom/overrides.json +4 -0
- core/bundled/catalog/custom/rules/django-settings.yml +19 -0
- core/bundled/catalog/imported/changes.json +5 -0
- core/bundled/catalog/imported/docs.json +1143 -0
- core/bundled/catalog/imported/meta.json +54 -0
- core/bundled/catalog/imported/rules.json +85421 -0
- core/bundled/catalog/imported/standards.json +11191 -0
- core/bundled/tools/analyzers.lock +786 -0
- core/bundled/tools/axe-scan.mjs +45 -0
- core/bundled/tools/checkov.lock +2463 -0
- core/bundled/tools/codewatch-checks.mjs +99 -0
- core/bundled/tools/eslint-a11y.config.js +16 -0
- core/bundled/tools/eslint-quality.config.js +63 -0
- core/bundled/tools/eslint-typed.config.js +18 -0
- core/bundled/tools/package-lock.json +6102 -0
- core/bundled/tools/package.json +32 -0
- core/bundled/tools/rule-metadata.mjs +56 -0
- core/bundled/tools/semgrep.lock +1232 -0
- core/bundled/tools/stylelint.config.json +11 -0
- core/catalog/__init__.py +190 -0
- core/catalog/build.py +84 -0
- core/catalog/merge.py +122 -0
- core/catalog/sources.py +418 -0
- core/catalog/standards.py +119 -0
- core/catalog/update.py +99 -0
- core/catalog_views.py +115 -0
- core/client.py +645 -0
- core/collect.py +518 -0
- core/duplicates.py +60 -0
- core/fingerprint.py +25 -0
- core/folders.py +73 -0
- core/gate.py +77 -0
- core/git.py +149 -0
- core/jobs.py +86 -0
- core/management/__init__.py +0 -0
- core/management/commands/__init__.py +0 -0
- core/management/commands/addproject.py +40 -0
- core/management/commands/buildcatalog.py +15 -0
- core/management/commands/scan.py +74 -0
- core/management/commands/updatecatalog.py +14 -0
- core/mcp_server.py +140 -0
- core/middleware.py +17 -0
- core/migrations/0001_initial.py +115 -0
- core/migrations/0002_auth_tokens_a11y.py +60 -0
- core/migrations/0003_default_admin.py +43 -0
- core/migrations/0004_project_members.py +28 -0
- core/migrations/0005_uploads_and_sources.py +55 -0
- core/migrations/0006_thresholds.py +28 -0
- core/migrations/0007_also_reported_by.py +18 -0
- core/migrations/0008_new_code_period.py +18 -0
- core/migrations/0009_resolution_safe.py +18 -0
- core/migrations/0010_analysis_progress.py +18 -0
- core/migrations/0011_overall_gate_conditions.py +20 -0
- core/migrations/__init__.py +0 -0
- core/models.py +323 -0
- core/network.py +41 -0
- core/paths.py +29 -0
- core/ratings.py +67 -0
- core/runner.py +168 -0
- core/templates/core/account.html +30 -0
- core/templates/core/analysis.html +49 -0
- core/templates/core/base.html +121 -0
- core/templates/core/form_table.html +12 -0
- core/templates/core/gate_badge.html +1 -0
- core/templates/core/index.html +26 -0
- core/templates/core/issues.html +38 -0
- core/templates/core/login.html +13 -0
- core/templates/core/new_project.html +27 -0
- core/templates/core/password_change.html +10 -0
- core/templates/core/project.html +40 -0
- core/templates/core/rating.html +1 -0
- core/templates/core/ratings.html +32 -0
- core/templates/core/rule.html +33 -0
- core/templates/core/rules.html +42 -0
- core/templates/core/scan_progress.html +2 -0
- core/templates/core/settings.html +36 -0
- core/templates/core/source.html +15 -0
- core/templates/core/standards.html +30 -0
- core/templates/core/user_edit.html +15 -0
- core/templates/core/users.html +18 -0
- core/templatetags/__init__.py +0 -0
- core/templatetags/codewatch.py +42 -0
- core/tool_setup.py +68 -0
- core/views.py +564 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Generated by Django 5.2.18 on 2026-10-28 18:37
|
|
2
|
+
|
|
3
|
+
import core.models
|
|
4
|
+
import django.db.models.deletion
|
|
5
|
+
from django.db import migrations, models
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Migration(migrations.Migration):
|
|
9
|
+
|
|
10
|
+
initial = True
|
|
11
|
+
|
|
12
|
+
dependencies = [
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
operations = [
|
|
16
|
+
migrations.CreateModel(
|
|
17
|
+
name='Analysis',
|
|
18
|
+
fields=[
|
|
19
|
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
20
|
+
('branch', models.CharField(max_length=200)),
|
|
21
|
+
('commit', models.CharField(max_length=40)),
|
|
22
|
+
('reference_branch', models.CharField(blank=True, max_length=200)),
|
|
23
|
+
('reference_commit', models.CharField(blank=True, max_length=40)),
|
|
24
|
+
('started_at', models.DateTimeField(auto_now_add=True)),
|
|
25
|
+
('finished_at', models.DateTimeField(blank=True, null=True)),
|
|
26
|
+
('status', models.CharField(choices=[('running', 'running'), ('success', 'success'), ('failed', 'failed')], default='running', max_length=10)),
|
|
27
|
+
('error', models.TextField(blank=True)),
|
|
28
|
+
('gate_passed', models.BooleanField(null=True)),
|
|
29
|
+
('gate_details', models.JSONField(blank=True, default=list)),
|
|
30
|
+
('tools', models.JSONField(blank=True, default=dict)),
|
|
31
|
+
],
|
|
32
|
+
options={
|
|
33
|
+
'ordering': ['-started_at'],
|
|
34
|
+
},
|
|
35
|
+
),
|
|
36
|
+
migrations.CreateModel(
|
|
37
|
+
name='Project',
|
|
38
|
+
fields=[
|
|
39
|
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
40
|
+
('key', models.SlugField(unique=True)),
|
|
41
|
+
('name', models.CharField(max_length=200)),
|
|
42
|
+
('repo_url', models.CharField(help_text='Local path or git URL', max_length=500)),
|
|
43
|
+
('main_branch', models.CharField(default='main', max_length=200)),
|
|
44
|
+
('exclusions', models.JSONField(blank=True, default=core.models.default_exclusions)),
|
|
45
|
+
('disabled_analyzers', models.JSONField(blank=True, default=list)),
|
|
46
|
+
('semgrep_config', models.CharField(default='p/default', max_length=200)),
|
|
47
|
+
('complexity_threshold', models.PositiveIntegerField(default=10)),
|
|
48
|
+
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
49
|
+
],
|
|
50
|
+
),
|
|
51
|
+
migrations.CreateModel(
|
|
52
|
+
name='Issue',
|
|
53
|
+
fields=[
|
|
54
|
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
55
|
+
('fingerprint', models.CharField(db_index=True, max_length=40)),
|
|
56
|
+
('tool', models.CharField(max_length=30)),
|
|
57
|
+
('rule', models.CharField(max_length=300)),
|
|
58
|
+
('severity', models.CharField(choices=[('blocker', 'blocker'), ('critical', 'critical'), ('major', 'major'), ('minor', 'minor'), ('info', 'info')], max_length=10)),
|
|
59
|
+
('type', models.CharField(choices=[('bug', 'bug'), ('vulnerability', 'vulnerability'), ('code_smell', 'code_smell')], max_length=15)),
|
|
60
|
+
('message', models.TextField()),
|
|
61
|
+
('path', models.CharField(max_length=500)),
|
|
62
|
+
('line', models.PositiveIntegerField(null=True)),
|
|
63
|
+
('end_line', models.PositiveIntegerField(null=True)),
|
|
64
|
+
('is_new', models.BooleanField(default=False)),
|
|
65
|
+
('analysis', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='issues', to='core.analysis')),
|
|
66
|
+
],
|
|
67
|
+
options={
|
|
68
|
+
'ordering': ['path', 'line'],
|
|
69
|
+
},
|
|
70
|
+
),
|
|
71
|
+
migrations.CreateModel(
|
|
72
|
+
name='GateCondition',
|
|
73
|
+
fields=[
|
|
74
|
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
75
|
+
('metric', models.CharField(max_length=60)),
|
|
76
|
+
('op', models.CharField(choices=[('gt', 'is greater than'), ('lt', 'is less than')], max_length=2)),
|
|
77
|
+
('threshold', models.FloatField()),
|
|
78
|
+
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='gate_conditions', to='core.project')),
|
|
79
|
+
],
|
|
80
|
+
options={
|
|
81
|
+
'ordering': ['metric'],
|
|
82
|
+
},
|
|
83
|
+
),
|
|
84
|
+
migrations.AddField(
|
|
85
|
+
model_name='analysis',
|
|
86
|
+
name='project',
|
|
87
|
+
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='analyses', to='core.project'),
|
|
88
|
+
),
|
|
89
|
+
migrations.CreateModel(
|
|
90
|
+
name='Metric',
|
|
91
|
+
fields=[
|
|
92
|
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
93
|
+
('key', models.CharField(max_length=60)),
|
|
94
|
+
('value', models.FloatField()),
|
|
95
|
+
('analysis', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='metrics', to='core.analysis')),
|
|
96
|
+
],
|
|
97
|
+
options={
|
|
98
|
+
'constraints': [models.UniqueConstraint(fields=('analysis', 'key'), name='uniq_metric')],
|
|
99
|
+
},
|
|
100
|
+
),
|
|
101
|
+
migrations.CreateModel(
|
|
102
|
+
name='IssueResolution',
|
|
103
|
+
fields=[
|
|
104
|
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
105
|
+
('fingerprint', models.CharField(max_length=40)),
|
|
106
|
+
('status', models.CharField(choices=[('wont_fix', "Won't fix"), ('false_positive', 'False positive')], max_length=20)),
|
|
107
|
+
('comment', models.TextField(blank=True)),
|
|
108
|
+
('updated_at', models.DateTimeField(auto_now=True)),
|
|
109
|
+
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='resolutions', to='core.project')),
|
|
110
|
+
],
|
|
111
|
+
options={
|
|
112
|
+
'constraints': [models.UniqueConstraint(fields=('project', 'fingerprint'), name='uniq_resolution')],
|
|
113
|
+
},
|
|
114
|
+
),
|
|
115
|
+
]
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Generated by Django 5.2.18 on 2026-10-28 19:08
|
|
2
|
+
|
|
3
|
+
import django.db.models.deletion
|
|
4
|
+
from django.conf import settings
|
|
5
|
+
from django.db import migrations, models
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Migration(migrations.Migration):
|
|
9
|
+
|
|
10
|
+
dependencies = [
|
|
11
|
+
('core', '0001_initial'),
|
|
12
|
+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
operations = [
|
|
16
|
+
migrations.AddField(
|
|
17
|
+
model_name='project',
|
|
18
|
+
name='a11y_urls',
|
|
19
|
+
field=models.JSONField(blank=True, default=list, help_text='Live pages to check with axe-core; {branch} is replaced by the branch name'),
|
|
20
|
+
),
|
|
21
|
+
migrations.AddField(
|
|
22
|
+
model_name='project',
|
|
23
|
+
name='owner',
|
|
24
|
+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='projects', to=settings.AUTH_USER_MODEL),
|
|
25
|
+
),
|
|
26
|
+
migrations.AlterField(
|
|
27
|
+
model_name='issue',
|
|
28
|
+
name='type',
|
|
29
|
+
field=models.CharField(choices=[('bug', 'bug'), ('vulnerability', 'vulnerability'), ('security_hotspot', 'security_hotspot'), ('code_smell', 'code_smell'), ('accessibility', 'accessibility')], max_length=20),
|
|
30
|
+
),
|
|
31
|
+
migrations.AlterField(
|
|
32
|
+
model_name='project',
|
|
33
|
+
name='main_branch',
|
|
34
|
+
field=models.CharField(blank=True, help_text='Detected on first scan if blank', max_length=200),
|
|
35
|
+
),
|
|
36
|
+
migrations.CreateModel(
|
|
37
|
+
name='ApiToken',
|
|
38
|
+
fields=[
|
|
39
|
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
40
|
+
('name', models.CharField(max_length=100)),
|
|
41
|
+
('scope', models.CharField(choices=[('read', 'Read issues and results, resolve issues'), ('scan', 'Read, resolve, and create projects / start scans')], default='scan', max_length=10)),
|
|
42
|
+
('prefix', models.CharField(max_length=12)),
|
|
43
|
+
('key_hash', models.CharField(max_length=64, unique=True)),
|
|
44
|
+
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
45
|
+
('last_used_at', models.DateTimeField(blank=True, null=True)),
|
|
46
|
+
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='api_tokens', to=settings.AUTH_USER_MODEL)),
|
|
47
|
+
],
|
|
48
|
+
options={
|
|
49
|
+
'ordering': ['-created_at'],
|
|
50
|
+
},
|
|
51
|
+
),
|
|
52
|
+
migrations.CreateModel(
|
|
53
|
+
name='Profile',
|
|
54
|
+
fields=[
|
|
55
|
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
56
|
+
('must_change_password', models.BooleanField(default=False)),
|
|
57
|
+
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL)),
|
|
58
|
+
],
|
|
59
|
+
),
|
|
60
|
+
]
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import secrets
|
|
3
|
+
|
|
4
|
+
from django.conf import settings
|
|
5
|
+
from django.contrib.auth.hashers import make_password
|
|
6
|
+
from django.db import migrations
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def initial_password():
|
|
10
|
+
"""CODEWATCH_ADMIN_PASSWORD, else a random one in a file only this account can read. A well-known default
|
|
11
|
+
(admin/admin) let anyone in until someone changed it."""
|
|
12
|
+
password = os.environ.get("CODEWATCH_ADMIN_PASSWORD")
|
|
13
|
+
if password:
|
|
14
|
+
return password
|
|
15
|
+
password = secrets.token_urlsafe(16)
|
|
16
|
+
path = settings.CODEWATCH_CACHE / "admin-password.txt"
|
|
17
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
18
|
+
with os.fdopen(os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600), "w") as out:
|
|
19
|
+
out.write(password + "\n")
|
|
20
|
+
print(f"\n Created the administrator account 'admin'; its first password is in {path}")
|
|
21
|
+
return password
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def create_admin(apps, schema_editor):
|
|
25
|
+
User = apps.get_model("auth", "User")
|
|
26
|
+
Profile = apps.get_model("core", "Profile")
|
|
27
|
+
Project = apps.get_model("core", "Project")
|
|
28
|
+
if User.objects.filter(is_superuser=True).exists():
|
|
29
|
+
return
|
|
30
|
+
admin = User.objects.create(
|
|
31
|
+
username="admin", password=make_password(initial_password()), is_superuser=True, is_staff=True, is_active=True
|
|
32
|
+
)
|
|
33
|
+
Profile.objects.create(user=admin, must_change_password=True)
|
|
34
|
+
Project.objects.filter(owner__isnull=True).update(owner=admin)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class Migration(migrations.Migration):
|
|
38
|
+
dependencies = [
|
|
39
|
+
("core", "0002_auth_tokens_a11y"),
|
|
40
|
+
("auth", "0012_alter_user_first_name_max_length"),
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
operations = [migrations.RunPython(create_admin, migrations.RunPython.noop)]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Generated by Django 5.2.18 on 2026-10-28 19:09
|
|
2
|
+
|
|
3
|
+
import django.db.models.deletion
|
|
4
|
+
from django.conf import settings
|
|
5
|
+
from django.db import migrations, models
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Migration(migrations.Migration):
|
|
9
|
+
|
|
10
|
+
dependencies = [
|
|
11
|
+
('core', '0003_default_admin'),
|
|
12
|
+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
operations = [
|
|
16
|
+
migrations.CreateModel(
|
|
17
|
+
name='ProjectMember',
|
|
18
|
+
fields=[
|
|
19
|
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
20
|
+
('role', models.CharField(choices=[('viewer', 'Viewer: see results'), ('contributor', 'Contributor: also scan branches and resolve issues')], default='contributor', max_length=12)),
|
|
21
|
+
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='members', to='core.project')),
|
|
22
|
+
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='memberships', to=settings.AUTH_USER_MODEL)),
|
|
23
|
+
],
|
|
24
|
+
options={
|
|
25
|
+
'constraints': [models.UniqueConstraint(fields=('project', 'user'), name='uniq_member')],
|
|
26
|
+
},
|
|
27
|
+
),
|
|
28
|
+
]
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Generated by Django 5.2.18 on 2026-10-28 19:13
|
|
2
|
+
|
|
3
|
+
import django.db.models.deletion
|
|
4
|
+
from django.conf import settings
|
|
5
|
+
from django.db import migrations, models
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Migration(migrations.Migration):
|
|
9
|
+
|
|
10
|
+
dependencies = [
|
|
11
|
+
('core', '0004_project_members'),
|
|
12
|
+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
operations = [
|
|
16
|
+
migrations.CreateModel(
|
|
17
|
+
name='SourceBlob',
|
|
18
|
+
fields=[
|
|
19
|
+
('sha', models.CharField(max_length=64, primary_key=True, serialize=False)),
|
|
20
|
+
('content', models.TextField()),
|
|
21
|
+
],
|
|
22
|
+
),
|
|
23
|
+
migrations.AddField(
|
|
24
|
+
model_name='analysis',
|
|
25
|
+
name='dirty',
|
|
26
|
+
field=models.BooleanField(default=False, help_text='Scanned from a working copy with uncommitted changes'),
|
|
27
|
+
),
|
|
28
|
+
migrations.AddField(
|
|
29
|
+
model_name='analysis',
|
|
30
|
+
name='origin',
|
|
31
|
+
field=models.CharField(choices=[('server', 'server'), ('client', 'client')], default='server', max_length=10),
|
|
32
|
+
),
|
|
33
|
+
migrations.AddField(
|
|
34
|
+
model_name='analysis',
|
|
35
|
+
name='scanned_by',
|
|
36
|
+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
|
|
37
|
+
),
|
|
38
|
+
migrations.AlterField(
|
|
39
|
+
model_name='project',
|
|
40
|
+
name='repo_url',
|
|
41
|
+
field=models.CharField(blank=True, help_text='Only for server-side scans; leave blank when using codewatch-scan', max_length=500),
|
|
42
|
+
),
|
|
43
|
+
migrations.CreateModel(
|
|
44
|
+
name='AnalysisSource',
|
|
45
|
+
fields=[
|
|
46
|
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
47
|
+
('path', models.CharField(max_length=500)),
|
|
48
|
+
('analysis', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sources', to='core.analysis')),
|
|
49
|
+
('blob', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='core.sourceblob')),
|
|
50
|
+
],
|
|
51
|
+
options={
|
|
52
|
+
'constraints': [models.UniqueConstraint(fields=('analysis', 'path'), name='uniq_source')],
|
|
53
|
+
},
|
|
54
|
+
),
|
|
55
|
+
]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Generated by Django 5.2.18 on 2026-10-28 20:10
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('core', '0005_uploads_and_sources'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AddField(
|
|
14
|
+
model_name='project',
|
|
15
|
+
name='cognitive_complexity_threshold',
|
|
16
|
+
field=models.PositiveIntegerField(default=15, help_text='Cognitive complexity per function (Python)'),
|
|
17
|
+
),
|
|
18
|
+
migrations.AddField(
|
|
19
|
+
model_name='project',
|
|
20
|
+
name='duplicate_literal_threshold',
|
|
21
|
+
field=models.PositiveIntegerField(default=3, help_text='Flag a string literal repeated more than this many times in a file'),
|
|
22
|
+
),
|
|
23
|
+
migrations.AlterField(
|
|
24
|
+
model_name='project',
|
|
25
|
+
name='complexity_threshold',
|
|
26
|
+
field=models.PositiveIntegerField(default=10, help_text='Cyclomatic complexity per function'),
|
|
27
|
+
),
|
|
28
|
+
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Generated by Django 5.2.18 on 2026-10-28 20:11
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('core', '0006_thresholds'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AddField(
|
|
14
|
+
model_name='issue',
|
|
15
|
+
name='also_reported_by',
|
|
16
|
+
field=models.JSONField(blank=True, default=list),
|
|
17
|
+
),
|
|
18
|
+
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Generated by Django 5.2.18 on 2026-10-29 02:48
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('core', '0007_also_reported_by'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AddField(
|
|
14
|
+
model_name='project',
|
|
15
|
+
name='new_code_period',
|
|
16
|
+
field=models.CharField(blank=True, help_text='Blank: since the previous analysis. 30d: since the newest analysis at least 30 days old. Anything else is a tag, branch or commit, e.g. v1.4.', max_length=200, verbose_name='New code on the main branch'),
|
|
17
|
+
),
|
|
18
|
+
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Generated by Django 5.2.18 on 2026-11-18 09:38
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('core', '0008_new_code_period'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterField(
|
|
14
|
+
model_name='issueresolution',
|
|
15
|
+
name='status',
|
|
16
|
+
field=models.CharField(choices=[('wont_fix', "Won't fix"), ('false_positive', 'False positive'), ('safe', 'Safe (reviewed)')], max_length=20),
|
|
17
|
+
),
|
|
18
|
+
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Generated by Django 5.2.18 on 2026-11-19 10:37
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('core', '0009_resolution_safe'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AddField(
|
|
14
|
+
model_name='analysis',
|
|
15
|
+
name='progress',
|
|
16
|
+
field=models.JSONField(blank=True, default=list),
|
|
17
|
+
),
|
|
18
|
+
]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from django.db import migrations
|
|
2
|
+
|
|
3
|
+
# A copy of models.OVERALL_GATE as it was when this migration was written: migrations don't import live code.
|
|
4
|
+
OVERALL_GATE = [("reliability_rating", "gt", 3), ("security_rating", "gt", 3), ("security_review_rating", "gt", 3),
|
|
5
|
+
("maintainability_rating", "gt", 3)]
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def add_overall_conditions(apps, schema_editor):
|
|
9
|
+
"""Existing projects get the overall conditions too, unless they already have one on that metric."""
|
|
10
|
+
project_model = apps.get_model("core", "Project")
|
|
11
|
+
condition_model = apps.get_model("core", "GateCondition")
|
|
12
|
+
for project in project_model.objects.all():
|
|
13
|
+
have = set(condition_model.objects.filter(project=project).values_list("metric", flat=True))
|
|
14
|
+
condition_model.objects.bulk_create(
|
|
15
|
+
condition_model(project=project, metric=m, op=op, threshold=t) for m, op, t in OVERALL_GATE if m not in have)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class Migration(migrations.Migration):
|
|
19
|
+
dependencies = [("core", "0010_analysis_progress")]
|
|
20
|
+
operations = [migrations.RunPython(add_overall_conditions, migrations.RunPython.noop)]
|
|
File without changes
|