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

Bugs in regular expression matching #39

Closed
jacksgt opened this issue Jul 28, 2023 · 3 comments
Closed

Bugs in regular expression matching #39

jacksgt opened this issue Jul 28, 2023 · 3 comments

Comments

@jacksgt
Copy link

jacksgt commented Jul 28, 2023

Hello!

I upgraded to the latest release (1.2.0) to get the new regular expression matching feature (thanks also for the additional documentation!).

Unfortunately, I encountered two limitations:

  1. property value cannot contain spaces

It is not possible to use an expression like try "at most 5 times every 5s to get Route named '${ROUTE_NAME}' and verify that '.spec.tls.certificate' matches 'BEGIN CERTIFICATE'".

Given this input:

oc --no-headers=true --namespace=test-cert-manager-1234 get route test-selfsigned-certificates -o jsonpath='{.spec.tls.certificate}'
-----BEGIN CERTIFICATE-----
MIIClzCCAjygAwIBAgIRANLLorHDbAcObjpzZunlA/MwCgYIKoZIzj0EAwIwHDEa
MBgGA1UEAxMRc2VsZnNpZ25lZC1pc3N1ZXIwHhcNMjMwNzI4MTQ0NDUzWhcNMjMx
MDI2MTQ0NDUzWjAAMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoNpJ
qiSEgZ72mOt6yyI4EVncF5UWLdyBetvQYAmWsOZLPnPZy2ZgfMKEN9+RfJROuHAs
MqMxHqgicxmNMuiWNbWr4+8Q7gYHsbnLXvsa15ykRM/Yz/lHrQAPiUPvFnLC8xKC
Z+RozJi3lspR8VHc7RYzg/NmiehYypz78sBV9IMKnC/Qz4zaZUG+pXsEr6kddW3x
4cs5VpSsrz9XZvDbd5To1BiB4MPQEKBOO6hvBqryS+1CjbRNA/TizEQkC8ZKaiH6
AtPuhhuoFPnVcpb0pWEalRfq4f4lrVvJfRgcuABjeoHK9oYlikWKFdPcZHbXGrIr
kwK0UKK+AIOWmdTpVwIDAQABo4GvMIGsMA4GA1UdDwEB/wQEAwIFoDATBgNVHSUE
DDAKBggrBgEFBQcDATAMBgNVHRMBAf8EAjAAMB8GA1UdIwQYMBaAFHLHEmRxTNZP
HjyKOdO5Kt+qoUhFMFYGA1UdEQEB/wRMMEqCSHRlc3Qtc2VsZnNpZ25lZC1jZXJ0
aWZpY2F0ZXMtdGVzdC1jZXJ0LW1hbmFnZXItMTIzNC5jbHUtamFjay1kZXYuY2Vy
bi5jaDAKBggqhkjOPQQDAgNJADBGAiEA7dd13BTx7ZujRw/n1hK1A34J1eJbZPJO
yvl5J3M3FH0CIQCTRWWIgKgSN/Uh7mR07D/A7G1POCSkb3z1Hh4B+yM0lw==
-----END CERTIFICATE-----

This line of code fails:

value=$(echo "$line" | awk '{ print $2 }')

		# Keep the second column (property to verify)
		value=$(echo "$line" | awk '{ print $2 }')

and only keeps -----BEGIN in value (instead of the entire line).


  1. regular expression cannot begin with dashes

It is not possible to use an expression like try "at most 5 times every 5s to get Route named '${ROUTE_NAME}' and verify that '.spec.tls.certificate' matches '----END CERTIFICATE----$'", because the leading dashes get interpreted as an argument for bash.

   Valid expression. Verification in progress...
   grep: unrecognized option '-----END CERTIFICATE-----'
   Usage: grep [OPTION]... PATTERNS [FILE]...
   Try 'grep --help' for more information.
@vincent-zurczak
Copy link
Member

OK. Let me have a look.

@vincent-zurczak
Copy link
Member

vincent-zurczak commented Sep 29, 2023

Sorry for the delay.
I have just pushed a fix. I am waiting for a code review before merging.

Thank you for reporting these issues. :)

vincent-zurczak added a commit that referenced this issue Oct 12, 2023
#39 Support spaces and dashes in regular expressions
@vincent-zurczak
Copy link
Member

I have just merged and tagged a new version (1.2.1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants