Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 1 addition & 3 deletions gateway/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
from pydantic import BaseModel

# Add modules to path
sys.path.insert(
0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "modules-python"))
)
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "modules-python")))

try:
from ioc_analyzer import IOCAnalyzer
Expand Down
8 changes: 2 additions & 6 deletions gateway/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class Settings(BaseSettings):
redis_url: str = Field(default="redis://redis:6379/0", env="REDIS_URL")

# JWT
jwt_secret: str = Field(
default="change_me_in_production_minimum_32_characters", env="JWT_SECRET"
)
jwt_secret: str = Field(default="change_me_in_production_minimum_32_characters", env="JWT_SECRET")
jwt_algorithm: str = Field(default="HS256", env="JWT_ALGORITHM")
jwt_expiration_minutes: int = Field(default=60, env="JWT_EXPIRATION_MINUTES")

Expand All @@ -31,9 +29,7 @@ class Settings(BaseSettings):
api_workers: int = Field(default=4, env="API_WORKERS")

# CORS
cors_origins: str = Field(
default="http://localhost:3000,http://localhost:8000", env="CORS_ORIGINS"
)
cors_origins: str = Field(default="http://localhost:3000,http://localhost:8000", env="CORS_ORIGINS")

# Rate Limiting
rate_limit_enabled: bool = Field(default=True, env="RATE_LIMIT_ENABLED")
Expand Down
4 changes: 1 addition & 3 deletions modules-python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ def analyze_data():
result = {"anomalies": anomalies, "total_analyzed": len(predictions)}

# Cache result
redis_client.setex(
f"analysis:{data.get('id', 'unknown')}", 3600, json.dumps(result)
)
redis_client.setex(f"analysis:{data.get('id', 'unknown')}", 3600, json.dumps(result))

return jsonify(result), 200
else:
Expand Down
20 changes: 5 additions & 15 deletions tests/test_python_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,12 @@ def test_identify_md5_hash(self):

def test_identify_sha1_hash(self):
"""Test SHA1 hash identification"""
result = self.analyzer.identify_ioc_type(
"da39a3ee5e6b4b0d3255bfef95601890afd80709"
)
result = self.analyzer.identify_ioc_type("da39a3ee5e6b4b0d3255bfef95601890afd80709")
assert result == "sha1"

def test_identify_sha256_hash(self):
"""Test SHA256 hash identification"""
result = self.analyzer.identify_ioc_type(
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
)
result = self.analyzer.identify_ioc_type("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
assert result == "sha256"

def test_identify_unknown(self):
Expand Down Expand Up @@ -133,12 +129,8 @@ def test_aggregate_threats(self):
self.feed.add_feed("feed1", "https://example.com/feed1")
self.feed.add_feed("feed2", "https://example.com/feed2")

self.feed.update_feed(
"feed1", {"threats": [{"ip": "1.2.3.4", "severity": "high"}]}
)
self.feed.update_feed(
"feed2", {"threats": [{"domain": "evil.com", "severity": "medium"}]}
)
self.feed.update_feed("feed1", {"threats": [{"ip": "1.2.3.4", "severity": "high"}]})
self.feed.update_feed("feed2", {"threats": [{"domain": "evil.com", "severity": "medium"}]})

threats = self.feed.aggregate_threats()
assert len(threats) == 2
Expand Down Expand Up @@ -168,9 +160,7 @@ def test_remove_nonexistent_feed(self):
def test_fetch_indicators(self):
"""Test fetching indicators"""
self.feed.add_feed("test_feed", "https://example.com/feed")
self.feed.update_feed(
"test_feed", {"threats": [{"ip": "1.2.3.4", "severity": "high"}]}
)
self.feed.update_feed("test_feed", {"threats": [{"ip": "1.2.3.4", "severity": "high"}]})
indicators = self.feed.fetch_indicators()
assert len(indicators) == 1
assert indicators[0]["ip"] == "1.2.3.4"
Expand Down