Skip to content

Commit 8619dfc

Browse files
committed
Fix merge conflict and add migration file
Signed-off-by: ziad hany <ziadhany2016@gmail.com>
1 parent 5e05761 commit 8619dfc

File tree

2 files changed

+71
-4
lines changed

2 files changed

+71
-4
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Generated by Django 4.2.25 on 2025-12-16 12:27
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
("vulnerabilities", "0105_packagecommitpatch_patch_and_more"),
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name="DetectionRule",
16+
fields=[
17+
(
18+
"id",
19+
models.AutoField(
20+
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
21+
),
22+
),
23+
(
24+
"rule_type",
25+
models.CharField(
26+
choices=[
27+
("yara", "Yara"),
28+
("yara-x", "Yara-X"),
29+
("sigma", "Sigma"),
30+
("clamav", "ClamAV"),
31+
("suricata", "Suricata"),
32+
],
33+
help_text="The type of the detection rule content (e.g., YARA, Sigma).",
34+
max_length=50,
35+
),
36+
),
37+
(
38+
"source_url",
39+
models.URLField(
40+
help_text="URL to the original source or reference for this rule.",
41+
max_length=1024,
42+
),
43+
),
44+
(
45+
"rule_metadata",
46+
models.JSONField(
47+
blank=True,
48+
help_text="Additional structured data such as tags, or author information.",
49+
null=True,
50+
),
51+
),
52+
(
53+
"rule_text",
54+
models.TextField(help_text="The content of the detection signature."),
55+
),
56+
(
57+
"advisory",
58+
models.ForeignKey(
59+
blank=True,
60+
null=True,
61+
on_delete=django.db.models.deletion.SET_NULL,
62+
related_name="detection_rules",
63+
to="vulnerabilities.advisoryv2",
64+
),
65+
),
66+
],
67+
),
68+
]

vulnerabilities/tests/pipelines/v2_improvers/test_yara.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from unittest.mock import MagicMock
1212

1313
import pytest
14+
1415
from vulnerabilities.models import DetectionRule
1516
from vulnerabilities.pipelines.v2_improvers.yara_rules import YaraRulesImproverPipeline
1617

@@ -24,10 +25,8 @@ def test_collect_and_store_rules_from_test_repo_dir():
2425
mock_vcs_response.dest_dir = str(TEST_REPO_DIR)
2526

2627
improver = YaraRulesImproverPipeline()
27-
improver.vcs_responses = [
28-
(mock_vcs_response, "https://github.com/mock/repo")
29-
]
28+
improver.vcs_responses = [(mock_vcs_response, "https://github.com/mock/repo")]
3029
improver.collect_and_store_rules()
3130

3231
assert DetectionRule.objects.exists()
33-
assert DetectionRule.objects.count() == 4
32+
assert DetectionRule.objects.count() == 4

0 commit comments

Comments
 (0)