"""Base class for Pro security rules."""

import re

from apiposture.rules.base import SecurityRule


def _keyword_match(text: str, keyword: str) -> bool:
    """Match keyword at word boundaries (separated by _, /, -, ., or string edges)."""
    return bool(re.search(rf"(?:^|[_/\-.]){re.escape(keyword)}(?:$|[_/\-.])", text))


def _any_keyword_match(text: str, keywords: list[str]) -> bool:
    """Check if any keyword matches at word boundaries."""
    return any(_keyword_match(text, kw) for kw in keywords)


class ProSecurityRule(SecurityRule):
    """
    Base class for Pro-only security rules.

    Pro rules extend the free version's SecurityRule with additional
    capabilities and more sophisticated analysis.
    """

    @property
    def is_pro_rule(self) -> bool:
        """Identify this as a Pro rule."""
        return True
