Fix TypeError when extracting KB from title#1633
Fix TypeError when extracting KB from title#1633EarthGrob wants to merge 4 commits intofox-it:mainfrom
Conversation
|
@EarthGrob changing the regex might lead to unwanted behavior, the old regex checked for any character and zero or more digits and this one removes that and always expects one character to be present |
|
Understood @Paradoxis, will open up a separate issue to address the regex |
|
@EarthGrob thank you for your contribution! As this is your first code contribution, please read the following Contributor License Agreement (CLA). If you agree with the CLA, please reply with the following information:
Contributor License Agreement
Contribution License AgreementThis Contribution License Agreement ("Agreement") governs your Contribution(s) (as defined below) and conveys certain license rights to Fox-IT B.V. ("Fox-IT") for your Contribution(s) to Fox-IT"s open source Dissect project. This Agreement covers any and all Contributions that you ("You" or "Your"), now or in the future, Submit (as defined below) to this project. This Agreement is between Fox-IT B.V. and You and takes effect when you click an “I Accept” button, check box presented with these terms, otherwise accept these terms or, if earlier, when You Submit a Contribution.
|
|
@DissectBot agree |
Co-authored-by: Luke Paris <Paradoxis@users.noreply.github.com>
Co-authored-by: Luke Paris <Paradoxis@users.noreply.github.com>
In some cases the title value in wua_history can be returned as
bytes instead of str. This causes re.search to raise a
TypeError when attempting to extract KB identifiers.
This change ensures the value is decoded to str before applying the
regex, preventing the crash. Fixes #1414.
Additionally, the KB regex was tightened to match valid KB identifiers
(KB\d+) instead of allowing arbitrary characters.
Proposed Changes
• Decode value to str when it is bytes in the title field
• Update regex from (KB.[0-9]*) to (KB\d+)
• Use group(1) to extract the KB identifier
How to test
-p windows.wua_history
• Run: dissect.target
• Ensure no TypeError is raised when processing records
• Verify KB identifiers are still correctly extracted from titles