Fix parsing errors in Alarms, Connected Devices, Plist, and NetUsage artifacts #1402
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes several execution errors encountered when processing specific artifacts (Alarms, Connected Devices, System Version Plist, and Network Usage). These changes improve tool stability and prevent crashes due to data parsing issues.
Detailed Changes
1. Alarms Artifact (
appleAlarms.py)ValueError: Invalid isoformat string: '...Z'becausedatetime.fromisoformat()does not support the 'Z' suffix (Zulu time) in certain Python versions.plistlibdate object and explicitly set the timezone to UTC using.replace(tzinfo=timezone.utc).2. Connected Device Information (
ConnectedDeviceInformation.py)sqlite3.DatabaseError: file is not a databasecrashed the tool when processing corrupt or 0-byte SQLite files.try-exceptblock to catchsqlite3.DatabaseErrorandsqlite3.OperationalError. This allows the tool to log the error and skip the invalid file gracefully instead of crashing.3. System Version Plist (
systemVersionPlist.py)TypeErrorcaused by variable shadowing. The variable namesystem_version_plistconflicted with a function/module name, causing Python to treat it as a function instead of a string path.plist_fileto ensure type safety.4. Network Usage (
netusage.py)ValueError: year 0 is out of range. The SQLite database contained timestamps with year 0, which is invalid in Python's Gregorian calendar implementation.try-exceptblock to handle conversion failures. If a timestamp is invalid, it falls back to the raw string value instead of crashing the artifact.