Skip to content

Commit

Permalink
[urlscan-enrichment] Make indicator creation optional
Browse files Browse the repository at this point in the history
  • Loading branch information
DucNg committed Dec 13, 2024
1 parent 29f9021 commit 106a1e4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
1 change: 1 addition & 0 deletions internal-enrichment/urlscan-enrichment/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ services:
- URLSCAN_ENRICHMENT_VISIBILITY=public # Available values : public, unlisted, private
- URLSCAN_ENRICHMENT_SEARCH_FILTERED_BY_DATE=>now-1y # Available : ">now-1h", ">now-1d", ">now-1y", "[2022 TO 2023]", "[2022/01/01 TO 2023/12/01]"
- URLSCAN_ENRICHMENT_MAX_TLP=TLP:AMBER # Required, Available values: TLP:CLEAR, TLP:WHITE, TLP:GREEN, TLP:AMBER, TLP:AMBER+STRICT, TLP:RED
- URLSCAN_ENRICHMENT_CREATE_INDICATOR=true
restart: always
34 changes: 20 additions & 14 deletions internal-enrichment/urlscan-enrichment/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,26 +197,32 @@ def _generate_stix_bundle(

if data_stat["domains"][0] in stix_entity["value"]:

stix_indicator = (
self.converter.upsert_stix_indicator_with_relationship(
data,
stix_entity,
external_reference,
labels,
prepared_file_png,
if self.config.create_indicator:
stix_indicator = (
self.converter.upsert_stix_indicator_with_relationship(
data,
stix_entity,
external_reference,
labels,
prepared_file_png,
)
)
)
self.stix_objects.extend(stix_indicator)
self.stix_objects.extend(stix_indicator)

for index, ip in enumerate(data_stat["ips"]):
if ip is None:
continue

# Generate Relationship : Indicator -> "based-on" -> obs_ip
indicator_to_ip = self.converter.generate_stix_relationship(
stix_indicator[0].id, "based-on", stix_obs_ip[index].id
)
self.stix_objects.append(indicator_to_ip)
if self.config.create_indicator:
# Generate Relationship : Indicator -> "based-on" -> obs_ip
indicator_to_ip = (
self.converter.generate_stix_relationship(
stix_indicator[0].id,
"based-on",
stix_obs_ip[index].id,
)
)
self.stix_objects.append(indicator_to_ip)

# Generate Relationship : Observable -> "related-to" -> obs_ip
observable_to_ip = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,10 @@ def _initialize_configurations(self) -> None:
self.max_tlp = get_config_variable(
"URLSCAN_ENRICHMENT_MAX_TLP", ["urlscan_enrichment", "max_tlp"], self.load
)

self.create_indicator = get_config_variable(
"URLSCAN_ENRICHMENT_CREATE_INDICATOR",
["urlscan_enrichment", "create_indicator"],
self.load,
default="true",
)

0 comments on commit 106a1e4

Please sign in to comment.