-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: [tests] test timeliner analyser
- Loading branch information
1 parent
a746246
commit 0a618d4
Showing
6 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
# Author: [email protected] | ||
|
||
import os | ||
import json | ||
|
||
parser_description = "Parsing WiFi Security logs" | ||
|
||
|
@@ -55,3 +56,10 @@ def parse_path(path: str) -> list | dict: | |
except Exception as e: | ||
print(f"Could not parse: {get_log_files(path)[0]}. Reason: {str(e)}") | ||
return entries | ||
|
||
|
||
def parse_path_to_folder(path: str, output_folder: str) -> bool: | ||
result = parse_path(path) | ||
output_file = os.path.join(output_folder, f"{__name__.split('.')[-1]}.json") | ||
with open(output_file, 'w') as f: | ||
json.dump(result, f, indent=4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from analysers.timeliner import analyse_path | ||
from parsers import accessibility_tcc, logarchive, mobileactivation, powerlogs, swcutil, shutdownlogs, wifisecurity, wifi_known_networks | ||
from tests import SysdiagnoseTestCase | ||
import unittest | ||
import os | ||
import tempfile | ||
|
||
|
||
class TestAnalysersTimeliner(SysdiagnoseTestCase): | ||
|
||
def test_analyse_timeliner(self): | ||
for log_root_path in self.log_root_paths: | ||
|
||
with tempfile.TemporaryDirectory() as tmp_outpath: | ||
# first run the parsers | ||
accessibility_tcc.parse_path_to_folder(log_root_path, output_folder=tmp_outpath) | ||
logarchive.parse_path_to_folder(log_root_path, output_folder=tmp_outpath) | ||
mobileactivation.parse_path_to_folder(log_root_path, output_folder=tmp_outpath) | ||
powerlogs.parse_path_to_folder(log_root_path, output_folder=tmp_outpath) | ||
shutdownlogs.parse_path_to_folder(log_root_path, output_folder=tmp_outpath) | ||
swcutil.parse_path_to_folder(log_root_path, output_folder=tmp_outpath) | ||
wifi_known_networks.parse_path_to_folder(log_root_path, output_folder=tmp_outpath) | ||
wifisecurity.parse_path_to_folder(log_root_path, output_folder=tmp_outpath) | ||
|
||
# then run the analyser | ||
output_file = os.path.join(tmp_outpath, 'timeliner.jsonl') | ||
analyse_path(case_folder=tmp_outpath, output_file=output_file) | ||
self.assertTrue(os.path.isfile(output_file)) | ||
self.assertGreater(os.path.getsize(output_file), 0) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |