Skip to content

Commit 18afad2

Browse files
committed
chore: lint fixes
1 parent 5eef312 commit 18afad2

34 files changed

Lines changed: 350 additions & 273 deletions

backend/application/commons/migrations/0004_settings_background_exploits_import_crontab_hours_and_more.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,11 @@ class Migration(migrations.Migration):
3838
migrations.AddField(
3939
model_name="settings",
4040
name="exploits_last_sync_github_poc",
41-
field=models.DateTimeField(
42-
help_text="Last sync date of GitHub PoC data", null=True
43-
),
41+
field=models.DateTimeField(help_text="Last sync date of GitHub PoC data", null=True),
4442
),
4543
migrations.AddField(
4644
model_name="settings",
4745
name="exploits_last_sync_vulncheck_kev",
48-
field=models.DateTimeField(
49-
help_text="Last sync date of Vulncheck KEV data", null=True
50-
),
46+
field=models.DateTimeField(help_text="Last sync date of Vulncheck KEV data", null=True),
5147
),
5248
]

backend/application/commons/migrations/0016_merge_20250328_1143.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
class Migration(migrations.Migration):
77

88
dependencies = [
9-
('commons', '0013_merge_20241028_1602'),
10-
('commons', '0015_settings_exploit_information_max_age_years_and_more'),
9+
("commons", "0013_merge_20241028_1602"),
10+
("commons", "0015_settings_exploit_information_max_age_years_and_more"),
1111
]
1212

13-
operations = [
14-
]
13+
operations = []

backend/application/commons/models.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,9 @@ class Settings(Model):
166166
feature_disable_user_login = BooleanField(default=False, help_text="Disable user login")
167167
feature_general_rules_need_approval = BooleanField(default=False, help_text="General rules need approval")
168168

169-
exploits_last_sync_vulncheck_kev = DateTimeField(
170-
null=True, help_text="Last sync date of Vulncheck KEV data"
171-
)
169+
exploits_last_sync_vulncheck_kev = DateTimeField(null=True, help_text="Last sync date of Vulncheck KEV data")
172170

173-
exploits_last_sync_github_poc = DateTimeField(
174-
null=True, help_text="Last sync date of GitHub PoC data"
175-
)
171+
exploits_last_sync_github_poc = DateTimeField(null=True, help_text="Last sync date of GitHub PoC data")
176172

177173
background_exploits_import_crontab_minutes = IntegerField(
178174
default=0,

backend/application/core/api/filters.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,13 @@ def get_for_license_components(
188188
)
189189

190190
def filter_branch_name_with_product(
191-
self, queryset, field_name, value
192-
): # pylint: disable=unused-argument
191+
self, queryset: QuerySet, field_name: Any, value: Any
192+
) -> QuerySet: # pylint: disable=unused-argument
193193
# field_name is used as a positional argument
194194

195195
# check if branch or product name matches the search value
196196
return queryset.filter(
197-
Q(name__icontains=value)
198-
| Q(
199-
product_id__in=Product.objects.filter(name__icontains=value).values(
200-
"id"
201-
)
202-
)
197+
Q(name__icontains=value) | Q(product_id__in=Product.objects.filter(name__icontains=value).values("id"))
203198
)
204199

205200
class Meta:

backend/application/core/api/serializers_observation.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def update(self, instance: Observation, validated_data: dict) -> Observation:
380380
status=log_status,
381381
comment="Observation changed manually",
382382
vex_justification=actual_vex_justification,
383-
vex_remediations=actual_vex_remediations,
383+
vex_remediations=str(actual_vex_remediations) if actual_vex_remediations is not None else "",
384384
assessment_status=Assessment_Status.ASSESSMENT_STATUS_AUTO_APPROVED,
385385
risk_acceptance_expiry_date=log_risk_acceptance_expiry_date,
386386
)
@@ -475,7 +475,9 @@ def create(self, validated_data: dict) -> Observation:
475475
status=observation.current_status,
476476
comment="Observation created manually",
477477
vex_justification=observation.current_vex_justification,
478-
vex_remediations=observation.current_vex_remediations,
478+
vex_remediations=(
479+
str(observation.current_vex_remediations) if observation.current_vex_remediations is not None else ""
480+
),
479481
assessment_status=Assessment_Status.ASSESSMENT_STATUS_AUTO_APPROVED,
480482
risk_acceptance_expiry_date=observation.risk_acceptance_expiry_date,
481483
)

