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

Quick updates #1262

Merged
merged 13 commits into from
Oct 17, 2024
23 changes: 12 additions & 11 deletions analyzers/MISPWarningLists/mispwarninglists.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,19 @@ def run(self):
"SELECT list_name, list_version, concat(subdomain, '.', domain, '.', tld) as value FROM warninglists WHERE (subdomain = '%s' or subdomain = '*') and domain = '%s' and tld = '%s'"
% (subdomain, domain, tld)
)
values = self.engine.execute(sql)
with self.engine.connect() as conn:
values = conn.execute(db.text(sql))
if values.rowcount > 0:
for row in values:
results.append(
{
key: value
for (key, value) in zip(
["list_name", "list_version", "value"], row
)
}
)
self.engine.dispose()
if values.rowcount > 0:
for row in values:
results.append(
{
key: value
for (key, value) in zip(
["list_name", "list_version", "value"], row
)
}
)
self.report({"results": results, "mode": "db", "is_uptodate": "N/A"})

def summary(self, raw):
Expand Down
7 changes: 5 additions & 2 deletions analyzers/MISPWarningLists/warninglists_create_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
conn_string = "<insert_postgres_conn_strin>"
warninglists_path = "misp-warninglists/**/list.json"

engine = create_engine(conn_string, use_batch_mode=True)
engine = create_engine(conn_string))
vpiserchia marked this conversation as resolved.
Show resolved Hide resolved
conn = engine.connect()

# UPDATE TLD FROM MOZILLA
Expand Down Expand Up @@ -148,7 +148,10 @@


# CHECK IF OLD RELEASE ARE IN DB
s = select([warninglists.c.list_name, warninglists.c.list_version]).distinct()
try:
s = select([warninglists.c.list_name, warninglists.c.list_version]).distinct()
except sqlalchemy.exc.ArgumentError:
s = select(warninglists.c.list_name, warninglists.c.list_version).distinct()
last_versions = [x for x in conn.execute(s)]
print(f"{len(last_versions)} list already available in db")

Expand Down