Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
phutelmyer committed Oct 23, 2023
1 parent be2513e commit 8860b65
Show file tree
Hide file tree
Showing 21 changed files with 32 additions and 21 deletions.
1 change: 0 additions & 1 deletion src/python/bin/strelka-backend
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Command line utility for running Strelka backend server components.
import argparse

import strelka.config

import strelka.strelka


Expand Down
1 change: 0 additions & 1 deletion src/python/strelka/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from importlib.resources import files

import strelka.config

import strelka.strelka


Expand Down
3 changes: 2 additions & 1 deletion src/python/strelka/auxiliary/xl4ma/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import os
import tempfile
from pathlib import Path

from strelka.auxiliary.xl4ma.extract import iocs
from strelka.auxiliary.xl4ma.xl4decoder import decode
from strelka.auxiliary.xl4ma.xls_wrapper import XLSWrapper
from strelka.auxiliary.xl4ma.xlsb_wrapper import XLSBWrapper
from strelka.auxiliary.xl4ma.xlsm_wrapper import XLSMWrapper
from strelka.auxiliary.xl4ma.xl4decoder import decode


def _make_temp_file(data, file_type):
Expand Down
10 changes: 6 additions & 4 deletions src/python/strelka/auxiliary/xl4ma/xl4decoder.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import tempfile
from os import devnull

import xlrd2
from openpyxl.workbook import Workbook
from pyxlsb2 import open_workbook
from pyxlsb2.formula import Formula
from pyxlsb2.records import ErrorValue
from os import devnull

from strelka.auxiliary.xl4ma.xl4interpreter import Interpreter


Expand Down Expand Up @@ -45,7 +47,7 @@ def _decode_xls(file_path, defined_names):
book_sheet.cell(
row + 1, col + 1, wb[sheet_name].cell(row, col).value
)
except:
except Exception:
pass
temp_file = tempfile.NamedTemporaryFile(suffix=".xlsx", delete=False)
book.save(temp_file.name)
Expand Down Expand Up @@ -94,7 +96,7 @@ def _decode_xlsb(file_path, defined_names):
cell.col + 1,
str(cell.value).rstrip("\x00"),
)
except:
except Exception:
pass
temp_file = tempfile.NamedTemporaryFile(suffix=".xlsx", delete=False)
book.save(temp_file.name)
Expand All @@ -105,7 +107,7 @@ def _decode_xlsb(file_path, defined_names):

# XLSM
def _decode_xlsm(file_path, defined_names):
with tempfile.NamedTemporaryFile(suffix=f".xlsm", delete=False) as temp_file, open(
with tempfile.NamedTemporaryFile(suffix=".xlsm", delete=False) as temp_file, open(
file_path, "rb"
) as fp:
temp_file.write(fp.read())
Expand Down
5 changes: 3 additions & 2 deletions src/python/strelka/auxiliary/xl4ma/xl4interpreter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import logging
import formulas
import os

import formulas


class Interpreter:
def __init__(self, defined_names):
Expand Down Expand Up @@ -157,7 +158,7 @@ def calculate(self, temp_file):
if isinstance(result, str):
self.results.add(str(result))

except Exception as e:
except Exception:
logging.info("formula error")

temp_file.close()
Expand Down
7 changes: 4 additions & 3 deletions src/python/strelka/auxiliary/xl4ma/xls_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import xlrd
import xlrd2
from enum import Enum
from os import devnull

import xlrd
import xlrd2


class VISIBILITY(Enum):
VISIBLE = 0
Expand Down Expand Up @@ -71,7 +72,7 @@ def parse_sheets(self, file_path):
.value,
}
)
except:
except Exception:
pass

