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,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