Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions api_app/playbooks_manager/migrations/0063_rename_dns_playbook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file is a part of IntelOwl https://github.com/intelowlproject/IntelOwl
# See the file 'LICENSE' for copying permission.


from django.db import migrations


def migrate(apps, schema_editor):
PlaybookConfig = apps.get_model("playbooks_manager", "PlaybookConfig")
PlaybookConfig.objects.filter(name="Dns").update(name="DNS")
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This migration does a bulk update(name="DNS") while AbstractConfig.name is globally unique. If a user/org already created a PlaybookConfig named "DNS" (Postgres uniqueness is case-sensitive so it can coexist with "Dns" today), this will raise an IntegrityError and block deployments. Consider making the migration resilient (e.g., detect both records and either merge/delete the duplicate, or skip/rename with a clear strategy) before attempting the rename.

Copilot uses AI. Check for mistakes.


def reverse_migrate(apps, schema_editor):
PlaybookConfig = apps.get_model("playbooks_manager", "PlaybookConfig")
PlaybookConfig.objects.filter(name="DNS").update(name="Dns")
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverse_migrate can also hit the same unique-constraint problem if a "Dns" playbook was (re)created after the forward migration ran. Consider mirroring the forward migration’s conflict-handling logic here as well so downgrades don’t fail unexpectedly.

Copilot uses AI. Check for mistakes.


class Migration(migrations.Migration):
dependencies = [
("playbooks_manager", "0062_add_cleanbrowsing_to_free_to_use"),
]

