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

# configuration weakness component
CONFIG_STARTING_DETAIL_PATTERN = (r'(?:In |)' + CONFIGURATION_PATTERN + WEAKNESS_BEFORE_STOP_WORDS +
                                  WEAKNESS_PATTERN + COMPONENT_BEFORE_STOP_WORDS + COMPONENT_PATTERN)

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

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

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

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

# configuration weakness component vector
DETAILS_4_3 = CONFIG_STARTING_DETAIL_PATTERN + VECTOR_BEFORE_STOP_WORDS + VECTOR_PATTERN + r'\.$'

# configuration weakness component root_cause
DETAILS_4_4 = CONFIG_STARTING_DETAIL_PATTERN + ROOT_CAUSE_BEFORE_STOP_WORD + ROOT_CAUSE_PATTERN + r'\.'

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


CONFIGURATION_PATTERNS = {
    '6_1': DETAILS_6_1,
    '5_1': DETAILS_5_1,
    '4_1': DETAILS_4_1,
    '4_2': DETAILS_4_2,
    '4_3': DETAILS_4_3,
    '4_4': DETAILS_4_4,
    '3_1': DETAILS_3_1
}
