-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Zvelo] hot fix: connector stops working if processed data is invalid or incorrectly formatted #3402
[Zvelo] hot fix: connector stops working if processed data is invalid or incorrectly formatted #3402
Conversation
from stix2.exceptions import InvalidValueError | ||
|
||
|
||
class ConverterError(Exception): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Core of the PR
@@ -65,24 +65,25 @@ def _collect_intelligence(self, from_date: str) -> list[stix2.v21._STIXBase21]: | |||
continue | |||
|
|||
# Convert into STIX2 object and add it on a list | |||
if collection == "threat": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refacto and handling of the ConverterError
@@ -119,6 +152,7 @@ def _create_relation( | |||
) | |||
return stix_relationship | |||
|
|||
@known_converter_error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decorator to minimize code changes
def wrapper(self, *args, **kwargs): | ||
try: | ||
return func(self, *args, **kwargs) | ||
except InvalidValueError as error: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only InvalidValueError for now but can be extended later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@flavienSindou Thank you for the hotfix that add changes to catch the error and allow to continue the process!
Proposed changes
Related issues
Checklist
Further comments
A Data Validation error raised while acquiring the data should be preferred to this hot fix directly inside the use case layer.
Notion investigation page: https://www.notion.so/filigran/Zvelo-Connector-stops-working-if-data-is-invalid-or-incorrectly-formatted-1928fce17f2a808fa051edf1224659ee