Closed kedith closed 2 years ago
good catch. I updated the regex and put it on regex101. @kedith before I'm opening a PR for this fix, can you help me verify the new (regex) pattern by testing some valid & invalid cron examples? I want to verify it's not producing false positive/negative results.
thanks @eyarz. I will try to test it with some values too.
* 00 * * *
should be accepted by the regex as well.
oops...
@kedith I fixed the regex and also added validation for * * * * 00
, so please give it another try now.
If you are wondering why I missed all those 00
expressions is because it was not provided as an allowed value in the CRON expression definition 😅
@eyarz I tested it with more values. It seems to pass on all my examples but I found some corner cases where it shouldn't pass but passes. I thought of testing ranges where the starting value is still valid but the upper range not, ex:
* * * 12-14 *
, * * * * 5,8
I found this website useful while thinking of valid/invalid patterns https://crontab.guru/
Thanks a lot for your fast responses and help 🙂
@kedith you are right, the regex didn't validate the range for the second set of numbers after ,
or -
🙈
I updated the regex, and I think we are ready now! 🤞
I'm familiar with crontab.guru, but the problem is that you can only generate random examples of valid cron expressions...
Great! I don't have any other ideas for test cases. Thanks a lot @eyarz 🎉!
The rule logic was updated on will be fixed on the next CLI release. @kedith it looks like we just created the first regex to validate cron statements so I also published it on StackOverflow 🤓
Describe the bug The default rule #8 is incomplete. I found a valid CronJob schedule pattern which isn't accepted by the rule.
To Reproduce Steps to reproduce the behavior:
Expected behavior The rule should also accept 00 for minute/hour, not just 0.
Datree version (run
datree version
):Additional context
I am trying to integrate datree in a project and it fails on a valid CronJob definition we have. This rule is useful and it would be great if the regex would be fixed.