oasis-open / cti-pattern-validator

OASIS TC Open Repository: Validate patterns used to express cyber observable content in STIX Indicators
https://stix2-patterns.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
26 stars 23 forks source link

Repeat Negative Times #41

Closed varnerac closed 6 years ago

varnerac commented 6 years ago
$ validate-patterns
Enter a pattern to validate: [ipv4-addr:value = '198.51.100.1/32'] REPEATS -5 TIMES

PASS: [ipv4-addr:value = '198.51.100.1/32'] REPEATS -5 TIMES

I don't think something should be allowed to repeat a negative number of times.

gtback commented 6 years ago

Thanks for opening this, @varnerac and sorry for not seeing it right away. I'll need to check whether this is technically allowed by the spec; if so, we probably shouldn't invalidate it here. I agree that the pattern doesn't make sense semantically :-)

gtback commented 6 years ago

From the spec:

x MUST be a positive integer.

So yes, we should prevent that in the validator if possible :-)

Thanks, @varnerac

gtback commented 6 years ago

@varnerac This should be fixed now, but if not, feel free to reopen.