Skip to content

Commit 6916322

Browse files
committed
Add logging configuration and update .gitignore for log files
1 parent bb8dc76 commit 6916322

5 files changed

Lines changed: 42 additions & 2 deletions

File tree

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ sqlmap_adaptive_partial_report_*
88
sqlmap.cast
99
reports
1010
.eeg-info
11-
sqlmap_ai_audit.log
11+
# Log files
12+
logs/*.log
13+
logs/*.txt
14+
logs/sqlmap_*
15+
# But keep the logs directory structure
16+
!logs/
17+
!logs/.gitkeep
1218
dist/sqlmap_ai-2.0.0.tar.gz
1319
dist/sqlmap_ai-2.0.0-py3-none-any.whl
1420
sqlmap_ai.egg-info/

config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,10 @@ ui:
7777
show_banner: true
7878
verbose_output: false
7979
version: 2.0.0
80+
logging:
81+
log_directory: logs
82+
audit_log_file: sqlmap_ai_audit.log
83+
main_log_file: sqlmap_ai.log
84+
enable_file_logging: true
85+
max_log_size_mb: 50
86+
backup_count: 5

logs/.gitkeep

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This file ensures the logs directory is preserved in git
2+
# Log files in this directory are ignored by .gitignore

sqlmap_ai/config_manager.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ class UIConfig:
8181
progress_indicators: bool = True
8282

8383

84+
@dataclass
85+
class LoggingConfig:
86+
"""Logging configuration"""
87+
log_directory: str = "logs"
88+
audit_log_file: str = "sqlmap_ai_audit.log"
89+
main_log_file: str = "sqlmap_ai.log"
90+
enable_file_logging: bool = True
91+
max_log_size_mb: int = 50
92+
backup_count: int = 5
93+
94+
8495
@dataclass
8596
class AppConfig:
8697
"""Main application configuration"""
@@ -95,6 +106,7 @@ class AppConfig:
95106
sqlmap: SQLMapConfig = field(default_factory=SQLMapConfig)
96107
reporting: ReportingConfig = field(default_factory=ReportingConfig)
97108
ui: UIConfig = field(default_factory=UIConfig)
109+
logging: LoggingConfig = field(default_factory=LoggingConfig)
98110

99111
# Custom settings
100112
custom_settings: Dict[str, Any] = field(default_factory=dict)

sqlmap_ai/security_manager.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,20 @@ def sanitize_filename(self, filename: str) -> str:
246246
class AuditLogger:
247247
"""Comprehensive audit logging system"""
248248

249-
def __init__(self, log_file: str = "sqlmap_ai_audit.log"):
249+
def __init__(self, log_file: str = None, config_manager=None):
250+
if log_file is None:
251+
# Use configuration if available, otherwise default
252+
if config_manager and hasattr(config_manager.config, 'logging'):
253+
logs_dir = Path.cwd() / config_manager.config.logging.log_directory
254+
log_file = logs_dir / config_manager.config.logging.audit_log_file
255+
else:
256+
# Default fallback
257+
logs_dir = Path.cwd() / "logs"
258+
log_file = logs_dir / "sqlmap_ai_audit.log"
259+
260+
# Ensure logs directory exists
261+
logs_dir.mkdir(exist_ok=True)
262+
250263
self.log_file = Path(log_file)
251264
self.logger = logging.getLogger("SQLMapAI_Audit")
252265
self.logger.setLevel(logging.INFO)

0 commit comments

Comments
 (0)