Skip to content

Commit

Permalink
style: Automatic code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Feb 11, 2025
1 parent 9436fb6 commit 2941a69
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions lib/cuckoo/common/integrations/mandiant_intel.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
api_access = processing_conf.mandiant_intel.api_access
api_secret = processing_conf.mandiant_intel.api_secret


class MandiantAPIClient:
def __init__(self):
self.api_access = api_access
Expand All @@ -43,18 +44,12 @@ def get_new_token(self):
"Authorization": f"Basic {self._generate_auth_header()}",
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json",
"X-App-Name": "get-indicator-infos"
"X-App-Name": "get-indicator-infos",
}
params = {"grant_type": "client_credentials"}

try:
response = requests.post(
url=self.auth_url,
headers=headers,
verify=False,
allow_redirects=False,
data=params
)
response = requests.post(url=self.auth_url, headers=headers, verify=False, allow_redirects=False, data=params)
except Exception as e:
return {"error": True, "msg": f"Error during token request: {e}"}

Expand All @@ -73,7 +68,7 @@ def search(self, indicator):
"Authorization": f"Bearer {self.token}",
"Content-Type": "application/json",
"Accept": "application/json",
"X-App-Name": "get-indicator-infos"
"X-App-Name": "get-indicator-infos",
}

body = {
Expand All @@ -87,11 +82,7 @@ def search(self, indicator):

try:
response = requests.post(
url=self.search_url,
headers=headers,
verify=False,
allow_redirects=False,
data=json.dumps(body)
url=self.search_url, headers=headers, verify=False, allow_redirects=False, data=json.dumps(body)
)
except Exception as e:
return {"error": True, "msg": f"Error during search request: {e}"}
Expand Down Expand Up @@ -121,10 +112,8 @@ def parse_response(self, response):
if "malwares" in obj:
malwares.extend(malware.get("name") for malware in obj["malwares"] if "name" in malware)

return {
"actor": actors,
"malware": malwares
}
return {"actor": actors, "malware": malwares}


def mandiant_lookup(category: str, target: str, results: dict = {}):
if not processing_conf.mandiant_intel.enabled:
Expand Down Expand Up @@ -154,6 +143,7 @@ def mandiant_lookup(category: str, target: str, results: dict = {}):

if __name__ == "__main__":
import sys

indicator = sys.argv[1]

client = MandiantAPIClient()
Expand Down

0 comments on commit 2941a69

Please sign in to comment.