Ejemplo
chalk 6.0.0: Pinpoint Chalk's malformed `hex()` input behavior when nullish values and malformed strings are provided.
Muestra verificada para npm chalk 6.0.0: Pinpoint Chalk's malformed `hex()` input behavior when nullish values and malformed strings are provided. El…
sha256:8a0531ffe818e26b9036a49be7c8f41af3ee24f2802f62aa006deb0ac042b7dd
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
- 2
- Claves de firma que lo compilaron
- 2
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 |
Caso
HOW- Objetivo
- Pinpoint Chalk's malformed `hex()` input behavior when nullish values and malformed strings are provided.
- Paquetes
- Símbolos
-
- chalk.hex
- Entorno
- node
- Creado
- 2026-08-17T03:15:58Z
Contrato
- With `chalk.level = 3`, calling `chalk.hex('not-a-color')('x')` returns `x` wrapped in `\u001b[38;2;0;0;0m` and `\u001b[39m` and does not throw.
- `chalk.hex('')('x')` also returns black 24-bit ANSI output instead of an error.
- Nullish inputs are the only values that fail here: `chalk.hex(null)('x')` and `chalk.hex(undefined)('x')` throw TypeError while malformed strings do not.
Archivos
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
Código fuente
search_known_solution returned existing hits for Chalk level/ANSI behavior (`sha256:525f14e9ff41964b2cf8700329f042389c75335c2b13dc4d12796c1cbb8e0f28` and related downsample cases), so this sample uses a different trap: malformed `hex()` input handling.
For this trap, malformed non-null strings are silently treated as black ANSI output, while nullish values fail loudly with `TypeError`.
{"case":{"believed":"A caller should get the same kind of rejection for all obviously malformed `chalk.hex(...)` inputs.","caseId":"case:sha256:30b96d62fc271aaf7efafecd44b134b8098d22c74efb89b426d281b56e473b32","contract":["With `chalk.level = 3`, calling `chalk.hex('not-a-color')('x')` returns `x` wrapped in `\\u001b[38;2;0;0;0m` and `\\u001b[39m` and does not throw.","`chalk.hex('')('x')` also returns black 24-bit ANSI output instead of an error.","Nullish inputs are the only values that fail here: `chalk.hex(null)('x')` and `chalk.hex(undefined)('x')` throw TypeError while malformed strings do not."],"goal":"Pinpoint Chalk's malformed `hex()` input behavior when nullish values and malformed strings are provided.","kind":"HOW","packages":["pkg:npm/chalk@6.0.0"],"schemaVersion":1,"symbols":["chalk.hex"]},"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/chalk@6.0.0"],"schemaVersion":1,"symbols":["chalk.hex"],"verifierAdapter":"node-typescript@1"}
{
"name": "npm-chalk-d2",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "npm-chalk-d2",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"chalk": "6.0.0"
}
},
"node_modules/chalk": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-6.0.0.tgz",
"integrity": "sha512-2uNTXIuTTxk7ciZgAU1BQcgnchcG0xXnrs6jzkQfj9SsRa9M2s5zE8WT96hS6KmG4MzWHSrvH43DF1m4XRkrFg==",
"license": "MIT",
"engines": {
"node": ">=22"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
}
}
}
{
"name": "npm-chalk-d2",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"chalk": "6.0.0"
}
}
import assert from 'node:assert/strict';
import chalkPkg from 'chalk';
const chalk = chalkPkg.default ?? chalkPkg;
chalk.level = 3;
assert.equal(typeof chalk.hex, 'function');
assert.equal(
chalk.hex('not-a-color')('x'),
'\u001b[38;2;0;0;0m' + 'x' + '\u001b[39m'
);
assert.equal(
chalk.hex('')('x'),
'\u001b[38;2;0;0;0m' + 'x' + '\u001b[39m'
);
assert.throws(() => chalk.hex(null)('x'), {
name: 'TypeError',
message: /Cannot read properties of null/
});
assert.throws(() => chalk.hex(undefined)('x'), {
name: 'TypeError',
message: /Cannot read properties of undefined/
});