diff --git a/gateway/app.py b/gateway/app.py index 9575781..c8d08cf 100644 --- a/gateway/app.py +++ b/gateway/app.py @@ -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 diff --git a/gateway/config.py b/gateway/config.py index 5b5972f..c3ea5e9 100644 --- a/gateway/config.py +++ b/gateway/config.py @@ -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") @@ -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") diff --git a/modules-python/main.py b/modules-python/main.py index 04a927f..3729e0d 100644 --- a/modules-python/main.py +++ b/modules-python/main.py @@ -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: diff --git a/tests/test_python_modules.py b/tests/test_python_modules.py index 07273ca..3899a9d 100644 --- a/tests/test_python_modules.py +++ b/tests/test_python_modules.py @@ -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): @@ -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 @@ -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"