Skip to content

Commit 847754f

Browse files
committed
Fix tests
Signed-off-by: Tushar Goel <[email protected]>
1 parent 54151ad commit 847754f

File tree

7 files changed

+141
-166
lines changed

7 files changed

+141
-166
lines changed

vulnerabilities/forms.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@ class AdvisorySearchForm(forms.Form):
4040

4141
search = forms.CharField(
4242
required=True,
43-
widget=forms.TextInput(
44-
attrs={"placeholder": "Advisory id or alias such as CVE or GHSA"}
45-
),
43+
widget=forms.TextInput(attrs={"placeholder": "Advisory id or alias such as CVE or GHSA"}),
4644
)
4745

46+
4847
class ApiUserCreationForm(forms.ModelForm):
4948
"""
5049
Support a simplified creation for API-only users directly from the UI.

vulnerabilities/migrations/0092_advisoryalias_advisoryreference_advisoryseverity_and_more.py renamed to vulnerabilities/migrations/0093_advisoryalias_advisoryreference_advisoryseverity_and_more.py

Lines changed: 129 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
# Generated by Django 4.2.20 on 2025-05-27 10:43
1+
# Generated by Django 4.2.20 on 2025-05-28 13:31
22

33
from django.db import migrations, models
4+
import django.db.models.deletion
45

56

67
class Migration(migrations.Migration):
78

89
dependencies = [
9-
("vulnerabilities", "0091_alter_advisory_unique_together_and_more"),
10+
("vulnerabilities", "0092_pipelineschedule_pipelinerun"),
1011
]
1112

1213
operations = [
@@ -249,6 +250,16 @@ class Migration(migrations.Migration):
249250
"abstract": False,
250251
},
251252
),
253+
migrations.AlterField(
254+
model_name="pipelineschedule",
255+
name="is_active",
256+
field=models.BooleanField(
257+
db_index=True,
258+
default=True,
259+
help_text="When set to True, this Pipeline is active. When set to False, this Pipeline is inactive and not run.",
260+
null=True,
261+
),
262+
),
252263
migrations.CreateModel(
253264
name="AdvisoryV2",
254265
fields=[
@@ -295,7 +306,7 @@ class Migration(migrations.Migration):
295306
(
296307
"datasource_ID",
297308
models.CharField(
298-
help_text="Fully qualified name of the importer prefixed with themodule name importing the advisory. Eg:vulnerabilities.pipeline.nginx_importer.NginxImporterPipeline",
309+
help_text="Fully qualified name of the importer prefixed with themodule name importing the advisory. Eg:nginx_importer_v2",
299310
max_length=100,
300311
),
301312
),
@@ -346,7 +357,7 @@ class Migration(migrations.Migration):
346357
"fixed_by_packages",
347358
models.ManyToManyField(
348359
help_text="A list of packages that are reported by this advisory.",
349-
related_name="fixing_advisorues",
360+
related_name="fixing_advisories",
350361
to="vulnerabilities.packagev2",
351362
),
352363
),
@@ -379,4 +390,118 @@ class Migration(migrations.Migration):
379390
"ordering": ["date_published", "unique_content_id"],
380391
},
381392
),
393+
migrations.CreateModel(
394+
name="AdvisoryExploit",
395+
fields=[
396+
(
397+
"id",
398+
models.AutoField(
399+
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
400+
),
401+
),
402+
(
403+
"date_added",
404+
models.DateField(
405+
blank=True,
406+
help_text="The date the vulnerability was added to an exploit catalog.",
407+
null=True,
408+
),
409+
),
410+
(
411+
"description",
412+
models.TextField(
413+
blank=True,
414+
help_text="Description of the vulnerability in an exploit catalog, often a refinement of the original CVE description",
415+
null=True,
416+
),
417+
),
418+
(
419+
"required_action",
420+
models.TextField(
421+
blank=True,
422+
help_text="The required action to address the vulnerability, typically to apply vendor updates or apply vendor mitigations or to discontinue use.",
423+
null=True,
424+
),
425+
),
426+
(
427+
"due_date",
428+
models.DateField(
429+
blank=True,
430+
help_text="The date the required action is due, which applies to all USA federal civilian executive branch (FCEB) agencies, but all organizations are strongly encouraged to execute the required action",
431+
null=True,
432+
),
433+
),
434+
(
435+
"notes",
436+
models.TextField(
437+
blank=True,
438+
help_text="Additional notes and resources about the vulnerability, often a URL to vendor instructions.",
439+
null=True,
440+
),
441+
),
442+
(
443+
"known_ransomware_campaign_use",
444+
models.BooleanField(
445+
default=False,
446+
help_text="Known' if this vulnerability is known to have been leveraged as part of a ransomware campaign; \n or 'Unknown' if there is no confirmation that the vulnerability has been utilized for ransomware.",
447+
),
448+
),
449+
(
450+
"source_date_published",
451+
models.DateField(
452+
blank=True,
453+
help_text="The date that the exploit was published or disclosed.",
454+
null=True,
455+
),
456+
),
457+
(
458+
"exploit_type",
459+
models.TextField(
460+
blank=True,
461+
help_text="The type of the exploit as provided by the original upstream data source.",
462+
null=True,
463+
),
464+
),
465+
(
466+
"platform",
467+
models.TextField(
468+
blank=True,
469+
help_text="The platform associated with the exploit as provided by the original upstream data source.",
470+
null=True,
471+
),
472+
),
473+
(
474+
"source_date_updated",
475+
models.DateField(
476+
blank=True,
477+
help_text="The date the exploit was updated in the original upstream data source.",
478+
null=True,
479+
),
480+
),
481+
(
482+
"data_source",
483+
models.TextField(
484+
blank=True,
485+
help_text="The source of the exploit information, such as CISA KEV, exploitdb, metaspoit, or others.",
486+
null=True,
487+
),
488+
),
489+
(
490+
"source_url",
491+
models.URLField(
492+
blank=True,
493+
help_text="The URL to the exploit as provided in the original upstream data source.",
494+
null=True,
495+
),
496+
),
497+
(
498+
"advisory",
499+
models.ForeignKey(
500+
on_delete=django.db.models.deletion.CASCADE,
501+
related_name="exploits",
502+
to="vulnerabilities.advisoryv2",
503+
),
504+
),
505+
],
506+
),
382507
]

vulnerabilities/migrations/0093_alter_advisoryv2_datasource_id_and_more.py

Lines changed: 0 additions & 145 deletions
This file was deleted.

vulnerabilities/models.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,6 @@ def url(self):
13241324

13251325

13261326
class AdvisoryQuerySet(BaseQuerySet):
1327-
13281327
def search(query):
13291328
"""
13301329
This function will take a string as an input, the string could be an alias or an advisory ID or
@@ -2282,6 +2281,8 @@ def create_new_job(self, execute_now=False):
22822281
schedules.clear_job(self.schedule_work_id)
22832282

