From 046c53ac3512e4ebfd5688c22a05f6135a7d5a5e Mon Sep 17 00:00:00 2001 From: Charlie Getzen Date: Thu, 8 Aug 2024 11:35:49 -0500 Subject: [PATCH] fix: cron validation support for star step value --- regexes.go | 2 +- validator_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/regexes.go b/regexes.go index 7e1dd5a0..871cf7df 100644 --- a/regexes.go +++ b/regexes.go @@ -73,7 +73,7 @@ const ( cveRegexString = `^CVE-(1999|2\d{3})-(0[^0]\d{2}|0\d[^0]\d{1}|0\d{2}[^0]|[1-9]{1}\d{3,})$` // CVE Format Id https://cve.mitre.org/cve/identifiers/syntaxchange.html mongodbIdRegexString = "^[a-f\\d]{24}$" mongodbConnStringRegexString = "^mongodb(\\+srv)?:\\/\\/(([a-zA-Z\\d]+):([a-zA-Z\\d$:\\/?#\\[\\]@]+)@)?(([a-z\\d.-]+)(:[\\d]+)?)((,(([a-z\\d.-]+)(:(\\d+))?))*)?(\\/[a-zA-Z-_]{1,64})?(\\?(([a-zA-Z]+)=([a-zA-Z\\d]+))(&(([a-zA-Z\\d]+)=([a-zA-Z\\d]+))?)*)?$" - cronRegexString = `(@(annually|yearly|monthly|weekly|daily|hourly|reboot))|(@every (\d+(ns|us|µs|ms|s|m|h))+)|((((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*) ?){5,7})` + cronRegexString = `(@(annually|yearly|monthly|weekly|daily|hourly|reboot))|(@every (\d+(ns|us|µs|ms|s|m|h))+)|((((\d+,)+\d+|((\*|\d+)(\/|-)\d+)|\d+|\*) ?){5,7})` spicedbIDRegexString = `^(([a-zA-Z0-9/_|\-=+]{1,})|\*)$` spicedbPermissionRegexString = "^([a-z][a-z0-9_]{1,62}[a-z0-9])?$" spicedbTypeRegexString = "^([a-z][a-z0-9_]{1,61}[a-z0-9]/)?[a-z][a-z0-9_]{1,62}[a-z0-9]$" diff --git a/validator_test.go b/validator_test.go index 0f96b777..9f0188ba 100644 --- a/validator_test.go +++ b/validator_test.go @@ -13637,6 +13637,7 @@ func TestCronExpressionValidation(t *testing.T) { {"*/20 * * * *", "cron", true}, {"0 15 10 ? * MON-FRI", "cron", true}, {"0 15 10 ? * 6#3", "cron", true}, + {"0 */15 * * *", "cron", true}, {"wrong", "cron", false}, }