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 Mar 20, 2024
1 parent 69265e1 commit 9d3ce80
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 29 deletions.
1 change: 1 addition & 0 deletions agent/test_agent.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the agent."""

import base64
import datetime
import io
Expand Down
1 change: 0 additions & 1 deletion agent/test_python_architecture.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Ensure our version check and architecture check function as desired."""


import sys

import pytest
Expand Down
1 change: 0 additions & 1 deletion analyzer/windows/modules/packages/doc_antivm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class DOC_ANTIVM(Package):

"""Word analysis package, with anti-VM technique prevention."""

PATHS = [
Expand Down
10 changes: 5 additions & 5 deletions lib/cuckoo/common/cape_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,14 @@ def static_config_parsers(cape_name, file_path, file_data):
else:
cape_configraw = cape_malware_parsers[cape_name].config(file_data)
if isinstance(cape_configraw, list):
for (key, value) in cape_configraw[0].items():
for key, value in cape_configraw[0].items():
# python3 map object returns iterator by default, not list and not serializeable in JSON.
if isinstance(value, map):
value = list(value)
cape_config[cape_name].update({key: [value]})
parser_loaded = True
elif isinstance(cape_configraw, dict):
for (key, value) in cape_configraw.items():
for key, value in cape_configraw.items():
# python3 map object returns iterator by default, not list and not serializeable in JSON.
if isinstance(value, map):
value = list(value)
Expand Down Expand Up @@ -269,10 +269,10 @@ def static_config_parsers(cape_name, file_path, file_data):
malwareconfig_config = module.config
# ToDo remove
if isinstance(malwareconfig_config, list):
for (key, value) in malwareconfig_config[0].items():
for key, value in malwareconfig_config[0].items():
cape_config[cape_name].update({key: [value]})
elif isinstance(malwareconfig_config, dict):
for (key, value) in malwareconfig_config.items():
for key, value in malwareconfig_config.items():
cape_config[cape_name].update({key: [value]})
except Exception as e:
if "rules" in str(e):
Expand Down Expand Up @@ -307,7 +307,7 @@ def static_config_parsers(cape_name, file_path, file_data):
tmp_config = ext.config
del ext
if tmp_config:
for (key, value) in tmp_config[0].items():
for key, value in tmp_config[0].items():
cape_config[cape_name].update({key: [value]})

if not cape_config[cape_name]:
Expand Down
24 changes: 12 additions & 12 deletions lib/cuckoo/common/integrations/mitre.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,20 @@ def init_mitre_attck(online: bool = False):
save_config=False,
config_file_path=os.path.join(CUCKOO_ROOT, "data", "mitre", "config.yml"),
data_path=os.path.join(CUCKOO_ROOT, "data", "mitre"),
enterprise_attck_json=config.enterprise_attck_json
if online
else os.path.join(CUCKOO_ROOT, "data", "mitre", "enterprise_attck_json.json"),
enterprise_attck_json=(
config.enterprise_attck_json if online else os.path.join(CUCKOO_ROOT, "data", "mitre", "enterprise_attck_json.json")
),
pre_attck_json=config.pre_attck_json if online else os.path.join(CUCKOO_ROOT, "data", "mitre", "pre_attck_json.json"),
mobile_attck_json=config.mobile_attck_json
if online
else os.path.join(CUCKOO_ROOT, "data", "mitre", "mobile_attck_json.json"),
mobile_attck_json=(
config.mobile_attck_json if online else os.path.join(CUCKOO_ROOT, "data", "mitre", "mobile_attck_json.json")
),
ics_attck_json=config.ics_attck_json if online else os.path.join(CUCKOO_ROOT, "data", "mitre", "ics_attck_json.json"),
nist_controls_json=config.nist_controls_json
if online
else os.path.join(CUCKOO_ROOT, "data", "mitre", "nist_controls_json.json"),
generated_nist_json=config.generated_nist_json
if online
else os.path.join(CUCKOO_ROOT, "data", "mitre", "generated_nist_json.json"),
nist_controls_json=(
config.nist_controls_json if online else os.path.join(CUCKOO_ROOT, "data", "mitre", "nist_controls_json.json")
),
generated_nist_json=(
config.generated_nist_json if online else os.path.join(CUCKOO_ROOT, "data", "mitre", "generated_nist_json.json")
),
)
except Exception as e:
log.error("Can't initialize mitre's Attck class: %s", str(e))
Expand Down
3 changes: 1 addition & 2 deletions lib/cuckoo/common/integrations/vba2graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def vba2graph_from_vba_object(filepath):
log.error(e)
return False
full_vba_code = ""
for (subfilename, stream_path, vba_filename, vba_code) in vba.extract_macros():
for subfilename, stream_path, vba_filename, vba_code in vba.extract_macros():
full_vba_code += "VBA MACRO %s \n" % vba_filename
full_vba_code += "- " * 39 + "\n"
# Temporary workaround. Change when oletools 0.56 will be released.
Expand Down Expand Up @@ -462,7 +462,6 @@ def handle_olevba_input(file_content):


