@@ -18,12 +18,15 @@ The `alert_summary` directory contains the **Slips Evidence Log DAG Generator**,
1818### Key Classes
1919
2020- ** ` EvidenceEvent ` ** - Dataclass representing individual security events with timestamp, IP, threat level, and confidence
21- - ** ` SlipsLogParser ` ** - Core parser class handling multiple log formats and evidence extraction
22- - ** ` SlipsDAGGenerator ` ** - Main orchestrator class managing parsing, filtering, and output generation
21+ - ** ` Alert ` ** - Dataclass representing Slips alerts/analyses with associated evidence events and timewindow metadata
22+ - ** ` SlipsLogParser ` ** - Core parser class handling multiple log formats, evidence extraction, and alert parsing
23+ - ** ` DAGGenerator ` ** - Main DAG generation class supporting both IP-based and analysis-based output modes
2324
2425## Usage Commands
2526
2627### Basic Analysis
28+
29+ #### IP-based Analysis (Default Mode)
2730``` bash
2831# Single IP analysis (default compact format)
2932python3 slips_dag_generator.py sample_logs/test_data.log 192.168.1.113
@@ -35,6 +38,18 @@ python3 slips_dag_generator.py sample_logs/test_data.log --all-ips
3538python3 slips_dag_generator.py sample_logs/test_data.log 192.168.1.113 --output results.txt
3639```
3740
41+ #### Analysis-based Mode (DAG per Alert)
42+ ``` bash
43+ # Generate separate DAG for each alert/analysis
44+ python3 slips_dag_generator.py sample_logs/slips.log --per-analysis --compact
45+
46+ # Per-analysis for specific IP
47+ python3 slips_dag_generator.py sample_logs/slips.log 192.168.1.113 --per-analysis --minimal
48+
49+ # All analyses with threat level information
50+ python3 slips_dag_generator.py sample_logs/slips.log --per-analysis --include-threat-level --minimal
51+ ```
52+
3853### Output Format Options
3954``` bash
4055# Compact format (default) - single line per event
@@ -52,34 +67,51 @@ python3 slips_dag_generator.py sample_logs/test_data.log --all-ips --full
5267
5368### Filtering and Analysis
5469``` bash
55- # Filter by threat level
70+ # Filter by threat level (IP-based mode)
5671python3 slips_dag_generator.py sample_logs/test_data.log --all-ips --min-threat high
5772
58- # Limit number of events
73+ # Limit number of events (IP-based mode)
5974python3 slips_dag_generator.py sample_logs/test_data.log --all-ips --max-events 20
6075
61- # Export as JSON for further processing
76+ # Include threat level information (works with both modes)
77+ python3 slips_dag_generator.py sample_logs/test_data.log --all-ips --include-threat-level
78+
79+ # Export as JSON for further processing (IP-based mode)
6280python3 slips_dag_generator.py sample_logs/test_data.log --all-ips --json
6381
6482# Include summary statistics
6583python3 slips_dag_generator.py sample_logs/test_data.log --all-ips --summary
6684```
6785
6886### Common Workflows
87+
88+ #### IP-based Workflows
6989``` bash
7090# Incident response - quick overview of all threats
7191python3 slips_dag_generator.py sample_logs/slips-evidence.log --all-ips --minimal --min-threat medium
7292
7393# Forensic analysis - detailed single IP investigation
7494python3 slips_dag_generator.py sample_logs/slips.log 192.168.1.113 --full --summary
7595
76- # Threat hunting - pattern analysis across all IPs
77- python3 slips_dag_generator.py sample_logs/slips-5.log --all-ips --pattern
78-
7996# Report generation - structured export
8097python3 slips_dag_generator.py sample_logs/slips.log --all-ips --json --output network_threats.json
8198```
8299
100+ #### Analysis-based Workflows
101+ ``` bash
102+ # Alert investigation - analyze each detection separately
103+ python3 slips_dag_generator.py sample_logs/slips.log --per-analysis --minimal --include-threat-level
104+
105+ # Incident timeline - chronological analysis breakdown
106+ python3 slips_dag_generator.py sample_logs/slips.log --per-analysis --pattern
107+
108+ # Threat hunting - compare evidence patterns across alerts
109+ python3 slips_dag_generator.py sample_logs/slips.log --per-analysis --compact --summary
110+
111+ # Alert-focused reporting
112+ python3 slips_dag_generator.py sample_logs/slips.log --per-analysis --output alert_analysis.txt
113+ ```
114+
83115## Log Format Support
84116
85117The parser handles multiple Slips log formats:
@@ -91,14 +123,16 @@ given the following evidence:
91123- Detected a horizontal port scan to port 80/TCP. 5 unique dst IPs...
92124```
93125
94- ### Grouped Alerts Format
126+ ### Grouped Alerts Format (Supports Per-Analysis Mode)
95127```
961282024/04/05 16:53:07.882348 [evidence.py:1089] [INFO] [IP 10.0.2.15]
97129detected as malicious in timewindow 12
98130given the following evidence:
99131 - Detected Non-SSL connection to 185.29.135.234:443...
100132```
101133
134+ ** Note** : Per-analysis mode (` --per-analysis ` ) is only supported with the grouped alerts format. Use IP-based mode for standard format logs.
135+
102136## Evidence Types Detected
103137
1041381 . ** Port Scans** - Horizontal and vertical scanning activities
@@ -133,21 +167,69 @@ given the following evidence:
133167
134168### Testing
135169``` bash
136- # Quick functionality test
170+ # Quick functionality test (IP-based mode)
137171python3 slips_dag_generator.py sample_logs/test_data.log 192.168.1.113
138172
139- # Test all output formats
173+ # Test all output formats (IP-based mode)
140174python3 slips_dag_generator.py sample_logs/test_data.log --all-ips --compact
141175python3 slips_dag_generator.py sample_logs/test_data.log --all-ips --minimal
142176python3 slips_dag_generator.py sample_logs/test_data.log --all-ips --pattern
143177python3 slips_dag_generator.py sample_logs/test_data.log --all-ips --full
178+
179+ # Test per-analysis mode (requires grouped alerts format)
180+ python3 slips_dag_generator.py sample_logs/slips.log --per-analysis --compact
181+ python3 slips_dag_generator.py sample_logs/slips.log --per-analysis --minimal --include-threat-level
182+ python3 slips_dag_generator.py sample_logs/slips.log --per-analysis --pattern
144183```
145184
146185### Performance
147186- Efficient parsing of large log files
148- - Memory usage scales with events per IP, not total log size
187+ - Memory usage scales with events per IP (IP-based) or events per alert (analysis-based)
149188- Suitable for real-time incident analysis
150189
190+ ## Analysis Modes
191+
192+ ### IP-based Mode (Default)
193+ - ** Use case** : Traditional chronological analysis of all activity for specific IP addresses
194+ - ** Output** : Single DAG per IP showing all evidence events in chronological order
195+ - ** Best for** : Timeline reconstruction, comprehensive IP behavior analysis
196+ - ** Log format support** : Both standard and grouped alerts formats
197+
198+ ### Analysis-based Mode (` --per-analysis ` )
199+ - ** Use case** : Focus on individual Slips alert detections and their specific evidence
200+ - ** Output** : Separate DAG for each alert/analysis with associated evidence grouped by timewindow
201+ - ** Best for** : Alert investigation, incident response, evidence validation
202+ - ** Log format support** : Grouped alerts format only
203+ - ** Key benefits** :
204+ - Preserves alert context and evidence grouping
205+ - Individual risk assessment per analysis
206+ - Clear separation between different detection events
207+ - Easier correlation of evidence to specific alerts
208+
209+ ## Shell Script Integration
210+
211+ ### LLM Analysis Wrapper
212+ ** Location:** ` analyze_slips_with_llm.sh `
213+
214+ Enhanced shell script supporting both analysis modes with LLM integration:
215+
216+ ``` bash
217+ # IP-based analysis with LLM
218+ ./analyze_slips_with_llm.sh sample_logs/slips.log 192.168.1.113 --detailed
219+
220+ # Per-analysis mode with LLM
221+ ./analyze_slips_with_llm.sh sample_logs/slips.log --per-analysis --format minimal
222+
223+ # DAG-only output (no LLM analysis)
224+ ./analyze_slips_with_llm.sh sample_logs/slips.log --per-analysis --dag-only --include-threat-level
225+ ```
226+
227+ ### Script Features
228+ - ** Automatic format detection** : Handles both log formats appropriately
229+ - ** LLM integration** : Feeds DAG output to language models for security analysis
230+ - ** Flexible options** : Supports all DAG generation parameters
231+ - ** Output management** : Structured reporting with both DAG and LLM analysis
232+
151233## Integration
152234
153235The tool integrates with:
@@ -158,4 +240,45 @@ The tool integrates with:
158240
159241## Security Context
160242
161- This is a defensive security tool for analyzing network security evidence. All sample logs are sanitized research data from controlled environments. The tool helps security analysts understand attack patterns and timeline reconstruction from Slips network security analysis output.
243+ This is a defensive security tool for analyzing network security evidence. All sample logs are sanitized research data from controlled environments. The tool helps security analysts understand attack patterns and timeline reconstruction from Slips network security analysis output.
244+
245+ ## Tool for querying other LLMs
246+
247+ ### LLM Query and Benchmarking Script
248+ ** Location:** ` ../benchmark_models/stream_query_llm_long_prompt.py `
249+
250+ A Python tool for benchmarking LLM performance by streaming chat completions and measuring detailed usage metrics.
251+
252+ #### Features
253+ - Streams responses from OpenAI-compatible APIs
254+ - Measures token usage, timing, and tokens-per-second
255+ - Supports loading prompts from files or direct strings
256+ - 20-minute timeout for long operations
257+ - Stats-only mode for quiet benchmarking
258+
259+ #### Usage
260+ ``` bash
261+ # Basic usage with direct prompt
262+ python3 ../benchmark_models/stream_query_llm_long_prompt.py --prompt " Your question here"
263+
264+ # Load prompt from file
265+ python3 ../benchmark_models/stream_query_llm_long_prompt.py --prompt prompt.txt
266+
267+ # Test with OpenAI GPT models
268+ python3 ../benchmark_models/stream_query_llm_long_prompt.py --prompt " What is 2+2?" --model gpt-4o-mini --base_url https://api.openai.com/v1
269+
270+ # Custom Ollama endpoint
271+ python3 ../benchmark_models/stream_query_llm_long_prompt.py --prompt " test" --model llama2 --base_url http://10.147.20.102:11434/v1
272+
273+ # Stats only (no response text)
274+ python3 ../benchmark_models/stream_query_llm_long_prompt.py --prompt " test" --stats_only
275+ ```
276+
277+ #### Requirements
278+ - Python packages: ` openai ` , ` python-dotenv `
279+ - Environment variable: ` OPENAI_API_KEY `
280+ - Default endpoint: ` http://10.147.20.102:11434/v1 ` (Ollama)
281+ - Default model: ` qwen2.5:3b `
282+
283+ #### Tested Performance
284+ - ** GPT-4o-mini** : 21.65 TPS, 0.37s response time for simple queries
0 commit comments