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,
                     ROOT_CAUSE_BEFORE_STOP_WORD, ROOT_CAUSE_PATTERN)

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

# weakness configuration
WEAKNESS_STARTING_DETAIL_PATTERN_2 = (r'(An |A |)' + WEAKNESS_PATTERN + WEAKNESS_AFTER_STOP_WORDS +
                                      CONFIGURATION_BEFORE_STOP_WORDS + CONFIGURATION_PATTERN)

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

# weakness configuration attacker impact vector component
DETAILS_6_2 = (WEAKNESS_STARTING_DETAIL_PATTERN_2 + ATTACKER_BEFORE_STOP_WORDS + ATTACKER_PATTERN +
               IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN + VECTOR_BEFORE_STOP_WORDS + VECTOR_PATTERN +
               COMPONENT_BEFORE_STOP_WORDS + COMPONENT_PATTERN + r'\.')

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

# weakness configuration attacker impact vector
DETAILS_5_2 = (WEAKNESS_STARTING_DETAIL_PATTERN_2 + ATTACKER_BEFORE_STOP_WORDS + ATTACKER_PATTERN +
               IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN + VECTOR_BEFORE_STOP_WORDS + VECTOR_PATTERN + r'\.')

# weakness configuration attacker impact component
DETAILS_5_3 = (WEAKNESS_STARTING_DETAIL_PATTERN_2 + ATTACKER_BEFORE_STOP_WORDS + ATTACKER_PATTERN +
               IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN + COMPONENT_BEFORE_STOP_WORDS + COMPONENT_PATTERN + r'\.$')

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

# weakness component configuration root_cause
DETAILS_4_2 = WEAKNESS_STARTING_DETAIL_PATTERN_1 + ROOT_CAUSE_BEFORE_STOP_WORD + ROOT_CAUSE_PATTERN + r'\.'

# weakness component configuration impact
DETAILS_4_3 = WEAKNESS_STARTING_DETAIL_PATTERN_1 + IMPACT_BEFORE_STOP_WORDS + IMPACT_PATTERN + r'\.'

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

# weakness configuration vector
DETAILS_3_2 = WEAKNESS_STARTING_DETAIL_PATTERN_2 + VECTOR_BEFORE_STOP_WORDS + VECTOR_PATTERN + r'\.$'


WEAKNESS_PATTERNS = {
    '6_1': DETAILS_6_1,
    '6_2': DETAILS_6_2,
    '5_1': DETAILS_5_1,
    '5_2': DETAILS_5_2,
    '5_3': DETAILS_5_3,
    '4_1': DETAILS_4_1,
    '4_2': DETAILS_4_2,
    '4_3': DETAILS_4_3,
    '3_1': DETAILS_3_1,
    '3_2': DETAILS_3_2
}
