from ...common import (CONFIGURATION_PATTERN, CONFIGURATION_BEFORE_STOP_WORDS, IMPACT_BEFORE_STOP_WORDS, IMPACT_PATTERN,
                       ROOT_CAUSE_PATTERN, ROOT_CAUSE_BEFORE_STOP_WORD, WEAKNESS_PATTERN, WEAKNESS_AFTER_STOP_WORDS,
                       CONFIGURATION_AFTER_STOP_WORDS, CONDITION_BEFORE_STOP_WORDS, CONDITION_PATTERN,
                       ATTACKER_BEFORE_STOP_WORDS, ATTACKER_PATTERN, VECTOR_BEFORE_STOP_WORDS, VECTOR_PATTERN)


# weakness configuration root_cause
WEAKNESS_CONFIG_CAUSE_PATTERN = (
        r'(An |A |)' + WEAKNESS_PATTERN + WEAKNESS_AFTER_STOP_WORDS +
        CONFIGURATION_BEFORE_STOP_WORDS + CONFIGURATION_PATTERN + CONFIGURATION_AFTER_STOP_WORDS +
        ROOT_CAUSE_BEFORE_STOP_WORD + ROOT_CAUSE_PATTERN
)

# weakness configuration root_cause condition attacker impact
DETAILS_6_1 = (
        WEAKNESS_CONFIG_CAUSE_PATTERN + CONDITION_BEFORE_STOP_WORDS + CONDITION_PATTERN + ATTACKER_BEFORE_STOP_WORDS +
        ATTACKER_PATTERN + IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN + r'\.$'
)

# weakness configuration root_cause attacker impact vector
DETAILS_6_2 = (
        WEAKNESS_CONFIG_CAUSE_PATTERN + ATTACKER_BEFORE_STOP_WORDS + ATTACKER_PATTERN + IMPACT_BEFORE_STOP_WORDS +
        IMPACT_PATTERN + VECTOR_BEFORE_STOP_WORDS + VECTOR_PATTERN + r'\.$'
)

# weakness configuration root_cause impact
DETAILS_4_1 = (
        WEAKNESS_CONFIG_CAUSE_PATTERN + IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN + r'\.$'
)


WEAKNESS_CONFIG_CAUSE_PATTERNS = {
    '6_1': DETAILS_6_1,
    '6_2': DETAILS_6_2,
    '4_1': DETAILS_4_1
}
