Repository navigation
Fix ScheduleByWeek without WeeksInterval in CalendarTrigger - #1558
joaocmendonca wants to merge 3 commits into
Conversation
Resolves ValueError('Unknown calendar type') when parsing Windows Task XML
with ScheduleByWeek triggers that omit the WeeksInterval element.
This occurs in real-world exported/UTF-16 task XML files.
The fix:
- Detect ScheduleByWeek directly (not gated on WeeksInterval presence)
- Default weeks_between_triggers to 1 when WeeksInterval is missing
- Safely extract DaysOfWeek children (handle missing elements gracefully)
|
I should have added that this is a fix for #1505. Thx. |
|
Do you have a sample task that could be added as a unit test? Or otherwise can craft one? |
|
@joaocmendonca 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.
|
Here you are @Schamper! I am unable to attach this as a file, so you have it as text. |
|
@DissectBot agree |
Schamper
left a comment
There was a problem hiding this comment.
Could you add this file as a test file and expand the existing unit tests?
Fix ValueError('Unknown calendar type') when parsing Windows Task XML with ScheduleByWeek triggers that omit the WeeksInterval element. This occurs in real-world exported/UTF-16 task XML files
The fix:
Summary
Fix ValueError when parsing Windows Task XML with ScheduleByWeek but no WeeksInterval.
Issue
Parsing task XML files like
windows/system32/tasks/at26(UTF-16, exported) raised:ValueError: Unknown calendar typeThis occurred in CalendarTrigger with ScheduleByWeek that lacks WeeksInterval element (which is not mandatory as per specs, see https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/TaskSchd/taskschedulerschema-weeksinterval-weeklyscheduletype-element.md).
Fix
elif weeks_between_triggers := ...toelif trigger.find("ScheduleByWeek/") is not Noneweeks_between_triggersto 1 when element is missingTesting
Validated with standalone test that reproduces the exact scenario from the issue.
The full test suite can be run:
pytest tests/plugins/os/windows/test_tasks.py -qHTH, Best, Joao