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

# weakness configuration component
WEAKNESS_CONFIG_COMP_PATTERN = (r'(An |A |)' + WEAKNESS_PATTERN + WEAKNESS_AFTER_STOP_WORDS +
                                CONFIGURATION_BEFORE_STOP_WORDS + CONFIGURATION_PATTERN + COMPONENT_BEFORE_STOP_WORDS +
                                COMPONENT_PATTERN)

# weakness configuration component attacker impact root_cause
DETAILS_6_1 = (WEAKNESS_CONFIG_COMP_PATTERN +
               ATTACKER_BEFORE_STOP_WORDS + ATTACKER_PATTERN + ATTACKER_AFTER_STOP_WORDS + IMPACT_BEFORE_STOP_WORDS +
               IMPACT_PATTERN + ROOT_CAUSE_BEFORE_STOP_WORD + ROOT_CAUSE_PATTERN + r'\.$')

# weakness configuration component attacker impact root_cause
DETAILS_6_2 = (WEAKNESS_CONFIG_COMP_PATTERN + ATTACKER_BEFORE_STOP_WORDS + ATTACKER_PATTERN + IMPACT_BEFORE_STOP_WORDS +
               IMPACT_PATTERN + ROOT_CAUSE_BEFORE_STOP_WORD + ROOT_CAUSE_PATTERN + r'\.$')

# weakness configuration component attacker impact condition
DETAILS_6_3 = (WEAKNESS_CONFIG_COMP_PATTERN +
               ATTACKER_BEFORE_STOP_WORDS + ATTACKER_PATTERN + ATTACKER_AFTER_STOP_WORDS + IMPACT_BEFORE_STOP_WORDS +
               IMPACT_PATTERN + CONDITION_BEFORE_STOP_WORDS + CONDITION_PATTERN + r'\.$')

# weakness configuration component attacker impact condition
DETAILS_6_4 = (WEAKNESS_CONFIG_COMP_PATTERN + ATTACKER_BEFORE_STOP_WORDS + ATTACKER_PATTERN + IMPACT_BEFORE_STOP_WORDS +
               IMPACT_PATTERN + CONDITION_BEFORE_STOP_WORDS + CONDITION_PATTERN + r'\.$')

# weakness configuration component attacker impact
DETAILS_5_1 = (WEAKNESS_CONFIG_COMP_PATTERN + ATTACKER_BEFORE_STOP_WORDS + ATTACKER_PATTERN + IMPACT_BEFORE_STOP_WORDS +
               IMPACT_PATTERN + r'\.$')

# weakness configuration component impact
DETAILS_4_1 = WEAKNESS_CONFIG_COMP_PATTERN + IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN + r'\.$'

# weakness configuration component vector
DETAILS_4_2 = WEAKNESS_CONFIG_COMP_PATTERN + VECTOR_BEFORE_STOP_WORDS + VECTOR_PATTERN + r'\.$'

# weakness configuration component condition
DETAILS_4_3 = WEAKNESS_CONFIG_COMP_PATTERN + CONDITION_BEFORE_STOP_WORDS + CONDITION_PATTERN + r'\.$'


WEAKNESS_CONFIG_COMP_PATTERNS = {
    '6_1': DETAILS_6_1,
    '6_2': DETAILS_6_2,
    '6_3': DETAILS_6_3,
    '6_4': DETAILS_6_4,
    '5_1': DETAILS_5_1,
    '4_1': DETAILS_4_1,
    '4_2': DETAILS_4_2,
    '4_3': DETAILS_4_3
}
