Skip to content

[Bug]: cron validator accepts arbitrary strings containing a cron-like substring #1576

Description

@ahmedkamalio

What happened?

cronRegexString in regexes.go is the only full-string validator regex in the file without ^…$ anchors. isCron (baked_in.go) calls cronRegex().MatchString(s), which matches a substring rather than the whole input — so any string that merely contains a cron expression passes validation.

Version

v10.12.0+ including master

Example Code

Examples that currently (and incorrectly) pass `validate:"cron"`:

- "random text @daily more text"
- "x 1 2 3 4 5 y"
- "prefix @every 1h suffix"
- "not at all valid; trailing junk: * * * * *"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions