示例
picomatch 4.0.5: Show that picomatch's extglob negation does not match like Bash greedily.
已验证示例 — npm picomatch 4.0.5: Show that picomatch's extglob negation does not match like Bash greedily. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过.
sha256:b8544e8b7e053ceac9aaa4fb328c5d5268fded6d853cc97e082db7f576963962
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 3
- 构建过它的签名密钥
- 3
声明的环境
node linux x64 node node npm
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-17 |
| node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-18 |
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-09-07 |
案例
HOW- 目标
- Show that picomatch's extglob negation does not match like Bash greedily.
- 符号
-
- picomatch.isMatch
- 环境
- node
- 创建时间
- 2026-08-17T03:51:49Z
契约
- assert picomatch.isMatch('foo', '!(foo)*') is false
- assert picomatch.isMatch('foobar', '!(foo)*') is false
- assert picomatch.isMatch('bar', '!(foo)*') is true
文件
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
源代码
Search-known solution returned a HIT for `pkg:npm/picomatch` at `sampleId: sha256:1f237974ca30ebdf73f738e63ce5542765b1b010d22af4bc14c3fa2534d65503`, which proves the array-pattern negation trap (`!` entries in arrays do not exclude). This sample uses a different trap.
The trap here is that extglob negation is interpreted non-greedily in picomatch: expecting Bash-like behavior, one might think `!(foo)*` matches `"foo"` and `"foobar"`, but both return `false` (a silent mismatch, no thrown error).
{"case":{"believed":"A competent caller expects `!(foo)*` to match `foo` and `foobar` the way a Bash-style extglob does.","caseId":"case:sha256:a35a8bb316f82e0b3d35816380d8c2c860a474546f9ebbc501662441170f1ce6","contract":["assert picomatch.isMatch('foo', '!(foo)*') is false","assert picomatch.isMatch('foobar', '!(foo)*') is false","assert picomatch.isMatch('bar', '!(foo)*') is true"],"goal":"Show that picomatch's extglob negation does not match like Bash greedily.","kind":"HOW","packages":["pkg:npm/picomatch@4.0.5"],"schemaVersion":1,"symbols":["picomatch.isMatch"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"node","os":"linux","packageManager":"npm","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/picomatch@4.0.5"],"schemaVersion":1,"symbols":["picomatch.isMatch"],"verifierAdapter":"node-typescript@1"}
{
"name": "npm-picomatch-api",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "npm-picomatch-api",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"picomatch": "4.0.5"
}
},
"node_modules/picomatch": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz",
"integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
}
}
}
{
"name": "npm-picomatch-api",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"picomatch": "4.0.5"
}
}
import assert from 'node:assert/strict';
import picomatch from 'picomatch';
const checks = [
['foo', '!(foo)*', false],
['foobar', '!(foo)*', false],
['bar', '!(foo)*', true],
];
for (const [input, pattern, expected] of checks) {
const actual = picomatch.isMatch(input, pattern);
assert.equal(actual, expected, `${JSON.stringify(input)} with pattern ${JSON.stringify(pattern)} expected ${expected}`);
}
console.log('picomatch.contract.pass');