Commit f6b1c39
committed
Use word-boundary regex to detect
The simple `"now" in expression` substring check could produce false
positives for identifiers like `renown` or `knows`, setting `_uses_now`
unnecessarily. Replace with `_NOW_RE = re.compile(r"\bnow\b")` so only
the standalone identifier is matched.
The `\b` assertion matches at the boundary between word characters
(`[a-zA-Z0-9_]`) and non-word characters. Since CEL identifiers are
`[_a-zA-Z][_a-zA-Z0-9]*`, any occurrence of `now` as an identifier —
including inside expressions like `timestamp(now)` — is always flanked
by non-identifier characters, so this approach produces no false
negatives.now in CEL expressions1 parent 62e1830 commit f6b1c39
1 file changed
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
47 | 51 | | |
48 | 52 | | |
49 | 53 | | |
| |||
413 | 417 | | |
414 | 418 | | |
415 | 419 | | |
416 | | - | |
| 420 | + | |
417 | 421 | | |
418 | 422 | | |
419 | 423 | | |
| |||
0 commit comments