Skip to content
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

Conversation

flavienSindou
Copy link
Contributor

Proposed changes

  • Implement a dedicated error in converter use case
  • Hadle error in application layer to skip invalid conversion

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality using different use cases
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

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

@flavienSindou flavienSindou added bug use for describing something not working as expected filigran team use to identify PR from the Filigran team labels Feb 10, 2025
@flavienSindou flavienSindou added this to the Bugs backlog milestone Feb 10, 2025
@flavienSindou flavienSindou self-assigned this Feb 10, 2025
from stix2.exceptions import InvalidValueError


class ConverterError(Exception):
Copy link
Contributor Author

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":
Copy link
Contributor Author

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
Copy link
Contributor Author

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:
Copy link
Contributor Author

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

Copy link
Member

@helene-nguyen helene-nguyen left a 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!

@flavienSindou flavienSindou merged commit 8cba82e into master Feb 10, 2025
4 checks passed
@flavienSindou flavienSindou deleted the bug/3372-zvelo-connector-stops-working-if-data-is-invalid-or-incorrectly-formatted branch February 10, 2025 16:10
@romain-filigran romain-filigran removed this from the Bugs backlog milestone Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug use for describing something not working as expected filigran team use to identify PR from the Filigran team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Zvelo]: Connector stops working if data is invalid or incorrectly formatted
3 participants