Skip to content

Conversation

@Ninoxe
Copy link
Contributor

@Ninoxe Ninoxe commented Dec 12, 2025

WARNING: PR can't work without Reference models (see issue #5405 )

Proposed changes

  • Implement IPv4 enrichment
  • Use connectors_sdk models

Related issues

Checklist

  • I consider the submitted work as finished
  • I have signed my commits using GPG key.
  • 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

@Ninoxe Ninoxe self-assigned this Dec 12, 2025
@Ninoxe Ninoxe added feature use for describing a new feature to develop filigran team use to identify PR from the Filigran team connector: kaspersky-enrichment labels Dec 12, 2025
@Ninoxe Ninoxe linked an issue Dec 12, 2025 that may be closed by this pull request
@Ninoxe Ninoxe marked this pull request as ready for review December 15, 2025 16:32
Copy link
Member

@mariot mariot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, it works very well :)
Just a few things before merging: the new objects lack an author and markings.

Image

You should send an Identity and Marking-Definition objects in the bundle and link them to each object.

You should also send back the original bundle even if there is an exception during the enrichment.

You can ignore the code suggestions if you don't have the time.

Comment on lines +46 to +48
if last_seen == first_seen:
return True
return False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if last_seen == first_seen:
return True
return False
return last_seen == first_seen

self.helper.connector_logger.info("[CONNECTOR] Starting enrichment...")

# Retrieve ipv4
obs_ipv4 = observable["value"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use observable_to_ref.id for the type checker?

Comment on lines +8 to +10
if entity_info["DayRequests"] >= entity_info["DayQuota"]:
return True
return False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if entity_info["DayRequests"] >= entity_info["DayQuota"]:
return True
return False
return entity_info["DayRequests"] >= entity_info["DayQuota"]

from datetime import datetime, timezone


def check_quota(entity_info: dict) -> bool:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using names like is_quota_exceeded or something

Comment on lines +23 to +26
if entity_type in scopes:
return True
else:
return False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if entity_type in scopes:
return True
else:
return False
return entity_type in scopes

Comment on lines +29 to +38
def resolve_file_hash(observable: dict) -> str:
if "hashes" in observable and "SHA-256" in observable["hashes"]:
return observable["hashes"]["SHA-256"]
if "hashes" in observable and "SHA-1" in observable["hashes"]:
return observable["hashes"]["SHA-1"]
if "hashes" in observable and "MD5" in observable["hashes"]:
return observable["hashes"]["MD5"]
raise ValueError(
"Unable to enrich the observable, the observable does not have an SHA256, SHA1, or MD5"
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def resolve_file_hash(observable: dict) -> str:
if "hashes" in observable and "SHA-256" in observable["hashes"]:
return observable["hashes"]["SHA-256"]
if "hashes" in observable and "SHA-1" in observable["hashes"]:
return observable["hashes"]["SHA-1"]
if "hashes" in observable and "MD5" in observable["hashes"]:
return observable["hashes"]["MD5"]
raise ValueError(
"Unable to enrich the observable, the observable does not have an SHA256, SHA1, or MD5"
)
def resolve_file_hash(observable: dict) -> str:
hashes = observable.get("hashes", {})
for key in ("SHA-256", "SHA-1", "MD5"):
if key in hashes:
return hashes[key]
raise ValueError(
"Unable to enrich the observable, the observable does not have an SHA256, SHA1, or MD5"
)

return False


def resolve_file_hash(observable: dict) -> str:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider sending directly hashes instead of observable

Comment on lines +65 to +67
OpenCTIStix2.put_attribute_in_extension(
observable, STIX_EXT_OCTI_SCO, "score", score
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

observable variable is changed by the method, yes; but it would be more readable if you caught the returned object like

Suggested change
OpenCTIStix2.put_attribute_in_extension(
observable, STIX_EXT_OCTI_SCO, "score", score
)
observable = OpenCTIStix2.put_attribute_in_extension(
observable, STIX_EXT_OCTI_SCO, "score", score
)

entity_general_info["CountryCode"]
)

if obs_country:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obs_country is never None, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

connector: kaspersky-enrichment feature use for describing a new feature to develop filigran team use to identify PR from the Filigran team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[kaspersky-enrichment] Add IPV4 enrichment

3 participants