Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve SQLite table exist checks #958

Merged
merged 7 commits into from
Nov 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions dissect/target/plugins/os/windows/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,21 +442,22 @@ def wpndatabase(self) -> Iterator[WpnDatabaseNotificationRecord | WpnDatabaseNot
"""
for user, wpndatabase in self.wpndb_files:
db = sqlite3.SQLite3(wpndatabase.open())

handlers = {}
for row in db.table("NotificationHandler").rows():
handlers[row["[RecordId]"]] = WpnDatabaseNotificationHandlerRecord(
created_time=datetime.datetime.strptime(row["[CreatedTime]"], "%Y-%m-%d %H:%M:%S"),
modified_time=datetime.datetime.strptime(row["[ModifiedTime]"], "%Y-%m-%d %H:%M:%S"),
id=row["[RecordId]"],
primary_id=row["[PrimaryId]"],
wns_id=row["[WNSId]"],
handler_type=row["[HandlerType]"],
wnf_event_name=row["[WNFEventName]"],
system_data_property_set=row["[SystemDataPropertySet]"],
_target=self.target,
_user=user,
)

if "NotificationHandler" in [table.name for table in db.tables()]:
JSCU-CNI marked this conversation as resolved.
Show resolved Hide resolved
for row in db.table("NotificationHandler").rows():
handlers[row["[RecordId]"]] = WpnDatabaseNotificationHandlerRecord(
created_time=datetime.datetime.strptime(row["[CreatedTime]"], "%Y-%m-%d %H:%M:%S"),
modified_time=datetime.datetime.strptime(row["[ModifiedTime]"], "%Y-%m-%d %H:%M:%S"),
id=row["[RecordId]"],
primary_id=row["[PrimaryId]"],
wns_id=row["[WNSId]"],
handler_type=row["[HandlerType]"],
wnf_event_name=row["[WNFEventName]"],
system_data_property_set=row["[SystemDataPropertySet]"],
_target=self.target,
_user=user,
)

for row in db.table("Notification").rows():
record = WpnDatabaseNotificationRecord(
Expand Down