Skip to content

Conversation

@bitterpanda63
Copy link
Member

No description provided.

bitterpanda63 and others added 6 commits December 16, 2025 15:35
- Updated AttackWaveDetector to accept Context objects instead of IP strings
- Added sample tracking functionality to collect request samples for metadata
- Updated is_attack_wave to check if context is from a web scanner using is_web_scanner
- Added get_samples_for_ip and clear_samples_for_ip methods to AttackWaveDetector
- Updated AttackWaveDetectorStore to work with context objects
- Updated create_attack_wave_event to include samples in metadata reporting
- Updated request_handler to pass context objects and include samples in events
- Updated all test cases to work with the new context-based approach
- Added comprehensive tests for sample tracking functionality

This implementation follows the pattern from firewall-node's AttackWaveDetector.ts
and includes metadata reporting similar to the onDetectedAttackWave function in Agent.ts
- Run black formatter to ensure consistent code style
- Remove unused json import from create_attack_wave_event.py
- Apply consistent double-quote formatting throughout

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
import json
from aikido_zen.helpers.limit_length_metadata import limit_length_metadata
from aikido_zen.helpers.logging import logger
from aikido_zen.storage.attack_wave_detector_store import attack_wave_detector_store
Copy link

@aikido-pr-checks aikido-pr-checks bot Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Importing and using the module-level singleton 'attack_wave_detector_store' caches request-specific samples globally and can leak data between requests

Details

✨ AI Reasoning
​​1) The added code imports a module-level singleton 'attack_wave_detector_store' and then reads/writes per-request samples from it inside create_attack_wave_event; 2) This introduces a new dependency on a global store that holds request-specific samples across requests, which can leak data between requests or cause race conditions; 3) The issue harms maintainability and safety because request-scoped data is now stored in a shared global object rather than passed through call state, making reasoning about data lifetime and isolation harder.

🔧 How do I fix it?
Avoid storing request-specific data in module-level variables. Use request-scoped variables or explicitly mark shared caches as intentional.

More info - Comment @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.

@bitterpanda63 bitterpanda63 changed the title Attack wave detection: fix bug & report samples Attack wave detection: fix bugs & report samples Dec 16, 2025
@bitterpanda63 bitterpanda63 merged commit 197cdef into main Dec 16, 2025
128 of 129 checks passed
@bitterpanda63 bitterpanda63 deleted the fix-attack-wave-detection branch December 16, 2025 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants