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


WEAKNESS_CONFIG_ATTACKER_PATTERN = (r'(An |A |)' + WEAKNESS_PATTERN + WEAKNESS_AFTER_STOP_WORDS +
                                    CONFIGURATION_BEFORE_STOP_WORDS + CONFIGURATION_PATTERN +
                                    CONFIGURATION_AFTER_STOP_WORDS + ATTACKER_BEFORE_STOP_WORDS + ATTACKER_PATTERN +
                                    ATTACKER_AFTER_STOP_WORDS)

# weakness configuration attacker impact vector component
DETAILS_6_1 = (WEAKNESS_CONFIG_ATTACKER_PATTERN + IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN + VECTOR_BEFORE_STOP_WORDS +
               VECTOR_PATTERN + COMPONENT_BEFORE_STOP_WORDS + COMPONENT_PATTERN + r'\.')

# weakness configuration attacker impact vector root_cause
DETAILS_6_2 = (WEAKNESS_CONFIG_ATTACKER_PATTERN + IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN + VECTOR_BEFORE_STOP_WORDS +
               VECTOR_PATTERN + ROOT_CAUSE_BEFORE_STOP_WORD + ROOT_CAUSE_PATTERN + r'\.$')

# weakness configuration attacker impact vector condition
DETAILS_6_3 = (WEAKNESS_CONFIG_ATTACKER_PATTERN + IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN + VECTOR_BEFORE_STOP_WORDS +
               VECTOR_PATTERN + CONDITION_BEFORE_STOP_WORDS + CONDITION_PATTERN + r'\.$')

# weakness configuration attacker impact vector
DETAILS_5_1 = (WEAKNESS_CONFIG_ATTACKER_PATTERN + IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN + VECTOR_BEFORE_STOP_WORDS +
               VECTOR_PATTERN + r'\.$')

# weakness configuration attacker impact component
DETAILS_5_2 = (WEAKNESS_CONFIG_ATTACKER_PATTERN + IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN +
               COMPONENT_BEFORE_STOP_WORDS + COMPONENT_PATTERN + r'\.$')

# weakness configuration attacker impact root_cause
DETAILS_5_3 = (WEAKNESS_CONFIG_ATTACKER_PATTERN + IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN +
               ROOT_CAUSE_BEFORE_STOP_WORD + ROOT_CAUSE_PATTERN + r'\.$')

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

# weakness configuration attacker impact
DETAILS_4_1 = (WEAKNESS_CONFIG_ATTACKER_PATTERN + IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN + r'\.')

WEAKNESS_CONFIG_ATTACKER_PATTERNS = {
    '6_1': DETAILS_6_1,
    '6_2': DETAILS_6_2,
    '6_3': DETAILS_6_3,
    '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
}