def vba2graph_gen(input_vba_content, output_folder="output", input_file_name="vba2graph", color_scheme=color_scheme):

"""Generage graph from processed vba macros
Args:
input_vba_content (string): data generated by handle_olevba_input
Expand Down
1 change: 1 addition & 0 deletions lib/cuckoo/common/mapTTPs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
except Exception as e:
print("Can't load TTPs.json file", e)


# Read the config file
def mapTTP(oldTTPs: list, mbcs: list):
ttpsList = []
Expand Down
1 change: 0 additions & 1 deletion modules/processing/behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,6 @@ def run(self):


class Anomaly:

"""Anomaly detected during analysis.
For example: a malware tried to remove Cuckoo's hooks.
"""
Expand Down
2 changes: 1 addition & 1 deletion modules/processing/parsers/CAPE/Blister.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def main():
decrypt_memory(file_path)

if dir_path and os.path.isdir(dir_path):
for (dirpath, _, filenames) in os.walk(dir_path):
for dirpath, _, filenames in os.walk(dir_path):
for file in filenames:
decrypt_memory(os.path.join(dirpath, file))

Expand Down
1 change: 1 addition & 0 deletions modules/processing/parsers/CAPE/Hancitor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Hancitor config extractor
"""

import hashlib
import logging
import re
Expand Down
1 change: 1 addition & 0 deletions modules/processing/parsers/CAPE/deprecated/PredatorPain.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def decrypt_string(key, salt, coded):
# except Exception:
# return False


# Get a list of strings from a section
def get_strings(pe, dir_type):
string_list = []
Expand Down
1 change: 1 addition & 0 deletions modules/processing/parsers/CAPE/deprecated/_jRat.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def run(md5, data):

# Helper Functions Go Here


# This extracts the Encryption Key and Config File from the Jar and or Dropper
def get_parts(data):
new_zip = StringIO(data)
Expand Down
1 change: 0 additions & 1 deletion modules/processing/parsers/malduck/test_malduck.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class TEST_MALDUCK(Extractor):

"""
TEST Configuration Extractor
"""
Expand Down
2 changes: 1 addition & 1 deletion modules/reporting/elasticsearchdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def fix_fields(self, report):
self.convert_procdump_strings_to_str(report)

def date_hook(self, json_dict):
for (key, value) in json_dict.items():
for key, value in json_dict.items():
with suppress(Exception):
json_dict[key] = datetime.strptime(value, "%Y-%m-%d %H:%M:%S")
return json_dict
Expand Down
1 change: 0 additions & 1 deletion modules/reporting/maec5.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ def _get_mime_type(cuckoo_type_desc):


class MaecReport(Report):

"""
Generates MAEC 5.0 report.
"""
Expand Down
1 change: 1 addition & 0 deletions utils/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
pending_task_id_map = {}
original_proctitle = getproctitle()


# https://stackoverflow.com/questions/41105733/limit-ram-usage-to-python-program
def memory_limit(percentage: float = 0.8):
if platform.system() != "Linux":
Expand Down
6 changes: 3 additions & 3 deletions web/web/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def process_response(self, request, response):
response["Pragma"] = "no-cache"
response["Cache-Control"] = "no-cache"
response["Expires"] = "0"
response[
"Permissions-Policy"
] = "accelerometer=(); autoplay=(); camera=(); encrypted-media=(); fullscreen=(); geolocation=(); gyroscope=(); magnetometer=(); microphone=(); midi=(); payment=(); picture-in-picture=(); sync-xhr=(); usb=();"
response["Permissions-Policy"] = (
"accelerometer=(); autoplay=(); camera=(); encrypted-media=(); fullscreen=(); geolocation=(); gyroscope=(); magnetometer=(); microphone=(); midi=(); payment=(); picture-in-picture=(); sync-xhr=(); usb=();"
)
return response

0 comments on commit 9d3ce80

Please sign in to comment.