Skip to content

Commit

Permalink
Merge branch 'parser_feature' of github.com:MISP/misp-stix into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisr3d committed Dec 5, 2024
2 parents cc31d42 + 08a46da commit c89f143
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
UndefinedIndicatorError, UndefinedSTIXObjectError,
UnknownParsingFunctionError, UnknownPatternMappingError,
UnknownPatternTypeError)
from ..importparser import _INDICATOR_TYPING
from ..stix2_pattern_parser import STIX2PatternParser
from .stix2converter import (
ExternalSTIX2Converter, InternalSTIX2Converter, STIX2Converter,
Expand Down Expand Up @@ -371,14 +370,6 @@ def _handle_pattern_mapping(self, indicator: _INDICATOR_TYPING) -> str:
return '_create_stix_pattern_object'
return '_parse_stix_pattern'

# Errors handlin
def _no_converted_content_from_pattern_warning(
self, indicator: _INDICATOR_TYPING):
self.main_parser._add_warning(
"No content extracted from the following Indicator's (id: "
f'{indicator.id}) pattern: {indicator.pattern}'
)

############################################################################
# INDICATORS PARSING METHODS #
############################################################################
Expand Down Expand Up @@ -630,8 +621,8 @@ def _parse_file_and_pe_pattern(
self._no_converted_content_from_pattern_warning(indicator)
self._create_stix_pattern_object(indicator)

def _parse_file_attribute(self, keys: list, values: Union[str, tuple],
indicator_id: str) -> dict:
def _parse_file_attribute(
self, keys: list, values: Union[str, tuple], indicator_id: str):
feature, index = (
('file_hashes', 1) if 'hashes' in keys else ('file_pattern', 0)
)
Expand Down Expand Up @@ -1104,6 +1095,13 @@ def _parse_yara_pattern(self, indicator: _INDICATOR_TYPING):
# ERRORS AND WARNINGS HANDLING METHODS #
############################################################################

def _no_converted_content_from_pattern_warning(
self, indicator: _INDICATOR_TYPING):
self.main_parser._add_warning(
"No content extracted from the following Indicator's (id: "
f'{indicator.id}) pattern: {indicator.pattern}'
)

def _unknown_pattern_mapping_warning(
self, indicator_id: str, pattern_types: GeneratorType):
self.main_parser._add_warning(
Expand Down
7 changes: 0 additions & 7 deletions misp_stix_converter/stix2misp/importparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,10 @@
from stix2.exceptions import InvalidValueError
from stix2.parsing import dict_to_stix2, parse as stix2_parser, ParseError
from stix2.v20.bundle import Bundle as Bundle_v20
from stix2.v20.sdo import Indicator as Indicator_v20
from stix2.v21.bundle import Bundle as Bundle_v21
from stix2.v21.sdo import Indicator as Indicator_v21
from types import GeneratorType
from typing import Optional, Union
from uuid import UUID, uuid5

_INDICATOR_TYPING = Union[
Indicator_v20,
Indicator_v21
]
_DATA_PATH = Path(__file__).parents[1].resolve() / 'data'

MISP_org_uuid = '55f6ea65-aa10-4c5a-bf01-4f84950d210f'
Expand Down

0 comments on commit c89f143

Please sign in to comment.