Skip to content

Commit

Permalink
#11 adding a few missing files without logging and removing print sta…
Browse files Browse the repository at this point in the history
…tements back from merge from main.
  • Loading branch information
dario-br committed Oct 16, 2024
1 parent 60c7672 commit 5b34d40
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/sysdiagnose/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import re
import tarfile
import fcntl
from sysdiagnose.utils.base import BaseParserInterface, BaseAnalyserInterface, SysdiagnoseConfig
from sysdiagnose.utils.base import BaseParserInterface, BaseAnalyserInterface, SysdiagnoseConfig, logger


class Sysdiagnose:
Expand Down Expand Up @@ -147,7 +147,7 @@ def create_case(self, sysdiagnose_file: str, force: bool = False, case_id: bool
case['unique_device_id'] = remotectl_dumpstate_json['Local device']['Properties']['UniqueDeviceID']
case['version'] = remotectl_dumpstate_json['Local device']['Properties']['OSVersion']
except (KeyError, TypeError) as e:
print(f"WARNING: Could not parse remotectl_dumpstate, and therefore extract serial numbers. Error {e}")
logger.warning(f"WARNING: Could not parse remotectl_dumpstate, and therefore extract serial numbers.", exc_info=True)

try:
case['date'] = remotectl_dumpstate_parser.sysdiagnose_creation_datetime.isoformat(timespec='microseconds')
Expand Down
4 changes: 2 additions & 2 deletions src/sysdiagnose/analysers/wifi_geolocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import dateutil.parser
import gpxpy
import gpxpy.gpx
from sysdiagnose.utils.base import BaseAnalyserInterface
from sysdiagnose.utils.base import BaseAnalyserInterface, logger
from sysdiagnose.parsers.wifi_known_networks import WifiKnownNetworksParser


Expand Down Expand Up @@ -45,7 +45,7 @@ def generate_gpx_from_known_networks_json(json_data: str, output_file: str):
try:
timestamp = dateutil.parser.parse(timestamp_str)
except Exception as e:
print(f"Error converting timestamp. Reason: {str(e)}. Timestamp was: {str(timestamp_str)}. Assuming Jan 1st 1970.")
logger.exception(f"Error converting timestamp. Timestamp was: {str(timestamp_str)}. Assuming Jan 1st 1970.")
timestamp = dateutil.parser.parse('1970-01-01') # begin of epoch

bssid = network_data.get('__OSSpecific__', {}).get('BSSID', '')
Expand Down
7 changes: 2 additions & 5 deletions src/sysdiagnose/analysers/yarascan.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import glob
import threading
import queue
import logging
from sysdiagnose.utils.base import BaseAnalyserInterface

logger = logging.getLogger('sysdiagnose')
from sysdiagnose.utils.base import BaseAnalyserInterface, logger


# These are the commonly used external variables that can be used in the YARA rules
Expand Down Expand Up @@ -39,7 +36,7 @@ def execute(self):
results = {'errors': [], 'matches': []}

if not os.path.isdir(self.yara_rules_path):
print(f"ERROR: Could not find the YARA rules (.yar) folder: {self.yara_rules_path}")
logger.error(f"ERROR: Could not find the YARA rules (.yar) folder: {self.yara_rules_path}")
results['errors'].append(f"Could not find the YARA rules (.yar) folder: {self.yara_rules_path}")
return results

Expand Down

0 comments on commit 5b34d40

Please sign in to comment.