operations = [
migrations.RunPython(migrate, reverse_migrate),
]
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("test AnalyzableOverview", () => {
data: {
jobs: [
{
playbook: "Dns",
playbook: "DNS",
id: 13,
user: "admin",
date: jobDate,
Expand Down Expand Up @@ -216,7 +216,7 @@ describe("test AnalyzableOverview", () => {
const scannerBadge = container.querySelector("#tag__row0_0");
expect(scannerBadge).toBeInTheDocument();
expect(
screen.getByRole("cell", { name: "Playbook executed: Dns" }),
screen.getByRole("cell", { name: "Playbook executed: DNS" }),
).toBeInTheDocument();
// cell - user event (artifact)
expect(screen.getByRole("cell", { name: "#6" })).toBeInTheDocument();
Expand Down Expand Up @@ -340,7 +340,7 @@ describe("test AnalyzableOverview", () => {
const scannerBadge = container.querySelector("#tag__row0_0");
expect(scannerBadge).toBeInTheDocument();
expect(
screen.getByRole("cell", { name: "Playbook executed: Dns" }),
screen.getByRole("cell", { name: "Playbook executed: DNS" }),
).toBeInTheDocument();
// cell - user event (artifact)
expect(screen.getByRole("cell", { name: "#6" })).toBeInTheDocument();
Expand Down
10 changes: 5 additions & 5 deletions frontend/tests/components/dashboard/charts.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,23 +320,23 @@ describe("test dashboard's charts", () => {
useAxios.mockReturnValue([
{
data: {
values: ["Dns", "FREE_TO_USE_ANALYZERS", "Passive_DNS"],
values: ["DNS", "FREE_TO_USE_ANALYZERS", "Passive_DNS"],
aggregation: [
{
date: "2024-11-28T22:00:00Z",
Dns: 5,
DNS: 5,
FREE_TO_USE_ANALYZERS: 1,
Passive_DNS: 3,
},
{
date: "2024-11-29T22:00:00Z",
Dns: 1,
DNS: 1,
FREE_TO_USE_ANALYZERS: 0,
Passive_DNS: 0,
},
{
date: "2024-11-29T23:00:00Z",
Dns: 1,
DNS: 1,
FREE_TO_USE_ANALYZERS: 0,
Passive_DNS: 0,
},
Expand Down Expand Up @@ -367,7 +367,7 @@ describe("test dashboard's charts", () => {
`${new Date("2024-11-29T23:00:00Z").getDate()}/${new Date("2024-11-29T23:00:00Z").getMonth() + 1}, ${hours}:00`,
),
).toBeInTheDocument();
expect(screen.getByText("Dns")).toBeInTheDocument();
expect(screen.getByText("DNS")).toBeInTheDocument();
expect(screen.getByText("FREE_TO_USE_ANALYZERS")).toBeInTheDocument();
expect(screen.getByText("Passive_DNS")).toBeInTheDocument();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { render, screen, fireEvent } from "@testing-library/react";
import { BrowserRouter } from "react-router-dom";
import { InvestigationFlow } from "../../../../src/components/investigations/flow/InvestigationFlow";

jest.mock("reactflow/dist/style.css", () => {});
jest.mock("reactflow/dist/style.css", () => { });
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor style consistency: the rest of the frontend tests mock this CSS import as () => {} (no space between braces). Keeping the same formatting here avoids unnecessary diffs and potential formatter/linter noise.

Copilot uses AI. Check for mistakes.

describe("test InvestigationFlow", () => {
// mock needed for testing flow https://reactflow.dev/learn/advanced-use/testing#using-jest
Expand Down Expand Up @@ -89,7 +89,7 @@ describe("test InvestigationFlow", () => {
{
pk: 10,
analyzed_object_name: "test1.com",
playbook: "Dns",
playbook: "DNS",
status: "reported_without_fails",
is_sample: false,
children: [],
Expand Down Expand Up @@ -124,15 +124,15 @@ describe("test InvestigationFlow", () => {
{
pk: 10,
analyzed_object_name: "test1.com",
playbook: "Dns",
playbook: "DNS",
status: "reported_without_fails",
is_sample: false,
children: [],
},
{
pk: 20,
analyzed_object_name: "test2.com",
playbook: "Dns",
playbook: "DNS",
status: "reported_without_fails",
is_sample: false,
children: [],
Expand Down Expand Up @@ -172,14 +172,14 @@ describe("test InvestigationFlow", () => {
{
pk: 10,
analyzed_object_name: "test1.com",
playbook: "Dns",
playbook: "DNS",
status: "reported_without_fails",
is_sample: false,
children: [
{
pk: 11,
analyzed_object_name: "test11.com",
playbook: "Dns",
playbook: "DNS",
status: "reported_without_fails",
is_sample: false,
children: [],
Expand Down Expand Up @@ -257,7 +257,7 @@ describe("test InvestigationFlow", () => {
{
pk: 10,
analyzed_object_name: "test1.com",
playbook: "Dns",
playbook: "DNS",
status: "reported_without_fails",
received_request_time: "2024-04-03T13:08:45.417245Z",
is_sample: false,
Expand All @@ -267,7 +267,7 @@ describe("test InvestigationFlow", () => {
{
pk: 11,
analyzed_object_name: "test11.com",
playbook: "Dns",
playbook: "DNS",
status: "reported_without_fails",
children: [],
received_request_time: "2024-04-03T13:09:45.417245Z",
Expand Down Expand Up @@ -340,7 +340,7 @@ describe("test InvestigationFlow", () => {
expect(jobInfo).toBeInTheDocument();
expect(jobInfo.textContent).toContain("Job:#10");
expect(jobInfo.textContent).toContain("Name:test1.com");
expect(jobInfo.textContent).toContain("Playbook:Dns");
expect(jobInfo.textContent).toContain("Playbook:DNS");
expect(jobInfo.textContent).toContain("Created:");

// observable child node
Expand Down Expand Up @@ -381,7 +381,7 @@ describe("test InvestigationFlow", () => {
expect(secondJobInfo).toBeInTheDocument();
expect(secondJobInfo.textContent).toContain("Job:#11");
expect(secondJobInfo.textContent).toContain("Name:test11.com");
expect(secondJobInfo.textContent).toContain("Playbook:Dns");
expect(secondJobInfo.textContent).toContain("Playbook:DNS");
expect(jobInfo.textContent).toContain("Created:");

const fileJobNode = container.querySelector("#job-12");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("test InvestigationOverview", () => {
observable_name: "test10.com",
file_name: "",
is_sample: false,
playbook: "Dns",
playbook: "DNS",
status: "reported_without_fails",
children: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe("test plugins report table", () => {
connectors_requested: ["connector1", "connector2"],
analyzers_to_execute: ["Classic_DNS"],
connectors_to_execute: ["connector1", "connector2"],
visualizers_to_execute: ["IP", "Dns"],
visualizers_to_execute: ["IP", "DNS"],
pivots_to_execute: ["test_pivot"],
}}
pluginReports={[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe("test PlaybookInfoPopoverIcon", () => {
connectors_requested: ["connector1", "connector2"],
analyzers_to_execute: ["Classic_DNS"],
connectors_to_execute: ["connector1", "connector2"],
visualizers_to_execute: ["IP", "Dns"],
visualizers_to_execute: ["IP", "DNS"],
pivots_to_execute: ["test_pivot"],
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ describe("Runtime Configuration Modal test", () => {
connectors: [],
playbook: {
isDisabled: false,
value: "Dns",
value: "DNS",
analyzers: ["TEST_ANALYZER"],
connectors: [],
label: {},
labelDisplay: "Dns",
labelDisplay: "DNS",
tags: [],
tlp: "AMBER",
scan_mode: "2",
Expand Down
2 changes: 1 addition & 1 deletion tests/api_app/analyzable_manager/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def setUp(self):
self.job3.add_child(
user=self.user,
analyzable=self.an,
playbook_to_execute=PlaybookConfig.objects.get(name="Dns"),
playbook_to_execute=PlaybookConfig.objects.get(name="DNS"),
finished_analysis_time=datetime.datetime(2025, 1, 1, tzinfo=datetime.timezone.utc),
tlp=Job.TLP.AMBER.value,
) # check similar investigation works with children
Expand Down
6 changes: 3 additions & 3 deletions tests/api_app/playbooks_manager/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def test_create(self):
def test_get(self):
# 1 - existing visualizer
self.client.force_authenticate(user=self.user)
response = self.client.get(f"{self.URL}/Dns")
response = self.client.get(f"{self.URL}/DNS")
self.assertEqual(response.status_code, 200, response.content)
self.assertEqual(
response.json(),
Expand All @@ -179,7 +179,7 @@ def test_get(self):
"for_organization": False,
"id": 1,
"is_editable": False,
"name": "Dns",
"name": "DNS",
"owner": None,
"pivots": [],
"runtime_configuration": {
Expand Down Expand Up @@ -207,5 +207,5 @@ def test_get(self):
def test_get_config(self):
# 1 - existing playbook
self.client.force_authenticate(user=self.user)
response = self.client.get(f"{self.URL}/Dns/plugin_config")
response = self.client.get(f"{self.URL}/DNS/plugin_config")
self.assertEqual(response.status_code, 404, response.content)
6 changes: 3 additions & 3 deletions tests/api_app/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def test_job_rescan__observable_playbook(self):
status="reported_without_fails",
finished_analysis_time=datetime.datetime(2024, 8, 24, 10, 10, tzinfo=datetime.timezone.utc)
- datetime.timedelta(days=5),
playbook_requested=PlaybookConfig.objects.get(name="Dns"),
playbook_requested=PlaybookConfig.objects.get(name="DNS"),
runtime_configuration={
"analyzers": {"Classic_DNS": {"query_type": "TXT"}},
"connectors": {},
Expand All @@ -534,7 +534,7 @@ def test_job_rescan__observable_playbook(self):
new_job = models.Job.objects.get(pk=new_job_id)
self.assertEqual(new_job.analyzable.name, "test.com")
self.assertEqual(new_job.tlp, "CLEAR")
self.assertEqual(new_job.playbook_requested, PlaybookConfig.objects.get(name="Dns"))
self.assertEqual(new_job.playbook_requested, PlaybookConfig.objects.get(name="DNS"))
self.assertEqual(
new_job.runtime_configuration,
{
Expand Down Expand Up @@ -658,7 +658,7 @@ def test_job_rescan__permission(self):
status="reported_without_fails",
finished_analysis_time=datetime.datetime(2024, 8, 24, 10, 10, tzinfo=datetime.timezone.utc)
- datetime.timedelta(days=5),
playbook_requested=PlaybookConfig.objects.get(name="Dns"),
playbook_requested=PlaybookConfig.objects.get(name="DNS"),
runtime_configuration={
"analyzers": {"Classic_DNS": {"query_type": "TXT"}},
"connectors": {},
Expand Down
12 changes: 6 additions & 6 deletions tests/api_app/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def setUp(self):
**{
"user": self.superuser,
"analyzable": self.analyzable,
"playbook_to_execute": PlaybookConfig.objects.get(name="Dns"),
"playbook_to_execute": PlaybookConfig.objects.get(name="DNS"),
"tlp": Job.TLP.CLEAR.value,
}
)
Expand All @@ -144,7 +144,7 @@ def setUp(self):
**{
"user": self.superuser,
"analyzable": self.analyzable3,
"playbook_to_execute": PlaybookConfig.objects.get(name="Dns"),
"playbook_to_execute": PlaybookConfig.objects.get(name="DNS"),
"tlp": Job.TLP.GREEN.value,
}
)
Expand All @@ -164,7 +164,7 @@ def setUp(self):
self.job2.add_child(
user=self.superuser,
analyzable=self.analyzable,
playbook_to_execute=PlaybookConfig.objects.get(name="Dns"),
playbook_to_execute=PlaybookConfig.objects.get(name="DNS"),
tlp=Job.TLP.AMBER.value,
)

Expand Down Expand Up @@ -404,11 +404,11 @@ def test_agg_top_playbook_200(self):
self.assertEqual(
resp.json(),
{
"values": ["Dns", "FREE_TO_USE_ANALYZERS"],
"values": ["DNS", "FREE_TO_USE_ANALYZERS"],
"aggregation": [
{
"date": "2024-11-28T00:00:00Z",
"Dns": 3,
"DNS": 3,
"FREE_TO_USE_ANALYZERS": 2,
}
],
Expand All @@ -429,7 +429,7 @@ def test_agg_top_user_200(self):
**{
"user": u,
"analyzable": self.analyzable,
"playbook_to_execute": PlaybookConfig.objects.get(name="Dns"),
"playbook_to_execute": PlaybookConfig.objects.get(name="DNS"),
"tlp": Job.TLP.CLEAR.value,
}
)
Expand Down
2 changes: 1 addition & 1 deletion tests/api_app/visualizers_manager/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_get(self):
"disabled": True,
"id": visualizer.id,
"name": "DNS",
"playbooks": ["Dns"],
"playbooks": ["DNS"],
"python_module": visualizer.python_module.id,
},
)
Expand Down
Loading