Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/compile_yara_signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def _get_plugin_name(plugin_path):
def _create_compiled_signature_file(directory, tmp_file):
target_path = os.path.join(SIGNATURE_DIR, f'{_get_plugin_name(directory)}.yc') # noqa: PTH118
try:
command = f'yarac -d test_flag=false {tmp_file.name} {target_path}'
subprocess.run(command, stdout=PIPE, stderr=STDOUT, shell=True, check=True)
command = ['yarac', '-d', 'test_flag=false', tmp_file.name, target_path]
subprocess.run(command, stdout=PIPE, stderr=STDOUT, shell=False, check=True) # nosec B603
except CalledProcessError:
print(f'[ERROR] Creation of {os.path.split(target_path)[0]} failed !!') # noqa: T201

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/analysis/file_system_metadata/docker/mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
@contextmanager
def mount(input_file: Path):
try:
check_call(f'mount -o ro,loop {input_file} {MOUNT_DIR}', shell=True)
check_call(['mount', '-o', 'ro,loop', str(input_file), str(MOUNT_DIR)], shell=False) # nosec B603
yield
finally:
check_call(f'umount {MOUNT_DIR}', shell=True)
check_call(['umount', str(MOUNT_DIR)], shell=False) # nosec B603


def main():
Expand Down
12 changes: 7 additions & 5 deletions src/plugins/analysis/qemu_exec/docker/start_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
TIMEOUT_ERROR_EXIT_CODES = [124, 128 + 9]


def get_output_error_and_return_code(command: str) -> tuple[bytes, bytes, int]:
process = subprocess.run(command, capture_output=True, shell=True)
def get_output_error_and_return_code(command: list[str]) -> tuple[bytes, bytes, int]:
process = subprocess.run(command, capture_output=True, shell=False) # nosec B603
return process.stdout, process.stderr, process.returncode


def get_output(command: str) -> dict:
def get_output(command: list[str]) -> dict:
std_out, std_err, return_code = get_output_error_and_return_code(command)
if return_code in TIMEOUT_ERROR_EXIT_CODES:
return {'error': 'timeout'}
Expand All @@ -31,10 +31,12 @@ def encode_as_str(std_out):
def main():
result = {}
for parameter in ['-h', '--help', '-help', '--version', ' ']:
command = f'timeout -s SIGKILL 1 qemu-{ARCH} {FILE_PATH} {parameter}'
command = ['timeout', '-s', 'SIGKILL', '1', f'qemu-{ARCH}', FILE_PATH, parameter.strip()]
if not parameter.strip():
command.pop()
result[parameter] = get_output(command)

command = f'timeout -s SIGKILL 2 qemu-{ARCH} -strace {FILE_PATH}'
command = ['timeout', '-s', 'SIGKILL', '2', f'qemu-{ARCH}', '-strace', FILE_PATH]
result['strace'] = get_output(command)
print(dumps(result), flush=True)

Expand Down