샘플
marked 18.0.9: Render Markdown to HTML and understand what marked does not sanitize
검증된 샘플 — npm marked 18.0.9: Render Markdown to HTML and understand what marked does not sanitize. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다.
sha256:05053573db62da10e081ce38a9b23cbfc2efd0f85c6572af0ca81406f6177895
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 3
- 빌드한 서명 키
- 3
선언된 환경
node 22 linux x64 node 22 javascript npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-13 |
| 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:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-09-08 |
케이스
HOW- 목표
- Render Markdown to HTML and understand what marked does not sanitize
- 패키지
- 심벌
-
- marked.parse
- 환경
- node 22
- 생성일
- 2026-08-13T18:14:19Z
컨트랙트
- render common markdown constructs to HTML
- assert code fences carry their language class
- assert marked does NOT strip embedded HTML, so output is not safe by default
- assert async parsing is available for extensions
파일
- csx.json
- package-lock.json
- package.json
- src/index.mjs
- test/contract.mjs
소스
{"case":{"caseId":"case:sha256:dd13e5795ac96a399dbbbda1c1fc1af1dd2cb4d05e9b6d4f11656566558e97c8","constraints":{"moduleSystem":"esm","runtime":"node"},"contract":["render common markdown constructs to HTML","assert code fences carry their language class","assert marked does NOT strip embedded HTML, so output is not safe by default","assert async parsing is available for extensions"],"goal":"Render Markdown to HTML and understand what marked does not sanitize","kind":"HOW","packages":["pkg:npm/marked@18.0.9"],"schemaVersion":1,"symbols":["marked.parse"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"javascript","moduleSystem":"esm","os":"linux","packageManager":"npm","runtime":"node","runtimeVersion":"22","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/marked@18.0.9"],"schemaVersion":1,"symbols":["marked.parse"],"verifierAdapter":"node-typescript@1"}
{
"name": "csx-sample-marked-render-markdown",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "csx-sample-marked-render-markdown",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"marked": "18.0.9"
}
},
"node_modules/marked": {
"version": "18.0.9",
"resolved": "https://registry.npmjs.org/marked/-/marked-18.0.9.tgz",
"integrity": "sha512-/Sa4qiiHZxf0/FQdBBowr9q4r10krCwMvpK48FUBdXdUXScDxiQGR9zCPrFgRVR5LU3iySOiIjy09ZQvADir1w==",
"license": "MIT",
"bin": {
"marked": "bin/marked.js"
},
"engines": {
"node": ">= 20"
}
}
}
}
{
"name": "csx-sample-marked-render-markdown",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"marked": "18.0.9"
}
}
import { marked } from 'marked';
// marked removed its `sanitize` option: it renders Markdown, it is not an
// HTML sanitizer. Raw HTML in the input reaches the output verbatim, so
// untrusted markdown must go through a sanitizer (DOMPurify and friends)
// afterwards. Treating marked's output as safe is the most common way this
// package turns into an XSS hole.
export function render(md) {
return marked.parse(md, { async: false });
}
import { strict as assert } from 'node:assert';
import { render } from '../src/index.mjs';
const html = render('# Title\n\nSome **bold** text.\n\n```js\nconst a = 1;\n```\n');
assert.match(html, /<h1[^>]*>Title<\/h1>/);
assert.match(html, /<strong>bold<\/strong>/);
assert.match(html, /<code class="language-js">/);
// The part people get wrong: raw HTML passes straight through.
const raw = render('Hello <img src=x onerror="alert(1)">');
assert.ok(raw.includes('onerror'), 'marked does not sanitize; it never claimed to');
console.log('CONTRACT PASS: marked rendered markdown and left HTML untouched, as documented');