Artifactspublic-v0

ply

main
ply4 git calls374 ms41 KiB1 cachedprotocol v2
95 lines10 KiBRaw
1// The checked inventory of every regular expression under src/ (scripts/regex-gate.mjs explains the rules).
2//
3// One row per (file, pattern text). `input` is the most hostile text the call sites hand the pattern:
4// remote bytes a server sent (advertisements, reports, error text, redirect targets)
5// stored repository or cached content read back (objects, .git files, saved indexes): untrusted too
6// caller an argument of the public API
7// internal a constant of this library
8// `linear` says why matching costs time linear in the input. `adversarial(n)` builds about n characters of the input
9// that makes the pattern work hardest (the longest run it can consume, then a character that makes it fail);
10// test/regex-linear.test.js times it at n, 2n and 4n. `op` is how the call site applies the pattern (exec by default).
11// `knownBad` names where the fix is: the gate lists the row instead of refusing it, the ratio test asserts the
12// generator really is superlinear, and the row fails the gate once the pattern is gone from the source.
13const rep = (s, n) => s.repeat(Math.max(1, Math.floor(n / s.length)));
14const run = (ch, tail = '!') => n => ch.repeat(n) + tail;
15const row = (file, pattern, input, linear, adversarial, more = {}) => ({ file, pattern, input, linear, adversarial, ...more });
16const ONE_START = 'anchored at ^: one start, one character class run, then a single failure';
17const NO_RUN = 'no quantifier above {0,1}: a bounded number of steps at each start';
18const FIXED = 'anchored at ^ with a fixed repeat count: at most that many steps';
20export const INVENTORY = [
21 row('src/attributes.ts', String.raw`/^[-A-Za-z0-9_.]+$/u`, 'stored', ONE_START, run('a')),
22 row('src/caps.ts', String.raw`/[ \t\n\v\f\r]+/`, 'remote', 'split: each run is consumed once and nothing follows it that can fail', n => rep(' '.repeat(63) + 'x', n), { op: 'split' }),
23 row('src/caps.ts', String.raw`/\n$/`, 'remote', NO_RUN, run('\n', 'x'), { op: 'replace' }),
24 row('src/changes.ts', String.raw`/^[0-9a-fA-F]{40}$/u`, 'caller', FIXED, run('a', '')),
25 row('src/checkout.ts', String.raw`/^[1-7][0-7]*$/`, 'stored', ONE_START, run('1', '9')),
26 row('src/edit.ts', String.raw`/^[0-9a-fA-F]{40}$/u`, 'caller', FIXED, run('a', '')),
27 row('src/errors.ts', String.raw`/[\p{Cc}\p{Cf}\p{Cs}\p{Zl}\p{Zp}]/gu`, 'remote',
28 'one character class and no quantifier: one step at each start; the global replaceAll never revisits a match, and its callback writes one fixed-size escape for each',
29 n => rep('‮\u{E0001}', n), { op: 'replace' }),
30 row('src/fetch.ts', String.raw`/\n$/`, 'remote', NO_RUN, run('\n', 'x'), { op: 'replace' }),
31 row('src/fetch.ts', String.raw`/only blob:none is supported|unsupported (git )?fetch filter/i`, 'remote',
32 'fixed phrases, one optional fixed group, no run: a bounded number of steps at each start', n => rep('unsupported git fetch filte', n)),
33 row('src/fetch.ts', String.raw`/filter ([^\n\r\u2028\u2029]*)/gi`, 'remote',
34 'the run takes the rest of the line and nothing after it can fail; a global scan resumes past each match, so no character is read twice (ply#274)',
35 n => rep('filter ', n), { op: 'replace' }),
36 row('src/fetch.ts', String.raw`/ not (supported|allowed)/i`, 'remote', NO_RUN, n => rep(' not supporte', n)),
37 row('src/http.ts', String.raw`/^[0-9A-Za-z._-]+$/`, 'caller', ONE_START, run('a', ' ')),
38 row('src/http.ts', String.raw`/%([0-9a-f]{2})/gi`, 'caller', 'three characters at most per start, and a global replace never revisits a match', n => rep('%4', n), { op: 'replace' }),
39 row('src/http.ts', String.raw`/[\0\r\n]/`, 'caller', NO_RUN, run('a', '')),
40 row('src/http.ts', String.raw`/^[a-z][a-z0-9+.-]*:\/\/[^/?#\\]*@/i`, 'caller', 'anchored at ^; the scheme run ends at ":" (not in its class), the authority run backtracks once for "@"', n => `a://${'a'.repeat(n)}/`),
41 row('src/http.ts', String.raw`/^[\t -~]+$/`, 'caller', ONE_START, run('a', '\0')),
42 row('src/http.ts', String.raw`/\/$/`, 'remote', NO_RUN, run('/', 'x'), { op: 'replace', count: 3 }),
43 row('src/http.ts', String.raw`/^Basic\s/i`, 'caller', 'anchored at ^, no run', n => `Basic${' '.repeat(n)}`),
44 row('src/http.ts', String.raw`/^Basic\s+/i`, 'caller', 'anchored at ^, one run, nothing after it that can fail', n => `Basic${' '.repeat(n)}`, { op: 'replace' }),
45 row('src/http.ts', String.raw`/^\S+\s+/`, 'caller', 'anchored at ^; \\S and \\s are disjoint, so the first run backtracks once', run('a', ''), { op: 'replace' }),
46 row('src/lsrefs.ts', 'new RegExp(`^[0-9a-fA-F]{${SHA256_HEX_CHARS}}$`)', 'remote', FIXED, run('a', ''), { build: () => /^[0-9a-fA-F]{64}$/ }),
47 row('src/merge.ts', String.raw`/\n?$/u`, 'caller', NO_RUN, run('\n', 'x'), { op: 'replace' }),
48 row('src/mergeio.ts', String.raw`/^refs\/heads\//u`, 'caller', 'anchored at ^, a literal', n => rep('refs/heads/', n), { op: 'replace' }),
49 row('src/objects.ts', String.raw`/^[0-9]$/u`, 'stored', 'anchored at ^, one character', run('1', '')),
50 row('src/objects.ts', String.raw`/\s+/u`, 'stored', 'split: each run is consumed once and nothing follows it that can fail', n => rep(' '.repeat(63) + 'x', n), { op: 'split' }),
51 row('src/objects.ts', String.raw`/^\d+$/u`, 'stored', ONE_START, run('1', 'x')),
52 row('src/objects.ts', String.raw`/[\0\n]/u`, 'caller', NO_RUN, run('a', '')),
53 row('src/packindex.ts', String.raw`/^[0-9a-f]{40}$/u`, 'stored', FIXED, run('a', '')),
54 row('src/packrangeresolve.ts', String.raw`/^[0-9a-f]{40}$/u`, 'caller', FIXED, run('a', '')),
55 row('src/packsaved.ts', String.raw`/^[0-9a-f]{40}$/u`, 'stored', FIXED, run('a', '')),
56 row('src/packsubset.ts', String.raw`/^[0-9a-f]{40}$/u`, 'caller', FIXED, run('a', '')),
57 row('src/push.ts', String.raw`/ .*/u`, 'internal', 'applied to the UA constant; nothing follows the run that can fail', undefined, { count: 2 }),
58 row('src/push.ts', String.raw`/^[ -~]+$/u`, 'remote', ONE_START, run('a', '\0')),
59 row('src/push.ts', String.raw`/^[0-9]{1,9}$|^[0-9]{1,9}[.][0-9]{1,6}$/u`, 'remote',
60 'each alternative is anchored at ^, every repeat is bounded and a required "." separates the two digit runs: at most 16 characters are read, whatever the length', n => `${'1'.repeat(9)}.${'1'.repeat(n)}`),
61 row('src/push.ts', String.raw`/^(failed to lock|stale ref)$|fetch first|non-fast-forward|already exists/u`, 'remote', 'literal alternatives: at most the longest literal at each start', n => rep('fetch firs', n)),
62 row('src/push.ts', String.raw`/\r?\n|\r/u`, 'remote', NO_RUN, run('\r', ''), { op: 'split' }),
63 row('src/push.ts', String.raw`/\n$/u`, 'remote', NO_RUN, run('\n', 'x'), { op: 'replace' }),
64 row('src/read.ts', String.raw`/^[0-9a-f]{40}$/`, 'caller', FIXED, run('a', '')),
65 row('src/read.ts', String.raw`/^[0-9a-f]{4,39}$/`, 'caller', FIXED, run('a', '')),
66 row('src/read.ts', String.raw`/^gpgsig(-sha256)? /`, 'stored', 'anchored at ^, literals only', n => rep('gpgsig-sha256', n)),
67 row('src/read.ts', String.raw`/\/$/`, 'caller', NO_RUN, run('/', 'x'), { op: 'replace' }),
68 row('src/receivecaps.ts', 'new RegExp(`^[0-9a-f]{${n}} [^ ]`, \'u\')', 'remote', FIXED, run('a', ''), { build: () => /^[0-9a-f]{40} [^ ]/u }),
69 row('src/receivecaps.ts', 'new RegExp(`^shallow [0-9a-f]{${n}}$`, \'u\')', 'remote', FIXED, n => `shallow ${'a'.repeat(n)}`, { build: () => /^shallow [0-9a-f]{40}$/u }),
70 row('src/receivecaps.ts', String.raw`/\n$/u`, 'remote', NO_RUN, run('\n', 'x'), { op: 'replace', count: 2 }),
71 row('src/repo-node.ts', String.raw`/^[0-9a-f]{40}$/u`, 'stored', FIXED, run('a', '')),
72 row('src/repo-node.ts', String.raw`/^gitdir: (.+)$/mu`, 'stored', '^ under m starts once per line and .+ cannot leave its line, which $ under m always accepts', n => rep('gitdir: \n', n)),
73 row('src/repo-node.ts', String.raw`/^\[([^\]\s"]+)(\s+"([^"]*)")?\]$/u`, 'stored', 'anchored at ^; the name, space and quoted runs are pairwise disjoint classes', n => `[a "${'b'.repeat(n)}`),
74 row('src/repo-node.ts', String.raw`/^([A-Za-z][\w-]*)\s*(=\s*(\S[^\n\r\u2028\u2029]*|))?$/u`, 'stored', 'anchored at ^; name, \\s and \\S are disjoint, so each run has one place to end and backtracks once (ply#274)', n => `a=${' '.repeat(n)}x\ry`),
75 row('src/repo-node.ts', String.raw`/^([0-9a-f]{40}) (refs\/\S+)$/u`, 'stored', 'anchored at ^; one \\S run that backtracks once', n => `${'a'.repeat(40)} refs/${'a'.repeat(n)} x`),
76 row('src/repo-node.ts', String.raw`/^(commit|tree|blob|tag) (\d+)$/u`, 'stored', ONE_START, n => `blob ${'1'.repeat(n)}x`),
77 row('src/repo-node.ts', String.raw`/\s/u`, 'caller', NO_RUN, run('a', '')),
78 row('src/scrub.ts', String.raw`/[0-9]/u`, 'remote', NO_RUN, run('a', '')),
79 row('src/sign.ts', String.raw`/\n$/u`, 'caller', NO_RUN, run('\n', 'x'), { op: 'replace' }),
80 row('src/tree-node.ts', String.raw`/[\u0080-\u{10FFFF}]/u`, 'stored',
81 'one character class, no quantifier: one step at each start (a directory entry name read from the local file system)', run('a', '')),
82 row('src/tree-node.ts', String.raw`/[\u{10000}-\u{10FFFF}]/u`, 'stored',
83 'one character class, no quantifier: one step at each start (a directory entry name read from the local file system)', run('é', '')),
84 row('src/uprequest.ts', 'new RegExp(`^[0-9a-fA-F]{${OID_HEX_CHARS}}$`)', 'caller', FIXED, run('a', ''), { build: () => /^[0-9a-fA-F]{40}$/ }),
85 row('src/uprequest.ts', String.raw`/^[0-9]+$/`, 'caller', ONE_START, run('1', 'x')),
86 row('src/validate.ts', 'new RegExp(`^[+-][0-9]{${IDENT_TZ_DIGITS}}$`, \'u\')', 'caller', FIXED, n => `+${'1'.repeat(n)}`, { build: () => /^[+-][0-9]{4}$/u }),
87 row('src/validate.ts', String.raw`/[\0\n<>]/u`, 'caller', NO_RUN, run('a', '')),
88 row('src/validate.ts', String.raw`/[\0\r\n]/u`, 'caller', NO_RUN, run('a', '')),
89 row('src/validate.ts', String.raw`/[^\t\u0020-\u007E\u0080-\u00FF]|^[\t ]|[\t ]$/u`, 'caller', NO_RUN, run('a', '\u0001')),
90 row('src/validate.ts', String.raw`/[\0-\u001F\u007F ~^:?*[\\]|\.\.|@\{|\/\/|\/$|\.$|\.lock(\/|$)|^\/|\/\.|^\./u`, 'remote', 'alternatives of literals and single classes: at most six characters at each start', n => rep('.loc', n).replace(/^\./u, 'a')),
91 row('src/validate.ts', String.raw`/^\.gitmodules$/i`, 'stored', 'anchored at ^, a literal', n => rep('.gitmodules', n)),
92 row('src/validate.ts', String.raw`/[:<>"|?*\u0001-\u001F]/u`, 'stored', NO_RUN, run('a', '')),
93 row('src/validate.ts', String.raw`/[ .]$/u`, 'stored', NO_RUN, run(' ', 'x')),
94 row('src/validate.ts', String.raw`/^(aux|prn|nul|con|com[1-9]|lpt[0-9]|conin\$|conout\$) *([.:]|$)/i`, 'stored', 'anchored at ^; one run of spaces that backtracks once', n => `aux${' '.repeat(n)}x`),
95];
Diagnostics4 git calls · 374 ms
CallStatusSizeTime0374 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=5
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200145 B2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=145
git.response.cache=UPDATING
git.response.duration_ms=2
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=145
git.pkt.payload.max=76
git.ls_refs.count=2
git.ls_refs.head=refs/heads/main
fetchblob:none · deepen 1020038 KiB · hit6 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=365
git.response.bytes=38434
git.response.cache=HIT
git.response.duration_ms=6
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=19912563f540228593df0c489082e5e2508e21e4
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=6
git.pkt.data=4
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=38434
git.pkt.payload.max=38339
git.sideband.band1.bytes=38338
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=63
git.pack.bytes=38338
git.pack.ofs_delta=0
git.pack.ref_delta=8
git.pack.chain.max=8
git.pack.trailer=0bc36ab7adf82d3109177f11f1ea93f1ce071f77
git.pack.full=55
Open pack map
fetch2003.1 KiB365 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=3205
git.response.cache=MISS
git.response.duration_ms=365
git.fetch.wants=d64052e511fea36d3d45982d3736478407c1fa03
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=3205
git.pkt.payload.max=3184
git.sideband.band1.bytes=3183
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/ply.git
Ref
refs/heads/main
Commit
19912563f540228593df0c489082e5e2508e21e4
cf-ray
a5e224873aefa87d
Request
b8a2aeb5…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format