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

Allow RegfValue.type to fall back to int #956

Merged
merged 6 commits into from
Nov 27, 2024

Conversation

JSCU-CNI
Copy link
Contributor

This PR fixes edge cases where RegfValue.type cannot be translated to the RegistryValueType enum.

@Horofic
Copy link
Contributor

Horofic commented Nov 21, 2024

Would you mind adding a test case for this behaviour in test_regutil?

Not sure, but should this not return REG_NONE in this case? Took a cursory peek here https://learn.microsoft.com/en-us/windows/win32/sysinfo/registry-value-types.

@Schamper
Copy link
Member

Using _missing_ is probably nicer: https://docs.python.org/3/library/enum.html#enum.Enum._missing_

@JSCU-CNI
Copy link
Contributor Author

This fix is not for catching REG_NONE (which is defined in the enum) but for arbitrary values not defined in winnt.h. Will update this to use _missing_.

@JSCU-CNI
Copy link
Contributor Author

Unfortunately it seems _missing_() is not allowed to return anything not inside the enum: https://stackoverflow.com/a/59951984.

@Schamper
Copy link
Member

You could go the cstruct route and insert new members as needed: https://github.com/fox-it/dissect.cstruct/blob/main/dissect/cstruct/types/enum.py#L183

@JSCU-CNI
Copy link
Contributor Author

JSCU-CNI commented Nov 26, 2024

You could go the cstruct route and insert new members as needed

Added in 308fda1. Perhaps the Enum should be moved to the dissect.regf project?

@Schamper
Copy link
Member

Added in 308fda1. Perhaps the Enum should be moved to the dissect.regf project?

Maybe, I'm fine with it in here for now since this enum serves more as an abstraction layer than a "parsing" enum.

Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
Copy link

codecov bot commented Nov 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.91%. Comparing base (67d34fe) to head (829e591).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #956   +/-   ##
=======================================
  Coverage   77.90%   77.91%           
=======================================
  Files         324      324           
  Lines       27857    27865    +8     
=======================================
+ Hits        21702    21710    +8     
  Misses       6155     6155           
Flag Coverage Δ
unittests 77.91% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Schamper Schamper merged commit f0f0aea into fox-it:main Nov 27, 2024
18 of 20 checks passed
@JSCU-CNI JSCU-CNI deleted the fix/regf-data-type branch November 27, 2024 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants