Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation Regex Bug? #2881

Open
Piankero opened this issue Aug 15, 2019 · 4 comments

Comments

@Piankero
Copy link
Contributor

commented Aug 15, 2019

Steps to Reproduce the Problem

Does C use a different form of regex engine?
The regex below works just fine in the browser: https://regex101.com/r/fZr9Mi/1

kdb mount test.spec spec/tests dump
kdb mount test.conf /tests dump validation
kdb rm -r /tests
kdb rm -r spec/tests
kdb rm user/tests/abc

kdb setmeta spec/tests/abc 'check/validation' '[1-9]\d{3,}'
kdb setmeta spec/tests/abc 'check/validation/match' 'LINE'
kdb setmeta spec/tests/abc 'check/validation/message' 'LircFlushThreshold must be a positive number >=1000'

kdb set /tests/abc 1000

kdb umount spec/tests
kdb umount /tests

Expected Result

The upper script is executed without any error

Actual Result

Sorry, module validation issued the error C03100:
Validation Syntactic: Key value failed to validate. Reason: LircFlushThreshold must be a positive number >=1000

System Information

  • Elektra Version: master
@markus2330

This comment has been minimized.

Copy link
Contributor

commented Aug 15, 2019

Thank you for reporting this problem!

Checking for numbers is easier to be done by the range plugin.

But you are right, the documentation about which kind of regex is supported is poor, this should be improved. We use REG_NOSUB | REG_EXTENDED from regcomp by default but this can be modified with check/validation/type (undocumented? BRE switches to basic regular expressions).

So we should:

  • document which regex can be used (link to regcomp(1) and regex(7) manual page)
  • clarify the check/validation/type in the docu or remove the feature
  • allow the message to contain the value and regex
  • and finally also fix #2603

To answer why the regex does not work: I would check if \d is supported.

@Piankero

This comment has been minimized.

Copy link
Contributor Author

commented Aug 15, 2019

Thank you for your clarification.

Checking for numbers is easier to be done by the range plugin.

I cannot do this since the range plugin needs a lower and upper bound whereas I only have a lower bound.

@Piankero

This comment has been minimized.

Copy link
Contributor Author

commented Aug 15, 2019

Switching the regex to [1-9][0-9]{3,} does now work.

@markus2330

This comment has been minimized.

Copy link
Contributor

commented Aug 15, 2019

Good! Would be great if you can improve the docu, so that it will be easier for the next person.

I cannot do this since the range plugin needs a lower and upper bound whereas I only have a lower bound.

It is possible if you write the actual number of LLONG_MIN-1000. But your regex also does not work for numbers below 0, so you could use the range 0-1000.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.