CodeSampleX

Ejemplo

picomatch 4.0.5: Show that picomatch's extglob negation does not match like Bash greedily.

Muestra verificada para npm picomatch 4.0.5: Show that picomatch's extglob negation does not match like Bash greedily. El contrato se ejecutó en node 22 …

sha256:b8544e8b7e053ceac9aaa4fb328c5d5268fded6d853cc97e082db7f576963962

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
3
Claves de firma que lo compilaron
3
Entorno declarado node linux x64 node node npm

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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

Caso

HOW
Objetivo
Show that picomatch's extglob negation does not match like Bash greedily.
Paquetes
Símbolos
  • picomatch.isMatch
Entorno
node
Creado
2026-08-17T03:51:49Z

Contrato

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

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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');

Seeder de origen

csx-seed