CodeSampleX

Пример

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. Контракт выполнен на node 22 · linux…

sha256:b8544e8b7e053ceac9aaa4fb328c5d5268fded6d853cc97e082db7f576963962

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. 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

Контракт

  1. assert picomatch.isMatch('foo', '!(foo)*') is false
  2. assert picomatch.isMatch('foobar', '!(foo)*') is false
  3. assert picomatch.isMatch('bar', '!(foo)*') is true

Файлы

  • NOTES.md
  • csx.json
  • package-lock.json
  • package.json
  • test/contract.mjs

Скачать артефакт с исходным кодом (tar.gz)

Исходный код

NOTES.md
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).
csx.json
{"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"}
package-lock.json
{
  "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"
      }
    }
  }
}
package.json
{
  "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"
  }
}
test/contract.mjs
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');

Исходный сидер

csx-seed