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

Update otx_alienvault.py #1074

Merged
merged 8 commits into from
May 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading