Skip to content

Commit

Permalink
Update otx_alienvault.py (#1074)
Browse files Browse the repository at this point in the history
Co-authored-by: Thomas Chopitea <[email protected]>
  • Loading branch information
sebdraven and tomchop committed May 22, 2024
1 parent 5ebdc4f commit ca2420d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions plugins/feeds/public/otx_alienvault.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class OTXAlienvault(task.FeedTask):
def run(self):
otx_key = yeti_config.get("otx", "key")
days = yeti_config.get("otx", "days")
data = None
assert otx_key, "OTX key not configured in yeti.conf"

if not days:
Expand All @@ -46,11 +47,13 @@ def run(self):
if self.last_run:
logging.debug("Getting OTX data since %s" % self.last_run)
data = client_otx.getsince(timestamp=self.last_run)

else:
delta_time = datetime.now() - timedelta(days=days)
logging.debug("Getting OTX data since %s" % delta_time)
data = client_otx.getsince(timestamp=delta_time)

if not data:
logging.debug("No data from OTX")
return
df = pd.read_json(
StringIO(json.dumps(data)), orient="values", convert_dates=["created"]
)
Expand All @@ -76,7 +79,6 @@ def analyze(self, item):
continue

context["infos"] = otx_indic["description"]
context["title"] = otx_indic["name"]
context["created"] = datetime.strptime(
otx_indic["created"], "%Y-%m-%dT%H:%M:%S"
)
Expand Down Expand Up @@ -113,8 +115,12 @@ def analyze(self, item):
pattern=otx_indic["content"],
type=indicator.IndicatorType.yara,
diamond=indicator.DiamondModel.capability,
description=t.meta["description"],
).save()
description = f"Threat name: {t.meta.get('threat_name', 'N/A')}"
description += (
f"\n\nDescription: {t.meta.get('description', 'N/A')}"
)
ind_obj.description = description
ind_obj.pattern = otx_indic["content"]
ind_obj.save()
investigation.link_to(ind_obj, "Observed", "OTXAlienVault")
Expand Down

0 comments on commit ca2420d

Please sign in to comment.