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

Added HTML parsing for content from Threatmatch #2846

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
3 changes: 2 additions & 1 deletion external-import/threatmatch/src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pycti==6.3.11
pycti==6.3.6
beautifulsoup4==4.12.3
11 changes: 10 additions & 1 deletion external-import/threatmatch/src/threatmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import time
from datetime import datetime

import bs4
import requests
import yaml
from pycti import OpenCTIConnectorHelper, get_config_variable
Expand Down Expand Up @@ -101,12 +102,20 @@ def _get_item(self, token, type, item_id):
headers=headers,
)
if r.status_code != 200:
self.helper.log_error(str(r.text))
self.helper.log_error(
f"Could not fetch item: {str(item_id)}, Error: {r.text}"
)
return []
# if 'error' in r.json():
# return []
if r.status_code == 200:
data = r.json()["objects"]
for object in data:
if "description" in object:
object["description"] = bs4.BeautifulSoup(
object["description"], "html.parser"
).get_text()
self.helper.log_info(f"Cleaned data : {object['description']}")
return data

def _process_list(self, work_id, token, type, list):
Expand Down