%W&P3 d Z ddlmZ ddlZddlZddlmZmZmZm Z m Z mZ ddlm Z mZ ej e Z G d de ZdS )a WordPress-specific disabled rules data model. This module provides a separate data model for WordPress disabled rules, independent of the existing DisabledRule/DisabledRuleDomain models used by modsec/ossec plugins. Disable Behavior: Global and domain-level disables are independent and can coexist. A rule is considered effectively disabled for a given WordPress domain if EITHER of these conditions is true: - A global disable exists for the rule (applies to all domains) - A domain-specific disable exists for the rule and that domain Enabling a rule at one scope does not affect disables at the other scope. For example, removing a global disable leaves any domain-specific disables intact, and vice versa. )IteratorN) CharField FloatFieldIntegerFieldIntegrityErrorPrimaryKeyFieldfn)Modelinstancec e Zd ZdZ G d d Z e Z ed Z ed Z ed Z ed Z ed Z ed ZdZdZd Zd Ze d$ded ee dz dedededz defd Zedededededef d Zeded ee dedededefd Zededededz dedededefd Zeded ee dz defd Zed$dededz defd Ze d%dededee fd Z ede!e fd Z"edee dz defd Z#e d&d!ed"edee dz dede$eee% f f d# Z&dS )'WPDisabledRulezStores disabled WordPress protection rules. Uses a scope-based design: - scope='global', scope_value=NULL: Rule disabled for all domains (root only) - scope='domain', scope_value='example.com': Rule disabled for specific domain c $ e Zd Zej ZdZdZdS )WPDisabledRule.Metawp_disabled_rules)))rule_idscopescope_valueTN)__name__ __module____qualname__r dbdatabasedb_tableindexes [/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/model/wp_disabled_rule.pyMetar - s ;&@r r F)nullTglobaldomain wordpressagentNr domainssourceuser_id timestampreturnc |t j }|r| ||||| S | |||| S )a> Disable a rule globally or for specific domains. Args: rule_id: The rule identifier (e.g., "CVE-2025-001") domains: List of domains to disable for, or None/empty for global disable source: Origin of the action ("wordpress" or "agent") user_id: UID of the user performing the action (0 for root) timestamp: Unix timestamp for when the rule was disabled. If None, uses current time. Returns: Number of new entries created (0 if all were no-ops). )time_disable_for_domains_disable_globally)clsr r$ r% r&