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

KeyError: 'category' #1

Closed
Alex888-li opened this issue Dec 31, 2021 · 2 comments
Closed

KeyError: 'category' #1

Alex888-li opened this issue Dec 31, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@Alex888-li
Copy link

I have encountered a problem

python3 ADExplorerSnapshot.py tests/data/Server.dat
[*] Server: .com
[
] Time of snapshot:
[
] Mapping offset: 0x2853a5
[
] Object count: 3632
[+] Parsing properties: 1499
[+] Parsing classes: 269
[+] Parsing object offsets: 3632
[+] Restored pre-processed information from data cache
[v] Collecting data: 3169/3632 (0 users, 0 groups, 0 computers, 0 trusts)
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.8/site-packages/dissect/cstruct/types/instance.py", line 16, in getattr
return self._values[attr]
KeyError: 'category'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "ADExplorerSnapshot.py", line 2, in
adexpsnapshot.main()
File "ADExplorerSnapshot.py/adexpsnapshot/init.py", line 603, in main
ADExplorerSnapshot(fh, log)
File "ADExplorerSnapshot.py/adexpsnapshot/init.py", line 92, in init
self.process()
File "ADExplorerSnapshot.py/adexpsnapshot/init.py", line 158, in process
ret = fun(obj)
File "ADExplorerSnapshot.py/adexpsnapshot/init.py", line 364, in processUsers
if not (('user' in entry.classes and 'person' == entry.category) or 'msds-groupmanagedserviceaccount' in entry.classes):
File "ADExplorerSnapshot.py/adexpsnapshot/parser/classes.py", line 59, in getattr
return getattr(self._data, attr)
File "/opt/anaconda3/lib/python3.8/site-packages/dissect/cstruct/types/instance.py", line 18, in getattr
raise AttributeError("Invalid attribute: %r" % attr)
AttributeError: Invalid attribute: 'category'

How do I need to solve this problem?Thanks

@c3c
Copy link
Owner

c3c commented Dec 31, 2021

Thanks for opening an issue report!
I've pushed commit f0c20cc, which hopefully fixes your issue.

This was an interesting error message... while it can access the classes property on the object, it seemingly can't access the category property and then the __getattr__ method gets called as a fallback. Except that the category property does exist. Apparently errors in the property method aren't properly propagated, and fallback happens to __getattr__.
https://groups.google.com/g/comp.lang.python/c/BZf-d0rLP8U

@c3c
Copy link
Owner

c3c commented Jan 2, 2022

Based on local tests, I think this is fixed. Please reopen if you still run into this issue.

@c3c c3c closed this as completed Jan 2, 2022
@c3c c3c added the bug Something isn't working label Jan 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants