Skip to content

A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.

feat(types): additional website properties + status_code test

dextmorgn1d7e7789e6a8
diff --git a/flowsint-types/src/flowsint_types/website.py b/flowsint-types/src/flowsint_types/website.py
index 52751134..31bfc435 100644
--- a/flowsint-types/src/flowsint_types/website.py
+++ b/flowsint-types/src/flowsint_types/website.py
@@ -1,4 +1,4 @@
-from typing import List, Optional, Self
+from typing import Dict, List, Optional, Self
from pydantic import Field, HttpUrl, model_validator
import re
from .domain import Domain
@@ -11,7 +11,10 @@ class Website(FlowsintType):
"""Represents a website with its URL, domain, and redirect information."""
url: HttpUrl = Field(
- ..., description="Full URL of the website", title="Website URL", json_schema_extra={"primary": True}
+ ...,
+ description="Full URL of the website",
+ title="Website URL",
+ json_schema_extra={"primary": True},
)
redirects: Optional[List[HttpUrl]] = Field(
[], description="List of redirects from the website", title="Redirects"
@@ -22,8 +25,26 @@ class Website(FlowsintType):
active: Optional[bool] = Field(
False, description="Whether the website is active", title="Is Active"
)
+ title: Optional[str] = Field(
+ None, description="Page title from <title> tag", title="Title"
+ )
+ description: Optional[str] = Field(
+ None, description="Meta description of the page", title="Description"
+ )
+ content: Optional[str] = Field(
+ None, description="Text content of the page", title="Content"
+ )
+ status_code: Optional[int] = Field(
+ None, description="HTTP status code", title="Status Code", ge=100, le=599 # Enforce status code
+ )
+ headers: Optional[Dict[str, str]] = Field(
+ None, description="Relevant HTTP headers", title="Headers"
+ )
+ technologies: Optional[List[str]] = Field(
+ [], description="Detected web technologies", title="Technologies"
+ )
- @model_validator(mode='after')
+ @model_validator(mode="after")
def compute_label(self) -> Self:
self.label = str(self.url)
return self
@@ -41,5 +62,5 @@ class Website(FlowsintType):
return False
# URL pattern: must start with http:// or https://
- url_pattern = r'^https?://[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(/.*)?$'
+ url_pattern = r"^https?://[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(/.*)?$"
return bool(re.match(url_pattern, line))
diff --git a/flowsint-types/tests/test_status_code.py b/flowsint-types/tests/test_status_code.py
new file mode 100644
index 00000000..3f39c387
--- /dev/null
+++ b/flowsint-types/tests/test_status_code.py
@@ -0,0 +1,13 @@
+from flowsint_types.website import Website
+import pytest
+
+
+def test_website_valid_status_code():
+ website = Website(url="http://test.com", status_code=200)
+ assert website.status_code == 200
+
+
+def test_website_invalid_status_code():
+ with pytest.raises(Exception) as e_info:
+ Website(url="http://test.com", status_code=600)
+ assert "Input should be less than or equal to" in str(e_info.value)