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,
                       CONDITION_BEFORE_STOP_WORDS, CONDITION_PATTERN, CONFIGURATION_AFTER_STOP_WORDS)

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

# weakness component configuration condition attacker impact vector
DETAILS_7_1 = (WEAKNESS_COMP_CONFIG_PATTERN + CONDITION_BEFORE_STOP_WORDS + CONDITION_PATTERN +
               ATTACKER_BEFORE_STOP_WORDS + ATTACKER_PATTERN + ATTACKER_AFTER_STOP_WORDS + IMPACT_BEFORE_STOP_WORDS +
               IMPACT_PATTERN + VECTOR_BEFORE_STOP_WORDS + VECTOR_PATTERN + r'\.')

# weakness component configuration attacker impact vector
DETAILS_6_1 = (WEAKNESS_COMP_CONFIG_PATTERN + ATTACKER_BEFORE_STOP_WORDS + ATTACKER_PATTERN +
               ATTACKER_AFTER_STOP_WORDS + IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN + VECTOR_BEFORE_STOP_WORDS +
               VECTOR_PATTERN + r'\.')

# weakness component configuration attacker impact root_cause
DETAILS_6_2 = (WEAKNESS_COMP_CONFIG_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 component configuration attacker impact root_cause
DETAILS_6_3 = (WEAKNESS_COMP_CONFIG_PATTERN + ATTACKER_BEFORE_STOP_WORDS + ATTACKER_PATTERN + IMPACT_BEFORE_STOP_WORDS +
               IMPACT_PATTERN + ROOT_CAUSE_BEFORE_STOP_WORD + ROOT_CAUSE_PATTERN + r'\.$')

# weakness component configuration attacker impact condition
DETAILS_6_4 = (WEAKNESS_COMP_CONFIG_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 component configuration attacker impact
DETAILS_5_1 = (WEAKNESS_COMP_CONFIG_PATTERN + ATTACKER_BEFORE_STOP_WORDS + ATTACKER_PATTERN + IMPACT_BEFORE_STOP_WORDS +
               IMPACT_PATTERN + r'\.')

# weakness component configuration root_cause
DETAILS_4_1 = WEAKNESS_COMP_CONFIG_PATTERN + ROOT_CAUSE_BEFORE_STOP_WORD + ROOT_CAUSE_PATTERN + r'\.$'

# weakness component configuration impact
DETAILS_4_2 = WEAKNESS_COMP_CONFIG_PATTERN + IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN + r'\.'

# weakness component configuration
DETAILS_3_1 = WEAKNESS_COMP_CONFIG_PATTERN + r'\.$'

WEAKNESS_COMP_CONFIG_PATTERNS = {
    '7_1': DETAILS_7_1,
    '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,
    '3_1': DETAILS_3_1
}
