@libreflare/worker-runtime 0.10.3 → 0.10.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -37
- package/dist/rule-evaluator/access-values.d.ts +42 -27
- package/dist/rule-evaluator/access-values.d.ts.map +1 -1
- package/dist/rule-evaluator/access-values.js +123 -52
- package/dist/rule-evaluator/access-values.js.map +1 -1
- package/dist/rule-evaluator/ast.d.ts +6 -0
- package/dist/rule-evaluator/ast.d.ts.map +1 -1
- package/dist/rule-evaluator/ast.js.map +1 -1
- package/dist/rule-evaluator/byte-strings.d.ts.map +1 -1
- package/dist/rule-evaluator/byte-strings.js +27 -11
- package/dist/rule-evaluator/byte-strings.js.map +1 -1
- package/dist/rule-evaluator/constants.d.ts +1 -1
- package/dist/rule-evaluator/constants.d.ts.map +1 -1
- package/dist/rule-evaluator/constants.js +3 -0
- package/dist/rule-evaluator/constants.js.map +1 -1
- package/dist/rule-evaluator/country-codes.generated.js +1 -1
- package/dist/rule-evaluator/diagnostics.d.ts +1 -1
- package/dist/rule-evaluator/diagnostics.d.ts.map +1 -1
- package/dist/rule-evaluator/diagnostics.js +8 -0
- package/dist/rule-evaluator/diagnostics.js.map +1 -1
- package/dist/rule-evaluator/edge-field-gaps.d.ts +6 -4
- package/dist/rule-evaluator/edge-field-gaps.d.ts.map +1 -1
- package/dist/rule-evaluator/edge-field-gaps.js +14 -39
- package/dist/rule-evaluator/edge-field-gaps.js.map +1 -1
- package/dist/rule-evaluator/edge-record.js +2 -0
- package/dist/rule-evaluator/edge-record.js.map +1 -1
- package/dist/rule-evaluator/engine-observations.d.ts +4 -4
- package/dist/rule-evaluator/engine-observations.d.ts.map +1 -1
- package/dist/rule-evaluator/engine-observations.generated.d.ts +496 -3
- package/dist/rule-evaluator/engine-observations.generated.d.ts.map +1 -1
- package/dist/rule-evaluator/engine-observations.generated.js +389 -248
- package/dist/rule-evaluator/engine-observations.generated.js.map +1 -1
- package/dist/rule-evaluator/engine-observations.js +1 -0
- package/dist/rule-evaluator/engine-observations.js.map +1 -1
- package/dist/rule-evaluator/explain.js +10 -7
- package/dist/rule-evaluator/explain.js.map +1 -1
- package/dist/rule-evaluator/field-availability.d.ts +6 -1
- package/dist/rule-evaluator/field-availability.d.ts.map +1 -1
- package/dist/rule-evaluator/field-availability.js +16 -4
- package/dist/rule-evaluator/field-availability.js.map +1 -1
- package/dist/rule-evaluator/field-descriptions.generated.d.ts +147 -5
- package/dist/rule-evaluator/field-descriptions.generated.d.ts.map +1 -1
- package/dist/rule-evaluator/field-descriptions.generated.js +345 -5
- package/dist/rule-evaluator/field-descriptions.generated.js.map +1 -1
- package/dist/rule-evaluator/fields.d.ts +0 -1
- package/dist/rule-evaluator/fields.d.ts.map +1 -1
- package/dist/rule-evaluator/fields.js +67 -8
- package/dist/rule-evaluator/fields.js.map +1 -1
- package/dist/rule-evaluator/function-availability.d.ts +7 -0
- package/dist/rule-evaluator/function-availability.d.ts.map +1 -1
- package/dist/rule-evaluator/function-availability.js +38 -0
- package/dist/rule-evaluator/function-availability.js.map +1 -1
- package/dist/rule-evaluator/function-descriptions.d.ts +10 -2
- package/dist/rule-evaluator/function-descriptions.d.ts.map +1 -1
- package/dist/rule-evaluator/function-descriptions.generated.d.ts +55 -4
- package/dist/rule-evaluator/function-descriptions.generated.d.ts.map +1 -1
- package/dist/rule-evaluator/function-descriptions.generated.js +351 -1
- package/dist/rule-evaluator/function-descriptions.generated.js.map +1 -1
- package/dist/rule-evaluator/function-descriptions.js +3 -1
- package/dist/rule-evaluator/function-descriptions.js.map +1 -1
- package/dist/rule-evaluator/function-signature-validation.d.ts +18 -0
- package/dist/rule-evaluator/function-signature-validation.d.ts.map +1 -1
- package/dist/rule-evaluator/function-signature-validation.js +146 -13
- package/dist/rule-evaluator/function-signature-validation.js.map +1 -1
- package/dist/rule-evaluator/functions.d.ts +10 -6
- package/dist/rule-evaluator/functions.d.ts.map +1 -1
- package/dist/rule-evaluator/functions.js +469 -172
- package/dist/rule-evaluator/functions.js.map +1 -1
- package/dist/rule-evaluator/operators.d.ts +0 -6
- package/dist/rule-evaluator/operators.d.ts.map +1 -1
- package/dist/rule-evaluator/operators.js +4 -52
- package/dist/rule-evaluator/operators.js.map +1 -1
- package/dist/rule-evaluator/parser.d.ts.map +1 -1
- package/dist/rule-evaluator/parser.js +4 -1
- package/dist/rule-evaluator/parser.js.map +1 -1
- package/dist/rule-evaluator/quantifier.d.ts +17 -2
- package/dist/rule-evaluator/quantifier.d.ts.map +1 -1
- package/dist/rule-evaluator/quantifier.js +90 -7
- package/dist/rule-evaluator/quantifier.js.map +1 -1
- package/dist/rule-evaluator/replacement.d.ts +37 -0
- package/dist/rule-evaluator/replacement.d.ts.map +1 -0
- package/dist/rule-evaluator/replacement.js +54 -0
- package/dist/rule-evaluator/replacement.js.map +1 -0
- package/dist/rule-evaluator/rule-language-types.d.ts.map +1 -1
- package/dist/rule-evaluator/rule-language-types.js +5 -0
- package/dist/rule-evaluator/rule-language-types.js.map +1 -1
- package/dist/rule-evaluator/validation.d.ts +1 -1
- package/dist/rule-evaluator/validation.d.ts.map +1 -1
- package/dist/rule-evaluator/validation.js +160 -106
- package/dist/rule-evaluator/validation.js.map +1 -1
- package/dist/rule-evaluator/wildcard.d.ts +65 -0
- package/dist/rule-evaluator/wildcard.d.ts.map +1 -0
- package/dist/rule-evaluator/wildcard.js +168 -0
- package/dist/rule-evaluator/wildcard.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ Analysis:
|
|
|
54
54
|
|
|
55
55
|
Validation:
|
|
56
56
|
|
|
57
|
-
- `validateRuleExpressionSyntax`: syntax, length, and field availability validation for Cloudflare URL Rewrite Rule filter expressions by default. Pass an explicit config object for minification, length enforcement, preset, field availability, deprecated-field notices, and list-reference policy. With minification enabled it validates the minified expression against Cloudflare's 4096-character rule limit by default; when minification is disabled, the result omits `minifiedExpression` and `minifiedLength`.
|
|
57
|
+
- `validateRuleExpressionSyntax`: syntax, length, and field availability validation for Cloudflare URL Rewrite Rule filter expressions by default. Pass an explicit config object for minification, length enforcement, preset, field availability, deprecated-field notices, and list-reference policy. The presets are `url-rewrite-filter`, `url-rewrite-target`, `custom-rule` for the Custom Rules of a zone, and `logging-source-key`. With minification enabled it validates the minified expression against Cloudflare's 4096-character rule limit by default; when minification is disabled, the result omits `minifiedExpression` and `minifiedLength`.
|
|
58
58
|
- `validateLoggingSourceKeyRuleExpressionSyntax`: runtime-only source-key rule validation using the pre-origin field context, without Custom List references or deployment length enforcement.
|
|
59
59
|
- `trimRuleExpression`: the expression without the whitespace Cloudflare trims off its ends, which is every character Unicode counts as whitespace: unlike `String.prototype.trim()`, it keeps U+FEFF and trims U+0085. Validation reads the expression trimmed this way, so its diagnostic positions count from the first character that is not whitespace, `source.search(/\P{White_Space}/u)`.
|
|
60
60
|
|
|
@@ -125,8 +125,11 @@ an expression, `lookup_json_*()` keys must be literals,
|
|
|
125
125
|
header map keys such as `http.request.headers["x-a"]` must be lowercase, and
|
|
126
126
|
integer literals must fit in 64 bits, with `0x` making one hex and a leading `0` making one octal. Field availability keeps each preset's
|
|
127
127
|
documented fields and the observed differences apart, and `fieldAvailability`
|
|
128
|
-
can still allow a field the engine was observed to reject.
|
|
129
|
-
|
|
128
|
+
can still allow a field the engine was observed to reject. Cloudflare documents
|
|
129
|
+
no field list for Custom Rules, so theirs is the observed one. The catalog also
|
|
130
|
+
has fields and functions that Cloudflare's references lack and dry runs accepted,
|
|
131
|
+
such as `cf.zone.plan`, `encode_hex()` and `filter()`. Source-key rules run in
|
|
132
|
+
the Worker rather than in a Cloudflare phase, so the URL rewrite phase's
|
|
130
133
|
observed differences do not apply to them.
|
|
131
134
|
|
|
132
135
|
Cloudflare trims any whitespace off the ends of an expression, but reads only
|
|
@@ -180,7 +183,17 @@ rewrite phase does not accept, such as `split()` in either and `to_string()`
|
|
|
180
183
|
in filters, with `function.unavailable`. Rewrite targets reject operators,
|
|
181
184
|
quantifiers, and conditions used as function arguments, such as `eq`, `any()`,
|
|
182
185
|
and `to_string((ssl))`, with `operator.unavailable`. In both, `concat()` can
|
|
183
|
-
appear only once.
|
|
186
|
+
appear only once.
|
|
187
|
+
|
|
188
|
+
Custom Rules also reject some functions with `function.unavailable`, such as
|
|
189
|
+
`split()`, or `join()` and `wildcard_replace()`, which URL rewrite filters
|
|
190
|
+
accept. They accept some that URL rewrite filters reject, such as `cidr()` and
|
|
191
|
+
`to_string()`. In Custom Rules, `concat()` can also appear only once, and it
|
|
192
|
+
reads only some request fields, such as `http.request.uri.path` and the request
|
|
193
|
+
headers but not `http.host`, directly or through nested calls; another field
|
|
194
|
+
gets `function.parameter.requires_allowed_field`.
|
|
195
|
+
|
|
196
|
+
These phase rules depend on the preset alone:
|
|
184
197
|
`fieldAvailability` does not change them, and they do not apply to source-key
|
|
185
198
|
rules or when `evaluateExpression` decides whether an expression is valid.
|
|
186
199
|
`getRuleExpressionFunctionDescriptions()` lists only the functions a preset
|
|
@@ -188,16 +201,17 @@ accepts, `url-rewrite-filter` by default as in validation; the
|
|
|
188
201
|
`logging-source-key` preset lists every function.
|
|
189
202
|
|
|
190
203
|
The observed behavior is recorded in
|
|
191
|
-
`src/rule-evaluator/engine-observations.generated.ts` by
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
`test/fixtures/rules-engine-probes.json`, and `npm test`
|
|
195
|
-
where this package's validator disagrees with the recorded
|
|
196
|
-
`CLOUDFLARE_API_TOKEN` (Zone Read
|
|
197
|
-
`CLOUDFLARE_ZONE_ID`,
|
|
198
|
-
|
|
199
|
-
`--write-probes <file>` and
|
|
200
|
-
`--responses <file>`, as described in the
|
|
204
|
+
`src/rule-evaluator/engine-observations.generated.ts` by `npm run
|
|
205
|
+
probe:rules-engine`, which dry-runs probe expressions against a URL rewrite
|
|
206
|
+
ruleset and a Custom Rules ruleset. It also records every probe with the
|
|
207
|
+
engine's verdict in `test/fixtures/rules-engine-probes.json`, and `npm test`
|
|
208
|
+
fails on any probe where this package's validator disagrees with the recorded
|
|
209
|
+
verdict. It needs `CLOUDFLARE_API_TOKEN` (Zone Read, Transform Rules Edit and
|
|
210
|
+
Zone WAF Edit), `CLOUDFLARE_ZONE_ID`, `CLOUDFLARE_URL_REWRITE_RULESET_ID`, and
|
|
211
|
+
`CLOUDFLARE_CUSTOM_RULES_RULESET_ID`, and never changes the rulesets. To probe
|
|
212
|
+
through another client, write the probe list with `--write-probes <file>` and
|
|
213
|
+
pass the API responses back with `--responses <file>`, as described in the
|
|
214
|
+
script.
|
|
201
215
|
|
|
202
216
|
## Rule Expression Evaluation
|
|
203
217
|
|
|
@@ -296,6 +310,19 @@ Quoted strings are read as Cloudflare reads them:
|
|
|
296
310
|
- A map key, as in `http.request.headers["x"]`, must be a quoted string that
|
|
297
311
|
is valid UTF-8, so `[r"x"]` and `["\xff"]` are errors.
|
|
298
312
|
|
|
313
|
+
Wildcard patterns, after `wildcard` and `strict wildcard` and in
|
|
314
|
+
`wildcard_replace()`, have escapes of their own: `\*` is a literal `*` and `\\` a
|
|
315
|
+
literal `\`, written `"\\*"` and `"\\\\"` in a quoted string. A `\` before any
|
|
316
|
+
other character, or at the end of a pattern, is an error, as is `**`. A
|
|
317
|
+
`wildcard_replace()` pattern can have at most eight `*`s, one for each of
|
|
318
|
+
`${1}` to `${8}`.
|
|
319
|
+
|
|
320
|
+
In the replacement of `wildcard_replace()` and `regex_replace()`, `${1}` stands
|
|
321
|
+
for the first capture and `$$` for a `$`, and in `regex_replace()`, `${0}` stands
|
|
322
|
+
for the whole match. Any other `$` is an error, and so are more than eight
|
|
323
|
+
references, or one past the pattern's captures. Validation does not count a
|
|
324
|
+
regex's captures, so it rejects only references past `${8}` there.
|
|
325
|
+
|
|
299
326
|
### Maps
|
|
300
327
|
|
|
301
328
|
The request header, cookie, and query argument maps are values too: functions
|
|
@@ -372,7 +399,8 @@ lists, where one `any()` for each array is usually what the rule means. Arrays
|
|
|
372
399
|
line up when they read the same field and access, directly or through a call
|
|
373
400
|
that gives each element a result, such as `lower()`, or when they come from one
|
|
374
401
|
list: the request header names and values, the query argument names and values,
|
|
375
|
-
or the response header names and values.
|
|
402
|
+
or the response header names and values. `filter()` calls over arrays that line
|
|
403
|
+
up do too when their conditions are the same. Raw fields are read before rewrites
|
|
376
404
|
and transforms, so the raw names and values make lists of their own. The
|
|
377
405
|
content scan arrays line up too, as Cloudflare documents them in the order the
|
|
378
406
|
objects were detected. Its documentation says nothing of the order of others,
|
|
@@ -386,11 +414,11 @@ elements settle it. An array may also hold more elements than it lists: when
|
|
|
386
414
|
`request.cf.requestHeaderNames` is cut, the request header arrays hold the
|
|
387
415
|
listed headers, and others at positions Worker context cannot tell. Their known
|
|
388
416
|
elements still pair with arrays that line up with them, as the warning counts
|
|
389
|
-
them, when each
|
|
390
|
-
settle the result counts only where every array surely
|
|
391
|
-
explain output words the reason for a predicate over several
|
|
392
|
-
pairs, as in `none of 4 paired element(s) satisfy its predicate`,
|
|
393
|
-
over a single array, such as a call's, by its elements, as in
|
|
417
|
+
them, when each lists as many and may lack the same ones, but not with other
|
|
418
|
+
arrays. A pair that would settle the result counts only where every array surely
|
|
419
|
+
has an element. The explain output words the reason for a predicate over several
|
|
420
|
+
arrays by their pairs, as in `none of 4 paired element(s) satisfy its predicate`,
|
|
421
|
+
and for one over a single array, such as a call's, by its elements, as in
|
|
394
422
|
`none of 4 element(s) satisfy its predicate`. When a call read as a value gives
|
|
395
423
|
nil, the reason says so, as in
|
|
396
424
|
`function 'starts_with' returned nil, which all() does not hold for`. In the
|
|
@@ -406,8 +434,8 @@ array of Booleans, one for each pair of its arrays, up to the shorter one (see
|
|
|
406
434
|
Quantifier Predicates). A comparison over `[*]` is such an argument, in
|
|
407
435
|
parentheses or not, and so is a call in parentheses that gives an array of
|
|
408
436
|
Booleans, as in `len((starts_with(http.request.headers.names[*], "x-")))`.
|
|
409
|
-
`len()`, `concat()`, `coalesce()` and `has_value()`'s collection
|
|
410
|
-
array, so
|
|
437
|
+
`len()`, `concat()`, `coalesce()`, `filter()` and `has_value()`'s collection
|
|
438
|
+
take the array, so
|
|
411
439
|
`any(concat((http.request.headers.names[*] eq "x-a"), (http.request.uri.args.names[*] eq "a")))`
|
|
412
440
|
holds when the request has the header or the query argument, without pairing
|
|
413
441
|
the two lists. No call maps over the array, so `len()` gives one Integer. A
|
|
@@ -419,13 +447,28 @@ uses the arguments after one. An element Worker context cannot tell keeps its
|
|
|
419
447
|
place as unknown, also through `concat()`, and `len()`, `has_value()`, `any()`
|
|
420
448
|
and `all()` read it only where their result depends on it.
|
|
421
449
|
|
|
450
|
+
`filter()`, which Cloudflare's reference lacks, gives the elements of its first
|
|
451
|
+
argument, an array, whose results in its second are true, so
|
|
452
|
+
`any(filter(http.request.headers.values, http.request.headers.names[*] eq "x-a")[*] eq "b")`
|
|
453
|
+
holds when an `x-a` header has the value `b`. Live requests on 2026-11-25 showed
|
|
454
|
+
that it pairs the two by index, stops at the shorter one, and gives an empty
|
|
455
|
+
array, not nil, when it keeps nothing. Over `[*]`, as in
|
|
456
|
+
`filter(http.request.uri.args[*], ...)`, each of the arrays pairs with the same
|
|
457
|
+
results. Cloudflare's `filter()` panics on a nil array, which fails the dry run of
|
|
458
|
+
a rule with `filter(http.request.headers["x"], ...)`, so validation rejects an
|
|
459
|
+
argument of it that may be nil, such as a map key's values, an array's element,
|
|
460
|
+
or a call over one, with `function.parameter.may_be_nil`. An element whose result
|
|
461
|
+
is unknown may be missing from its place among the elements kept, which leaves
|
|
462
|
+
the positions from there on unknown.
|
|
463
|
+
|
|
422
464
|
Validation checks each comparison over each element as a comparison of single
|
|
423
465
|
elements, with the `operator.*` diagnostics, and the array as its parameter's
|
|
424
466
|
value, so `lower((http.request.headers.names[*] eq "a"))` gets
|
|
425
467
|
`function.parameter.requires_typed_value`. Conditions with a result for each
|
|
426
468
|
element combine only with each other (`logical.operand_type_mismatch`), and
|
|
427
469
|
those over arrays from different lists get `array_expansion.unaligned_arrays`,
|
|
428
|
-
naming the function they are an argument of
|
|
470
|
+
naming the function they are an argument of, with `filter()`'s array among them.
|
|
471
|
+
Where a condition needs a single
|
|
429
472
|
result, as a whole expression or combined with one, a comparison over `[*]`
|
|
430
473
|
gets `array_expansion.direct_comparison`, and a call that gives an array of
|
|
431
474
|
Booleans gets `function.result_type_mismatch`. Dry runs on 2026-10-20 and
|
|
@@ -549,8 +592,8 @@ the solve, and the request goes where its unrewritten URL leads, which may
|
|
|
549
592
|
not be the Worker. Validation gives the notice
|
|
550
593
|
`field.header_dropped_on_challenge_solve` where a rule looks either header up
|
|
551
594
|
by name: by its key in the request headers, with `has_key()`, or among the
|
|
552
|
-
header names, with `has_value()` or by comparing each with the name in `any()
|
|
553
|
-
or `
|
|
595
|
+
header names, with `has_value()` or by comparing each with the name in `any()`,
|
|
596
|
+
`all()` or a function argument, such as `filter()`'s.
|
|
554
597
|
|
|
555
598
|
The evaluator takes a GET for a solve when its names list `Content-Length`,
|
|
556
599
|
`Content-Type` and `Origin` and the Worker has none of them. It then lists
|
|
@@ -574,10 +617,12 @@ Worker's other headers count once, and over HTTP/1 their names are lowercase
|
|
|
574
617
|
rather than the client's spelling. Cloudflare's order followed no protocol's
|
|
575
618
|
layout in the probes, so positions in the names and values follow the order
|
|
576
619
|
above, and validation warns where a rule reads them by index or through
|
|
577
|
-
`join()`, also by way of `coalesce()`, `concat()` and functions that
|
|
578
|
-
them, or where `any()` or `
|
|
620
|
+
`join()`, also by way of `coalesce()`, `concat()`, `filter()` and functions that
|
|
621
|
+
map over them, or where `any()`, `all()` or `filter()` pairs them with an array
|
|
622
|
+
from another list.
|
|
579
623
|
The raw header fields are unknown on a solve, so reading them in order gets no
|
|
580
|
-
such warning
|
|
624
|
+
such warning, and neither does a Custom Rule, which is never evaluated in Worker
|
|
625
|
+
context.
|
|
581
626
|
|
|
582
627
|
Cloudflare replays a challenged POST with its body, so it keeps its
|
|
583
628
|
`Content-Type` and is not taken for a solve. Cloudflare's header fields read
|
|
@@ -592,7 +637,7 @@ Cloudflare adds. Live requests compared them with Cloudflare's values over
|
|
|
592
637
|
HTTP/1.1, HTTP/2 and HTTP/3, and the evaluator follows what they showed:
|
|
593
638
|
|
|
594
639
|
- `cf.ray_id` adds the data center to the Worker's `CF-Ray`, as in
|
|
595
|
-
`8f1c2a3b4d5e6f70-LAX`.
|
|
640
|
+
`8f1c2a3b4d5e6f70-LAX`, and `cf.colo.code` reads it from `request.cf.colo`.
|
|
596
641
|
- `cf.edge.client_tcp` is false over HTTP/3 and true over the other HTTP
|
|
597
642
|
versions, which run over TCP. Cloudflare's `cf.timings.client_tcp_rtt_msec`
|
|
598
643
|
was 1 ms more than `request.cf.clientTcpRtt` in every TCP request probed, and
|
|
@@ -633,12 +678,14 @@ Values the evaluator cannot resolve are unknown rather than nil. These include
|
|
|
633
678
|
`raw.*` URI fields in Worker context, request metadata missing from the
|
|
634
679
|
request, such as `request.cf` properties or the `cf-connecting-ip` header behind
|
|
635
680
|
`ip.src`, which the Remove visitor IP headers Managed Transform removes, and
|
|
636
|
-
results of functions it cannot reproduce, such as the hash
|
|
637
|
-
`md5()`, `sha1()`, `sha256()` and `sha512()`, and `is_jwt_valid()
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
681
|
+
results of functions it cannot reproduce, such as `hmac_sha256()`, the hash
|
|
682
|
+
functions `md5()`, `sha1()`, `sha256()` and `sha512()`, and `is_jwt_valid()`,
|
|
683
|
+
or whose result holds more than 524,288 characters, counting each array element
|
|
684
|
+
as at least 8, or just 8 in `concat()` of arrays; the elements of an array that
|
|
685
|
+
fit stay known. An unknown value makes the functions and comparisons that use it
|
|
686
|
+
unknown. It also makes `not`, `and`, `or` and `xor` unknown, unless another
|
|
687
|
+
operand settles the result. An unknown result does not match, and the evaluation
|
|
688
|
+
warnings name the values involved.
|
|
642
689
|
|
|
643
690
|
Unresolved Cloudflare list references are the exception: they count as
|
|
644
691
|
inferred matches whenever assuming the list results alone can make the
|
|
@@ -855,7 +902,7 @@ Probes on a playground zone compared edge records with the rules engine's
|
|
|
855
902
|
values for the same requests, which a response header transform rule echoed
|
|
856
903
|
into the records (live requests, 2026-11-16 and 2026-11-17,
|
|
857
904
|
`test/fixtures/edge-record-probes.json`). The evaluator reads only what they
|
|
858
|
-
showed equal:
|
|
905
|
+
or other live requests showed equal, or what follows from it:
|
|
859
906
|
|
|
860
907
|
- `ip.src` reads the client address, and the location fields, Cloudflare's
|
|
861
908
|
ASN, country, city, region code, latitude and longitude. Logpush gives the
|
|
@@ -870,7 +917,10 @@ showed equal:
|
|
|
870
917
|
Worker's: the engine's was the record's plus 1 on every TCP request probed,
|
|
871
918
|
and on 15 production requests the Worker's equaled the record's. An RTT of
|
|
872
919
|
0 over TCP is unknown.
|
|
873
|
-
- `cf.ray_id` joins the Ray ID and the data center.
|
|
920
|
+
- `cf.ray_id` joins the Ray ID and the data center. The probes did not echo
|
|
921
|
+
`cf.colo.code`, which reads the data center, as it is the suffix of the
|
|
922
|
+
engine's Ray ID. Nor did they echo `http.request.headers.truncated` and its raw
|
|
923
|
+
form, which live requests with 1,000 headers showed false.
|
|
874
924
|
- `http.host`, `http.request.full_uri` and `raw.http.request.full_uri` read
|
|
875
925
|
the record's host, which Logpush gives in lowercase with any port or
|
|
876
926
|
trailing dot the client sent. The engine reads it without them, on any
|
|
@@ -11,42 +11,57 @@ export type ElementValue = Known<CfValue> | UnknownElement;
|
|
|
11
11
|
/** A map key's values, which can be known in part, as a header sent once with unknown text. */
|
|
12
12
|
export type MapEntryValue = Known<CfValue | PartialArrayValue> | UnknownElement;
|
|
13
13
|
export declare function isUnknownElement(element: MapEntryValue): element is UnknownElement;
|
|
14
|
+
/** An element of an array that the array may lack, and why it may. */
|
|
15
|
+
export declare class OptionalElement {
|
|
16
|
+
readonly element: ElementValue;
|
|
17
|
+
readonly reason: UnknownElement;
|
|
18
|
+
constructor(element: ElementValue, reason: UnknownElement);
|
|
19
|
+
}
|
|
20
|
+
/** An element a partly known array lists. */
|
|
21
|
+
export type ArrayElement = ElementValue | OptionalElement;
|
|
22
|
+
/** The element listed, as it is where the array has it. */
|
|
23
|
+
export declare function listedElement(listed: ArrayElement): ElementValue;
|
|
24
|
+
/** An element in the place of one listed, which an array lacks where it lacks that one. */
|
|
25
|
+
export declare function inPlaceOf(listed: ArrayElement, element: ElementValue): ArrayElement;
|
|
14
26
|
/**
|
|
15
|
-
* An array some of
|
|
16
|
-
* request header
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
27
|
+
* An array known in part while evaluating: some of its elements are unknown,
|
|
28
|
+
* as a request header's value that Worker context lacks, or it may lack some,
|
|
29
|
+
* as filter() may keep an element or not, or hold some it does not list, as a
|
|
30
|
+
* request header list that may be cut. What it lists is surely in order only
|
|
31
|
+
* before any element it does not list. Its known elements can still settle
|
|
32
|
+
* any() and all(), has_value(), and an index whose position is certain, and
|
|
33
|
+
* mapped calls, concat() and filter() keep them; anything else that reads the
|
|
34
|
+
* whole array is unknown. Arrays from one list still line up; see
|
|
35
|
+
* pairArrays().
|
|
22
36
|
*/
|
|
23
37
|
export declare class PartialArrayValue {
|
|
24
|
-
readonly elements: readonly
|
|
38
|
+
readonly elements: readonly ArrayElement[];
|
|
39
|
+
/** Why the array may hold elements it does not list, when it may. */
|
|
25
40
|
readonly more: UnknownElement | undefined;
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
readonly
|
|
41
|
+
/** How many of the elements listed come before any that is not. */
|
|
42
|
+
readonly moreFrom: number;
|
|
43
|
+
/** How many elements the array surely has. */
|
|
44
|
+
readonly shortest: number;
|
|
45
|
+
/** How many elements at its start have certain positions. */
|
|
46
|
+
readonly leading: number;
|
|
47
|
+
/** Why the array's length is unknown, when it is, and so are its positions past the leading ones. */
|
|
48
|
+
readonly unknownLength: UnknownElement | undefined;
|
|
30
49
|
private constructor();
|
|
31
50
|
/**
|
|
32
|
-
* An array of elements,
|
|
33
|
-
*
|
|
34
|
-
* conditions over a collection that may end early, `optional` lists them.
|
|
35
|
-
*/
|
|
36
|
-
static from(elements: readonly ElementValue[], more?: UnknownElement, optional?: readonly ElementValue[]): CfValue[] | PartialArrayValue;
|
|
37
|
-
/**
|
|
38
|
-
* Why the array may hold a matching element besides its known ones: its
|
|
39
|
-
* first unknown element, or that it may hold more, unless it may hold only
|
|
40
|
-
* optional elements, none of which match.
|
|
51
|
+
* An array of elements, known in part when one is unknown or may be lacking,
|
|
52
|
+
* or when it may hold `more`, which then come after the first `moreFrom`.
|
|
41
53
|
*/
|
|
54
|
+
static from(elements: readonly ArrayElement[], more?: UnknownElement, moreFrom?: number): CfValue[] | PartialArrayValue;
|
|
55
|
+
/** Why the array may hold a matching element besides the known ones it surely has, when it may. */
|
|
42
56
|
unknownMatch(matches: (value: CfValue) => boolean): UnknownElement | undefined;
|
|
43
|
-
/** Why the whole array is unknown
|
|
57
|
+
/** Why the whole array is unknown. */
|
|
44
58
|
unknown(): Unknown;
|
|
45
|
-
/** The
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
/** The first reason why the array is not known whole. */
|
|
60
|
+
firstUnknown(): UnknownElement;
|
|
61
|
+
/** The array without the elements it may lack, as ones it does not list. */
|
|
62
|
+
withoutOptional(): PartialArrayValue;
|
|
63
|
+
/** The values of the known elements the array surely has. */
|
|
64
|
+
knownValues(): CfValue[];
|
|
50
65
|
/** The element at an index, nil past the end. */
|
|
51
66
|
at(index: number): Evaluated<CfValue>;
|
|
52
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access-values.d.ts","sourceRoot":"","sources":["../../src/rule-evaluator/access-values.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEpD,OAAO,EAAoB,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAE1F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AM;IACvB,4CAA4C;IAC5C,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,qEAAqE;IACrE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;;IALtB,uEAAuE;IACtD,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,aAAa;IACvD,4CAA4C;IAC3B,IAAI,EAAE,MAAM,WAAW,CAAC,MAAM,CAAC;IAChD,qEAAqE;IACpD,IAAI,CAAC,EAAE,cAAc,YAAA;IAGvC,iEAAiE;IACjE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,GAAG,iBAAiB,CAAC;IAKxD;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC;IAMpC,gDAAgD;IAChD,MAAM,IAAI,OAAO,EAAE,GAAG,iBAAiB;CASvC;AAED,uFAAuF;AACvF,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,iBAAiB,GAAG,YAAY,CAAC;AAEtE;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,UAAU,EAAE,GAAG,SAAS,CAAC,YAAY,CAAC,CAmBtH;AA4BD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,UAAU,EAAE,GAAG,OAAO,CAE/F"}
|
|
@@ -3,78 +3,132 @@ import { isUnknown, known } from './outcome.js';
|
|
|
3
3
|
export function isUnknownElement(element) {
|
|
4
4
|
return typeof element === 'function';
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/** An element of an array that the array may lack, and why it may. */
|
|
7
|
+
export class OptionalElement {
|
|
8
|
+
element;
|
|
9
|
+
reason;
|
|
10
|
+
constructor(element, reason) {
|
|
11
|
+
this.element = element;
|
|
12
|
+
this.reason = reason;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** The element listed, as it is where the array has it. */
|
|
16
|
+
export function listedElement(listed) {
|
|
17
|
+
return listed instanceof OptionalElement ? listed.element : listed;
|
|
18
|
+
}
|
|
19
|
+
/** An element in the place of one listed, which an array lacks where it lacks that one. */
|
|
20
|
+
export function inPlaceOf(listed, element) {
|
|
21
|
+
return listed instanceof OptionalElement ? new OptionalElement(element, listed.reason) : element;
|
|
8
22
|
}
|
|
9
23
|
/**
|
|
10
|
-
* An array some of
|
|
11
|
-
* request header
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
24
|
+
* An array known in part while evaluating: some of its elements are unknown,
|
|
25
|
+
* as a request header's value that Worker context lacks, or it may lack some,
|
|
26
|
+
* as filter() may keep an element or not, or hold some it does not list, as a
|
|
27
|
+
* request header list that may be cut. What it lists is surely in order only
|
|
28
|
+
* before any element it does not list. Its known elements can still settle
|
|
29
|
+
* any() and all(), has_value(), and an index whose position is certain, and
|
|
30
|
+
* mapped calls, concat() and filter() keep them; anything else that reads the
|
|
31
|
+
* whole array is unknown. Arrays from one list still line up; see
|
|
32
|
+
* pairArrays().
|
|
17
33
|
*/
|
|
18
34
|
export class PartialArrayValue {
|
|
19
35
|
elements;
|
|
20
36
|
more;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
|
|
37
|
+
moreFrom;
|
|
38
|
+
/** How many elements the array surely has. */
|
|
39
|
+
shortest;
|
|
40
|
+
/** How many elements at its start have certain positions. */
|
|
41
|
+
leading;
|
|
42
|
+
/** Why the array's length is unknown, when it is, and so are its positions past the leading ones. */
|
|
43
|
+
unknownLength;
|
|
44
|
+
constructor(elements,
|
|
45
|
+
/** Why the array may hold elements it does not list, when it may. */
|
|
46
|
+
more,
|
|
47
|
+
/** How many of the elements listed come before any that is not. */
|
|
48
|
+
moreFrom) {
|
|
28
49
|
this.elements = elements;
|
|
29
50
|
this.more = more;
|
|
30
|
-
this.
|
|
31
|
-
|
|
51
|
+
this.moreFrom = moreFrom;
|
|
52
|
+
let optional = 0;
|
|
53
|
+
let leading = moreFrom;
|
|
54
|
+
let unknownLength = more;
|
|
55
|
+
for (let index = 0; index < elements.length; index++) {
|
|
56
|
+
const listed = elements[index];
|
|
57
|
+
if (!(listed instanceof OptionalElement))
|
|
58
|
+
continue;
|
|
59
|
+
optional++;
|
|
60
|
+
if (index < leading) {
|
|
61
|
+
leading = index;
|
|
62
|
+
unknownLength = listed.reason;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
this.shortest = elements.length - optional;
|
|
66
|
+
this.leading = leading;
|
|
67
|
+
this.unknownLength = unknownLength;
|
|
32
68
|
}
|
|
33
69
|
/**
|
|
34
|
-
* An array of elements,
|
|
35
|
-
*
|
|
36
|
-
* conditions over a collection that may end early, `optional` lists them.
|
|
70
|
+
* An array of elements, known in part when one is unknown or may be lacking,
|
|
71
|
+
* or when it may hold `more`, which then come after the first `moreFrom`.
|
|
37
72
|
*/
|
|
38
|
-
static from(elements, more,
|
|
73
|
+
static from(elements, more, moreFrom = 0) {
|
|
74
|
+
if (more)
|
|
75
|
+
return new PartialArrayValue(elements, more, moreFrom);
|
|
39
76
|
const values = [];
|
|
40
|
-
for (const
|
|
41
|
-
if (isUnknownElement(
|
|
42
|
-
return new PartialArrayValue(elements,
|
|
43
|
-
values.push(
|
|
77
|
+
for (const listed of elements) {
|
|
78
|
+
if (listed instanceof OptionalElement || isUnknownElement(listed))
|
|
79
|
+
return new PartialArrayValue(elements, undefined, elements.length);
|
|
80
|
+
values.push(listed.value);
|
|
44
81
|
}
|
|
45
|
-
return
|
|
82
|
+
return values;
|
|
46
83
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Why the array may hold a matching element besides its known ones: its
|
|
49
|
-
* first unknown element, or that it may hold more, unless it may hold only
|
|
50
|
-
* optional elements, none of which match.
|
|
51
|
-
*/
|
|
84
|
+
/** Why the array may hold a matching element besides the known ones it surely has, when it may. */
|
|
52
85
|
unknownMatch(matches) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
for (const element of this.optional) {
|
|
86
|
+
for (const listed of this.elements) {
|
|
87
|
+
const element = listedElement(listed);
|
|
56
88
|
if (isUnknownElement(element))
|
|
57
89
|
return element;
|
|
58
|
-
if (matches(element.value))
|
|
59
|
-
return
|
|
90
|
+
if (listed instanceof OptionalElement && matches(element.value))
|
|
91
|
+
return listed.reason;
|
|
60
92
|
}
|
|
61
|
-
return
|
|
93
|
+
return this.more;
|
|
62
94
|
}
|
|
63
|
-
/** Why the whole array is unknown
|
|
95
|
+
/** Why the whole array is unknown. */
|
|
64
96
|
unknown() {
|
|
65
|
-
return this.firstUnknown();
|
|
97
|
+
return this.firstUnknown()();
|
|
66
98
|
}
|
|
67
|
-
/** The
|
|
99
|
+
/** The first reason why the array is not known whole. */
|
|
100
|
+
firstUnknown() {
|
|
101
|
+
for (const listed of this.elements) {
|
|
102
|
+
if (listed instanceof OptionalElement)
|
|
103
|
+
return listed.reason;
|
|
104
|
+
if (isUnknownElement(listed))
|
|
105
|
+
return listed;
|
|
106
|
+
}
|
|
107
|
+
return this.more;
|
|
108
|
+
}
|
|
109
|
+
/** The array without the elements it may lack, as ones it does not list. */
|
|
110
|
+
withoutOptional() {
|
|
111
|
+
if (this.shortest === this.elements.length)
|
|
112
|
+
return this;
|
|
113
|
+
return new PartialArrayValue(this.elements.filter(listed => !(listed instanceof OptionalElement)), this.unknownLength, this.leading);
|
|
114
|
+
}
|
|
115
|
+
/** The values of the known elements the array surely has. */
|
|
68
116
|
knownValues() {
|
|
69
|
-
const values =
|
|
70
|
-
|
|
117
|
+
const values = [];
|
|
118
|
+
for (const listed of this.elements) {
|
|
119
|
+
if (!(listed instanceof OptionalElement || isUnknownElement(listed)))
|
|
120
|
+
values.push(listed.value);
|
|
121
|
+
}
|
|
122
|
+
return values;
|
|
71
123
|
}
|
|
72
124
|
/** The element at an index, nil past the end. */
|
|
73
125
|
at(index) {
|
|
74
|
-
if (this.more)
|
|
75
|
-
return
|
|
76
|
-
|
|
77
|
-
|
|
126
|
+
if (index >= this.elements.length && !this.more)
|
|
127
|
+
return known(null);
|
|
128
|
+
if (index >= this.leading)
|
|
129
|
+
return this.unknownLength();
|
|
130
|
+
const element = listedElement(this.elements[index]);
|
|
131
|
+
return isUnknownElement(element) ? element() : element;
|
|
78
132
|
}
|
|
79
133
|
}
|
|
80
134
|
/**
|
|
@@ -136,7 +190,7 @@ export class RuleMapValue {
|
|
|
136
190
|
if (isUnknownElement(value))
|
|
137
191
|
return value;
|
|
138
192
|
// As one element, values known in part are unknown, and may stand for any number of values.
|
|
139
|
-
return value.value instanceof PartialArrayValue ? value.value.
|
|
193
|
+
return value.value instanceof PartialArrayValue ? value.value.firstUnknown() : known(value.value ?? []);
|
|
140
194
|
});
|
|
141
195
|
return PartialArrayValue.from(elements, this.more);
|
|
142
196
|
}
|
|
@@ -175,16 +229,33 @@ export function applyRuntimeAccessPath(value, accessPath) {
|
|
|
175
229
|
}
|
|
176
230
|
/**
|
|
177
231
|
* Applies the access after a `[*]` to each element. An unknown element can
|
|
178
|
-
* give any number of results, so with access after it,
|
|
232
|
+
* give any number of results, so with access after it, its results are not
|
|
233
|
+
* listed.
|
|
179
234
|
*/
|
|
180
235
|
function applyExpandedAccess(array, rest) {
|
|
181
236
|
if (!(array instanceof PartialArrayValue))
|
|
182
237
|
return applyArrayAccessPath(array, rest, true);
|
|
183
238
|
if (rest.length === 0)
|
|
184
239
|
return array;
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
240
|
+
const results = [];
|
|
241
|
+
let unknown;
|
|
242
|
+
let { moreFrom } = array;
|
|
243
|
+
let resultsFrom = 0;
|
|
244
|
+
array.elements.forEach((listed, index) => {
|
|
245
|
+
const element = listedElement(listed);
|
|
246
|
+
if (isUnknownElement(element)) {
|
|
247
|
+
unknown ??= element;
|
|
248
|
+
moreFrom = Math.min(moreFrom, index);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const values = applyArrayAccessPath([element.value], rest, true);
|
|
252
|
+
if (Array.isArray(values))
|
|
253
|
+
for (const value of values)
|
|
254
|
+
results.push(inPlaceOf(listed, known(value)));
|
|
255
|
+
if (index < moreFrom)
|
|
256
|
+
resultsFrom = results.length;
|
|
257
|
+
});
|
|
258
|
+
return PartialArrayValue.from(results, unknown ?? array.more, resultsFrom);
|
|
188
259
|
}
|
|
189
260
|
/**
|
|
190
261
|
* Applies postfix array access while preserving Cloudflare's vectorized `[*]`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access-values.js","sourceRoot":"","sources":["../../src/rule-evaluator/access-values.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,KAAK,EAA4C,MAAM,cAAc,CAAC;AAe1F,MAAM,UAAU,gBAAgB,CAAC,OAAsB;IACtD,OAAO,OAAO,OAAO,KAAK,UAAU,CAAC;AACtC,CAAC;AAED,
|
|
1
|
+
{"version":3,"file":"access-values.js","sourceRoot":"","sources":["../../src/rule-evaluator/access-values.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,KAAK,EAA4C,MAAM,cAAc,CAAC;AAe1F,MAAM,UAAU,gBAAgB,CAAC,OAAsB;IACtD,OAAO,OAAO,OAAO,KAAK,UAAU,CAAC;AACtC,CAAC;AAED,sEAAsE;AACtE,MAAM,OAAO,eAAe;IAEjB;IACA;IAFV,YACU,OAAqB,EACrB,MAAsB;QADtB,YAAO,GAAP,OAAO,CAAc;QACrB,WAAM,GAAN,MAAM,CAAgB;IAC7B,CAAC;CACJ;AAKD,2DAA2D;AAC3D,MAAM,UAAU,aAAa,CAAC,MAAoB;IACjD,OAAO,MAAM,YAAY,eAAe,CAAC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AAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACpG,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC"}
|
|
@@ -10,9 +10,15 @@ type Span = {
|
|
|
10
10
|
pos: number;
|
|
11
11
|
length: number;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* `unclosed` is set on a literal without its closing delimiter, which runs to
|
|
15
|
+
* the end of the input, so its text may hold what was meant to follow it. Its
|
|
16
|
+
* missing delimiter has its own error.
|
|
17
|
+
*/
|
|
13
18
|
export type StringLiteral = {
|
|
14
19
|
kind: 'StringLiteral';
|
|
15
20
|
value: string;
|
|
21
|
+
unclosed?: true;
|
|
16
22
|
} & Span;
|
|
17
23
|
/**
|
|
18
24
|
* `raw` keeps the literal as written, and `integer` its exact value, since
|