from ...common import (CONFIGURATION_PATTERN, ATTACKER_PATTERN, ATTACKER_BEFORE_STOP_WORDS, IMPACT_PATTERN,
                       IMPACT_BEFORE_STOP_WORDS, ROOT_CAUSE_PATTERN, ROOT_CAUSE_BEFORE_STOP_WORD, ATTACK_PATTERN,
                       ATTACK_BEFORE_STOP_WORDS, VECTOR_BEFORE_STOP_WORDS, VECTOR_PATTERN, CONDITION_BEFORE_STOP_WORDS,
                       CONDITION_PATTERN, ATTACKER_AFTER_STOP_WORDS, COMPONENT_BEFORE_STOP_WORDS, COMPONENT_PATTERN,
                       WEAKNESS_BEFORE_STOP_WORDS, WEAKNESS_PATTERN)

# configuration root_cause attacker
CONFIG_CAUSE_ATTACKER_PATTERN = (r'(?:The |)' + CONFIGURATION_PATTERN + ROOT_CAUSE_BEFORE_STOP_WORD +
                                 ROOT_CAUSE_PATTERN + ATTACKER_BEFORE_STOP_WORDS + ATTACKER_PATTERN +
                                 ATTACKER_AFTER_STOP_WORDS)

# configuration root_cause attacker impact condition weakness
DETAILS_6_1 = (CONFIG_CAUSE_ATTACKER_PATTERN + IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN +
               CONDITION_BEFORE_STOP_WORDS + CONDITION_PATTERN + WEAKNESS_BEFORE_STOP_WORDS + WEAKNESS_PATTERN + r'\.$')

# configuration root_cause attacker attack vector
DETAILS_5_1 = (CONFIG_CAUSE_ATTACKER_PATTERN + ATTACK_BEFORE_STOP_WORDS + ATTACK_PATTERN +
               VECTOR_BEFORE_STOP_WORDS + VECTOR_PATTERN + r'\.$')

# configuration root_cause attacker impact vector
DETAILS_5_2 = (CONFIG_CAUSE_ATTACKER_PATTERN + IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN +
               VECTOR_BEFORE_STOP_WORDS + VECTOR_PATTERN + r'\.$')

# configuration root_cause attacker attack condition
DETAILS_5_3 = (CONFIG_CAUSE_ATTACKER_PATTERN + ATTACK_BEFORE_STOP_WORDS + ATTACK_PATTERN +
               CONDITION_BEFORE_STOP_WORDS + CONDITION_PATTERN + r'\.$')

# configuration root_cause attacker impact condition
DETAILS_5_4 = (CONFIG_CAUSE_ATTACKER_PATTERN + IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN +
               CONDITION_BEFORE_STOP_WORDS + CONDITION_PATTERN + r'\.$')

# configuration root_cause attacker attack
DETAILS_4_1 = CONFIG_CAUSE_ATTACKER_PATTERN + ATTACK_BEFORE_STOP_WORDS + ATTACK_PATTERN + r'\.$'

# configuration root_cause attacker impact
DETAILS_4_2 = CONFIG_CAUSE_ATTACKER_PATTERN + IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN + r'\.$'


CONFIG_CAUSE_ATTACKER_PATTERNS = {
    '6_1': DETAILS_6_1,
    '5_1': DETAILS_5_1,
    '5_2': DETAILS_5_2,
    '5_3': DETAILS_5_3,
    '5_4': DETAILS_5_4,
    '4_1': DETAILS_4_1,
    '4_2': DETAILS_4_2
}