22842283
return schedules.schedule_execution(self, execute_now) if self.is_active else None
2284+
2285+
22852286
class AdvisorySeverity(models.Model):
22862287
url = models.URLField(
22872288
max_length=1024,
@@ -2556,7 +2557,6 @@ def risk_score(self):
25562557

25572558
objects = AdvisoryQuerySet.as_manager()
25582559

2559-
25602560
class Meta:
25612561
ordering = ["date_published", "unique_content_id"]
25622562

@@ -2593,7 +2593,6 @@ def get_aliases(self):
25932593

25942594

25952595
class PackageQuerySetV2(BaseQuerySet, PackageURLQuerySet):
2596-
25972596
def search(self, query: str = None):
25982597
"""
25992598
Return a Package queryset searching for the ``query``.

vulnerabilities/pipelines/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
from vulnerabilities.importer import UnMergeablePackageError
2929
from vulnerabilities.improver import MAX_CONFIDENCE
3030
from vulnerabilities.models import Advisory
31-
from vulnerabilities.models import PipelineRun
3231
from vulnerabilities.models import PackageV2
32+
from vulnerabilities.models import PipelineRun
3333
from vulnerabilities.pipes.advisory import import_advisory
3434
from vulnerabilities.pipes.advisory import insert_advisory
3535
from vulnerabilities.pipes.advisory import insert_advisory_v2

vulnerabilities/views.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929

3030
from vulnerabilities import models
3131
from vulnerabilities.forms import AdminLoginForm
32-
from vulnerabilities.forms import ApiUserCreationForm
3332
from vulnerabilities.forms import AdvisorySearchForm
33+
from vulnerabilities.forms import ApiUserCreationForm
3434
from vulnerabilities.forms import PackageSearchForm
3535
from vulnerabilities.forms import PipelineSchedulePackageForm
3636
from vulnerabilities.forms import VulnerabilitySearchForm
@@ -100,7 +100,6 @@ def get_queryset(self, query=None):
100100
)
101101

102102

103-
104103
class VulnerabilitySearch(ListView):
105104
model = models.Vulnerability
106105
template_name = "vulnerabilities.html"
@@ -110,7 +109,7 @@ class VulnerabilitySearch(ListView):
110109
def get_context_data(self, **kwargs):
111110
context = super().get_context_data(**kwargs)
112111
request_query = self.request.GET
113-
context["advisory_search_form"] = AdvisorySearchForm(request_query)
112+
context["vulnerability_search_form"] = VulnerabilitySearchForm(request_query)
114113
context["search"] = request_query.get("search")
115114
return context
116115

0 commit comments

Comments
 (0)