Skip to content

Commit

Permalink
fix: [tests] fix broken tests since last change
Browse files Browse the repository at this point in the history
  • Loading branch information
cvandeplas committed Sep 4, 2024
1 parent 2a69044 commit da048d3
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
8 changes: 8 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@
"args": "-c 1 parse security_sysdiagnose",
"cwd": "${workspaceFolder}/"
},
{
"name": "Python Debugger: parse powerlogs",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/sysdiagnose.py",
"args": "-c 1 parse powerlogs",
"cwd": "${workspaceFolder}/"
},
{
"name": "Python Debugger: parse mobileactivation",
"type": "debugpy",
Expand Down
9 changes: 5 additions & 4 deletions analysers/ps_everywhere.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ def execute(self):

# processes with full path, no parameters, no threads
shutdownlogs_json = ShutdownLogsParser(self.config, self.case_id).get_result()
for section in shutdownlogs_json.values():
for p in shutdownlogs_json:
# not using 'path' but 'command', as the path being appended by the UUID will be counter productive to normalisation
for p in section:
self.add_if_full_command_is_not_in_set(p['command'])
self.add_if_full_command_is_not_in_set(p['command'])
print(f"{len(self.all_ps)} entries after shutdownlogs")

# processes with full path, no parameters, no threads
Expand All @@ -86,7 +85,9 @@ def execute(self):
# on the other hand it may contain valuable stuff, so we use it in 2 formats
# - name::#num_of_threads
# - name::thread name
for p in taskinfo_json['tasks']:
for p in taskinfo_json:
if 'name' not in p:
continue
self.add_if_full_path_is_not_in_set(p['name'])
# add_if_full_path_is_not_in_set(f"{p['name']}::#{len(p['threads'])}") # count is different than in spindumpnosymbols
for t in p['threads']:
Expand Down
4 changes: 3 additions & 1 deletion analysers/ps_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def execute(self):

taskinfo_json = TaskinfoParser(self.config, self.case_id).get_result()
taskinfo_dict = {}
for p in taskinfo_json['tasks']:
for p in taskinfo_json:
if 'pid' not in p:
continue
taskinfo_dict[int(p['pid'])] = {
'PID': p['pid']
}
Expand Down
7 changes: 6 additions & 1 deletion commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ find . -type f -name "*.plist" -exec sh -c 'plutil -p $1 > $1.txt' - {} \;
# Backup the device with libimobile device
To install
To install
````
apt-get install libimobiledevice-dev libimobiledevice-doc libimobiledevice6 libplist-doc ideviceinstaller libimobiledevice-utils python-imobiledevice python-plist libplist-utils
````
Expand Down Expand Up @@ -69,3 +69,8 @@ $find . -type f -name "*.sqlitedb"
# Parsing unified logging:
https://github.com/ydkhatri/UnifiedLogReader
# Count rows in powerlogs
db="filename"
for i in `sqlite3 "$db" "SELECT name FROM sqlite_master WHERE type='table';"`; do a=$(sqlite3 "$db" "SELECT COUNT(*) FROM '$i'"); echo -e "$a\t$i"; done | sort -n > powerlogs_cnt
2 changes: 1 addition & 1 deletion parsers/powerlogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ def execute(self) -> list:
[print(f" {table}") for table in skipped]
return result

def parse_file(path: str) -> dict:
def parse_file_to_json(path: str) -> dict:
return sqlite2json.sqlite2struct(path)
1 change: 0 additions & 1 deletion tests/test_analysers_ps_everywhere.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class TestAnalysersPsEverywhere(SysdiagnoseTestCase):

def test_analyse_ps_everywhere(self):
for case_id, case in self.sd.cases().items():
print(f"Running PsEverywhereAnalyser for {case_id}")
Expand Down

0 comments on commit da048d3

Please sign in to comment.