6NF d Z ddlZddlZddlZddlZddlZddlZddlm Z ddl mZ ddlm Z ddlmZ ddlmZ ddlmZmZmZ ej e Z G d d Z G d d ZdS ) z1Collector for WordPress CVE protection incidents. N)Path)defaultdict)WPSite)get_data_dir)IncidentFileParser)upsert_wordpress_incidentbulk_create_wordpress_incidentsbuild_incident_dictc h e Zd ZdZ ddededefdZd Zd ededee ef fd Z d edefdZdS )IncidentRateLimitera Rate limiter to prevent DoS attacks via incident flooding. Implements per-rule-per-IP rate limiting as per spec: - Maximum 100 incidents for each rule from the same IP within 15 minutes Memory-optimized implementation with bounded entry count using LRU eviction. d ' max_incidents_per_rule_per_iptime_window_secondsmax_unique_entriesc || _ || _ || _ t t | _ d| _ t j | _ dS )aI Initialize the rate limiter. Args: max_incidents_per_rule_per_ip: Max incidents per rule per IP (default: 100) time_window_seconds: Time window in seconds (default: 900 = 15 minutes) max_unique_entries: Max unique (rule_id, IP) combinations to track (default: 10000) <