-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into certificate_verification_fix
- Loading branch information
Showing
11 changed files
with
173 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
stix_shifter_modules/crowdstrike/stix_transmission/error_mapper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from stix_shifter_utils.utils.error_mapper_base import ErrorMapperBase | ||
from stix_shifter_utils.utils.error_response import ErrorCode | ||
from stix_shifter_utils.utils import logger | ||
|
||
error_mapping = { | ||
"ConnectionError": ErrorCode.TRANSMISSION_REMOTE_SYSTEM_IS_UNAVAILABLE, | ||
"AuthenticationError": ErrorCode.TRANSMISSION_AUTH_CREDENTIALS, | ||
"ValidationError": ErrorCode.TRANSMISSION_QUERY_LOGICAL_ERROR, | ||
"AttributeError": ErrorCode.TRANSMISSION_INVALID_PARAMETER, | ||
} | ||
|
||
|
||
class ErrorMapper: | ||
""" | ||
Set Error Code | ||
""" | ||
logger = logger.set_logger(__name__) | ||
DEFAULT_ERROR = ErrorCode.TRANSMISSION_MODULE_DEFAULT_ERROR | ||
|
||
@staticmethod | ||
def set_error_code(json_data, return_obj, connector=None): | ||
err_type = None | ||
try: | ||
err_type = json_data['type'] | ||
except KeyError: | ||
pass | ||
|
||
error_type = ErrorMapper.DEFAULT_ERROR | ||
|
||
if err_type in error_mapping: | ||
error_type = error_mapping.get(err_type) | ||
|
||
if error_type == ErrorMapper.DEFAULT_ERROR: | ||
ErrorMapper.logger.error("failed to map: %s", str(json_data)) | ||
|
||
ErrorMapperBase.set_error_code(return_obj, error_type, connector=connector) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.