results["sheets"].append(
Expand Down
4 changes: 2 additions & 2 deletions src/python/strelka/auxiliary/xl4ma/xlsb_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class XLSBWrapper:
def __init__(self, file_path):
try:
self.workbook = open_workbook(file_path)
except Exception as e:
except Exception:
return

def get_defined_names(self):
Expand Down Expand Up @@ -52,7 +52,7 @@ def parse_sheets(self, file_path):
"value": cell.value,
}
)
except:
except Exception:
pass
results["sheets"].append(
{
Expand Down
1 change: 1 addition & 0 deletions src/python/strelka/auxiliary/xl4ma/xlsm_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re

from openpyxl import load_workbook


Expand Down
4 changes: 2 additions & 2 deletions src/python/strelka/scanners/scan_lnk.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import uuid

from construct import Bytes, IfThenElse, Int16ul, StringEncoded, Struct, this

from strelka import strelka
from strelka.cstructs.lnk import (
CommonNetworkRelativeLink,
ExtraData,
Expand All @@ -9,8 +11,6 @@
ShellLinkHeader,
)

from strelka import strelka


class ScanLNK(strelka.Scanner):
"""Collects metadata from LNK files."""
Expand Down
3 changes: 1 addition & 2 deletions src/python/strelka/scanners/scan_onenote.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import binascii
import re

from strelka.cstructs.onenote import FileDataStoreObject

from strelka import strelka
from strelka.cstructs.onenote import FileDataStoreObject

# This is the binary string we're searching for in the data.
ONE_NOTE_MAGIC = binascii.unhexlify(b"e716e3bd65261145a4c48d4d0b7a9eac")
Expand Down
2 changes: 1 addition & 1 deletion src/python/strelka/scanners/scan_xl4ma.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from strelka.auxiliary.xl4ma import analyzer
from strelka import strelka
from strelka.auxiliary.xl4ma import analyzer


class ScanXl4ma(strelka.Scanner):
Expand Down
3 changes: 2 additions & 1 deletion src/python/strelka/scanners/scan_yara.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import glob
import os

import yara

from strelka import strelka
Expand Down Expand Up @@ -56,7 +57,7 @@ def scan(self, data, file, options, expire_at):
if not self.compiled_yara:
self.load_yara_rules(options)
if not self.compiled_yara:
self.flags.append(f"no_rules_loaded")
self.flags.append("no_rules_loaded")
return

# Set the total rules loaded
Expand Down
1 change: 1 addition & 0 deletions src/python/strelka/tests/test_scan_capa.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from unittest import TestCase, mock

from pytest_unordered import unordered

from strelka.scanners.scan_capa import ScanCapa as ScanUnderTest
from strelka.tests import run_test_scan

Expand Down
1 change: 1 addition & 0 deletions src/python/strelka/tests/test_scan_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from unittest import TestCase, mock

from pytest_unordered import unordered

from strelka.scanners.scan_email import ScanEmail as ScanUnderTest
from strelka.tests import run_test_scan

Expand Down
1 change: 1 addition & 0 deletions src/python/strelka/tests/test_scan_javascript.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from unittest import TestCase, mock

from pytest_unordered import unordered

from strelka.scanners.scan_javascript import ScanJavascript as ScanUnderTest
from strelka.tests import run_test_scan

Expand Down
1 change: 0 additions & 1 deletion src/python/strelka/tests/test_scan_nf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from pathlib import Path
from unittest import TestCase, mock

import pytest
from strelka.scanners.scan_nf import ScanNf as ScanUnderTest
from strelka.tests import run_test_scan

Expand Down
1 change: 1 addition & 0 deletions src/python/strelka/tests/test_scan_pcap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from unittest import TestCase, mock

from pytest_unordered import unordered

from strelka.scanners.scan_pcap import ScanPcap as ScanUnderTest
from strelka.tests import run_test_scan

Expand Down
1 change: 1 addition & 0 deletions src/python/strelka/tests/test_scan_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from unittest import TestCase, mock

from pytest_unordered import unordered

from strelka.scanners.scan_pdf import ScanPdf as ScanUnderTest
from strelka.tests import run_test_scan

Expand Down
1 change: 1 addition & 0 deletions src/python/strelka/tests/test_scan_pe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from unittest import TestCase, mock

from pytest_unordered import unordered

from strelka.scanners.scan_pe import ScanPe as ScanUnderTest
from strelka.tests import run_test_scan

Expand Down
1 change: 1 addition & 0 deletions src/python/strelka/tests/test_scan_transcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from unittest import TestCase, mock

import pytest

from strelka.scanners.scan_transcode import ScanTranscode as ScanUnderTest
from strelka.tests import run_test_scan

Expand Down
1 change: 1 addition & 0 deletions src/python/strelka/tests/test_scan_xl4ma.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from unittest import TestCase, mock

from pytest_unordered import unordered

from strelka.scanners.scan_xl4ma import ScanXl4ma as ScanUnderTest
from strelka.tests import run_test_scan

Expand Down

0 comments on commit 8860b65

Please sign in to comment.