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

Regex support? #48

Closed
alexsnaps opened this issue Jun 18, 2024 · 3 comments · Fixed by #49
Closed

Regex support? #48

alexsnaps opened this issue Jun 18, 2024 · 3 comments · Fixed by #49

Comments

@alexsnaps
Copy link
Contributor

This is more of a question really than an actual issue... for now at least.

If I read the cel spec properly, it is expected it'd support regular expressions, re2 based flavor.

Trying this out:

#[test]
fn test_matches() {
  let tests = vec![
      ("map", "{1: 'abc', 2: 'def', 3: 'ghi'}.all(key, key.matches('^[a-zA-Z]*$')) == true"),
      ("string", "'foobar'.matches('^[a-zA-Z]*$') == true"),
  ];

  for (name, script) in tests {
      assert_eq!(test_script(script, None), Ok(true.into()), "{}", name);
  }
}

I'm getting a Err(NoSuchKey("matches")) for both map & string tests. Couldn't see anything mentioning regular expressions neither. So here's the questions, is this a conscious decision to not support them? Looking around, I couldn't find a good candidate regex lib to start implementing that support actually... especially as in our use-case we're looking at targeting wasm...

Have you considered that side of the spec? Any conclusion you came to already?

@clarkmcc
Copy link
Owner

Definitely not intentional, it's been more a lack of demand than anything. I'll definitely get this on the priority list, or I would be happy to work through a PR with you if you'd like to take a stab at it as well. Otherwise I'll take a look later this week.

@alexsnaps
Copy link
Contributor Author

Great! I'm certainly willing to have a shot at this, as if I can make it work here, I don't have to support two different code path in my own on-going work (see here, tho I'm rewriting the entire support for typing leveraging CEL, as that's how many types are actually represented with Envoy anyways).
I'll look at supporting this while keeping it all working in wasm too then tho. I'll start looking around for a way to support that and will report my findings here. If you have any leads, now or later, please drop them here too 🙏
Thanks for the awesome work you've done on CEL for Rust already!

@alexsnaps
Copy link
Contributor Author

Looks like regex would do the job... I'll start looking into leveraging it to add support for regex in the interpreter

This was referenced Jun 19, 2024
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

Successfully merging a pull request may close this issue.

2 participants