backend/application/core/api/views.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ def get_queryset(self) -> QuerySet[Observation]:
500500
.select_related("parser")
501501
)
502502

503-
def filter_queryset(self, queryset):
503+
def filter_queryset(self, queryset: QuerySet) -> QuerySet:
504504
queryset = super().filter_queryset(queryset)
505505

506506
order_by = list(queryset.query.order_by)
@@ -698,23 +698,6 @@ def bulk_approval(self, request: Request) -> Response:
698698
)
699699
return Response(status=HTTP_204_NO_CONTENT)
700700

701-
@extend_schema(
702-
methods=["DELETE"],
703-
request=ObservationLogBulkApprovalSerializer,
704-
responses={HTTP_204_NO_CONTENT: None},
705-
)
706-
@action(detail=False, methods=["delete"])
707-
def bulk_delete(self, request):
708-
request_serializer = ObservationLogBulkDeleteSerializer(data=request.data)
709-
if not request_serializer.is_valid():
710-
raise ValidationError(request_serializer.errors)
711-
712-
Observation_Log.objects.filter(
713-
id__in=request_serializer.validated_data.get("observation_logs"),
714-
user=get_current_user(),
715-
).delete()
716-
return Response(status=HTTP_204_NO_CONTENT)
717-
718701
@extend_schema(
719702
methods=["GET"],
720703
request=None,

backend/application/core/migrations/0042_observation_core_observ_stackab_f65ce5_idx.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ class Migration(migrations.Migration):
1212
operations = [
1313
migrations.AddIndex(
1414
model_name="observation",
15-
index=models.Index(
16-
fields=["stackable_score"], name="core_observ_stackab_f65ce5_idx"
17-
),
15+
index=models.Index(fields=["stackable_score"], name="core_observ_stackab_f65ce5_idx"),
1816
),
1917
]

backend/application/core/migrations/0044_observation_patch_available_and_more.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ class Migration(migrations.Migration):
1616
),
1717
migrations.AddIndex(
1818
model_name="observation",
19-
index=models.Index(
20-
fields=["patch_available"], name="core_observ_patch_a_6e4989_idx"
21-
),
19+
index=models.Index(fields=["patch_available"], name="core_observ_patch_a_6e4989_idx"),
2220
),
2321
]

backend/application/core/migrations/0048_exploit_observation_core_observ_in_vuln_bb4e6d_idx_and_more.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,11 @@ class Migration(migrations.Migration):
4343
),
4444
migrations.AddIndex(
4545
model_name="observation",
46-
index=models.Index(
47-
fields=["in_vulncheck_kev"], name="core_observ_in_vuln_bb4e6d_idx"
48-
),
46+
index=models.Index(fields=["in_vulncheck_kev"], name="core_observ_in_vuln_bb4e6d_idx"),
4947
),
5048
migrations.AddIndex(
5149
model_name="observation",
52-
index=models.Index(
53-
fields=["exploit_available"], name="core_observ_exploit_bc386d_idx"
54-
),
50+
index=models.Index(fields=["exploit_available"], name="core_observ_exploit_bc386d_idx"),
5551
),
5652
migrations.AddIndex(
5753
model_name="exploit",
@@ -62,8 +58,6 @@ class Migration(migrations.Migration):
6258
),
6359
migrations.AddIndex(
6460
model_name="exploit",
65-
index=models.Index(
66-
fields=["-created"], name="core_exploi_created_0f7300_idx"
67-
),
61+
index=models.Index(fields=["-created"], name="core_exploi_created_0f7300_idx"),
6862
),
6963
]

backend/application/core/migrations/0049_observation_exploits_alter_exploit_vulnerability_id.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ class Migration(migrations.Migration):
1313
migrations.AddField(
1414
model_name="observation",
1515
name="exploits",
16-
field=models.ManyToManyField(
17-
blank=True, related_name="observations", to="core.exploit"
18-
),
16+
field=models.ManyToManyField(blank=True, related_name="observations", to="core.exploit"),
1917
),
2018
migrations.AlterField(
2119
model_name="exploit",

0 commit comments

Comments
 (0)