markdown-parity-check 0.2.32 → 0.2.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/SECURITY.md +1 -1
- package/dist/src/cli.d.ts +1 -1
- package/dist/src/fetch.js +8 -4
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,10 +78,10 @@ A value that is outside these ranges, or that is not a plain run of digits, stop
|
|
|
78
78
|
|
|
79
79
|
### Example output
|
|
80
80
|
|
|
81
|
-
This is the text report for the matching fixture pair in this repository, run with version 0.2.
|
|
81
|
+
This is the text report for the matching fixture pair in this repository, run with version 0.2.33 on 2026-11-05. The exact command is in the Development section below. The text report ends with a list of limitations, which is omitted here:
|
|
82
82
|
|
|
83
83
|
```text
|
|
84
|
-
markdown-parity-check 0.2.
|
|
84
|
+
markdown-parity-check 0.2.33 (offline mode)
|
|
85
85
|
Result: PASS (0 error(s), 0 warning(s), 1 info)
|
|
86
86
|
|
|
87
87
|
HTML: test/fixtures/same/page.html (file, 1,017 bytes, base https://example.com/page)
|
|
@@ -161,7 +161,7 @@ Some limits are not in the table:
|
|
|
161
161
|
- The tool sends `Accept-Encoding: gzip, deflate, br` and decodes responses with no Content-Encoding, `identity`, `gzip`, `x-gzip`, `deflate` or `br`. A response with any other Content-Encoding, `zstd` for example, is rejected, and the run ends with exit code 2.
|
|
162
162
|
- The command-line tool follows at most 5 redirects.
|
|
163
163
|
- When elements are nested more than 1024 levels deep, in the HTML page, in a raw HTML block written inside the Markdown or in the Markdown's own structure, the extraction stops with exit code 2.
|
|
164
|
-
- The matching stops the same way when more than 1 000 000 similar block pairs would have to be considered. The library `limits` default to the same two values.
|
|
164
|
+
- The matching stops the same way when more than 1 000 000 similar block pairs would have to be considered. The library `limits` default to the same two values for block pairs and similar block pairs. `maxSimilarityWork` has no default bound.
|
|
165
165
|
- The hosted page uses lower nesting and matching limits: 512 levels and 50 000 similar block pairs.
|
|
166
166
|
|
|
167
167
|
A hosted check can fail on turva.dev's own pages as well. On 2026-09-11 the check of https://turva.dev/tools returned `fail` with five errors. The Markdown carries a Related heading and four links that the HTML page leaves out, and the report listed each of them. The same four targets are links inside that page's tool cards, so the report found a missing structure and not missing content. The page passed again on 2026-10-02. [HTML and Markdown can disagree](https://turva.dev/blog/html-and-markdown-can-disagree) reads that result in full.
|
|
@@ -199,7 +199,7 @@ The options type is `RunOptions`. It takes `selector`, `frontMatter`, `strict`,
|
|
|
199
199
|
|
|
200
200
|
When the Markdown source has `kind: 'url'` in its `meta`, the delivery check runs first and reads the HTTP `status` and `contentType` from that `meta`.
|
|
201
201
|
|
|
202
|
-
A host with a smaller CPU or memory budget can pass lower `limits`, typed as `RunLimits`: `maxAlignmentPairs`, `maxSimilarityCandidates`, `maxSimilarityWork` and `maxNestingDepth`. The nesting limit also applies to raw HTML blocks inside the Markdown.
|
|
202
|
+
A host with a smaller CPU or memory budget can pass lower `limits`, typed as `RunLimits`: `maxAlignmentPairs`, `maxSimilarityCandidates`, `maxSimilarityWork` and `maxNestingDepth`. The nesting limit also applies to raw HTML blocks inside the Markdown. Set `maxSimilarityWork` when the library compares untrusted documents: with the default limits one measured worst case at the full 4 000 000 block pairs took between 26 and 30 seconds, and a value of 2 000 000 made the pairing step stop after about 70 milliseconds, on top of the parse time. `align` and `compare` throw an `AlignmentLimitError` there, and `run` turns it into a `RunError` with the same message.
|
|
203
203
|
|
|
204
204
|
The caller fetches the pages and decides which addresses are allowed. The address policy the command applies is exported as `assertPublicHost` and `isPublicAddress`.
|
|
205
205
|
|
|
@@ -245,10 +245,10 @@ Only after that check does it create the GitHub release with the verified tarbal
|
|
|
245
245
|
GitHub Actions publishes every version from 0.1.2 on with npm trusted publishing, and each one carries a provenance attestation. To check one, install it in an empty directory and ask npm to verify the signatures. Replace the version with the one you want to check.
|
|
246
246
|
|
|
247
247
|
```sh
|
|
248
|
-
mkdir verify-mpc && cd verify-mpc && npm init -y && npm install markdown-parity-check@0.2.
|
|
248
|
+
mkdir verify-mpc && cd verify-mpc && npm init -y && npm install markdown-parity-check@0.2.33 --ignore-scripts && npm audit signatures
|
|
249
249
|
```
|
|
250
250
|
|
|
251
|
-
`npm audit signatures` checks the registry signature and the provenance attestation of each installed package that has one. The attestation of this package names three things to compare with what you expect: the repository `github.com/erekola/markdown-parity-check`, the workflow file `.github/workflows/release.yml` and the commit that produced the tarball. The npm version page shows them under Provenance. Tag `v0.2.
|
|
251
|
+
`npm audit signatures` checks the registry signature and the provenance attestation of each installed package that has one. The attestation of this package names three things to compare with what you expect: the repository `github.com/erekola/markdown-parity-check`, the workflow file `.github/workflows/release.yml` and the commit that produced the tarball. The npm version page shows them under Provenance. Tag `v0.2.33` must point at that same commit, and `gh api repos/erekola/markdown-parity-check/commits/v0.2.33 --jq .sha` prints it. A mismatch is a reason not to use that version. Provenance proves which workflow built a release and from which commit. It does not prove that the code is safe, so reading the source and the dependencies stays your job.
|
|
252
252
|
|
|
253
253
|
## Security
|
|
254
254
|
|
package/SECURITY.md
CHANGED
|
@@ -14,7 +14,7 @@ Please do not open a public issue for security reports. You can expect an initia
|
|
|
14
14
|
|
|
15
15
|
URL mode requests HTML and Markdown over HTTP or HTTPS. Non-public network targets are blocked, including targets reached through DNS and redirects. Each fetch has a deadline and a limit on decoded response bytes. The defaults are 15 seconds and 5 MiB. In the command line the same deadline also covers parsing and comparison, which run in a worker thread that is stopped when the deadline passes, and the tool then exits with code 2. The library entry point has no such deadline, so a program that compares untrusted documents with it needs a time limit of its own. JavaScript from fetched pages is not executed.
|
|
16
16
|
|
|
17
|
-
The
|
|
17
|
+
The number of block pairs is bounded by the product of the two block counts, at most 4 000 000. The time spent on each pair is not: the similarity search walks the distinct words of the HTML block once per pair, so the work grows with block pairs times distinct words per HTML block. One measured case, 100 HTML blocks of 870 distinct words each against 40 000 Markdown blocks of one word each, which is 4 000 000 pairs, took between 26 and 30 seconds with default limits on development machines, in two measurements by two people. The command line stops such a run at its deadline. The number of similar block pairs kept for matching is bounded as well. Above either limit the tool stops with exit code 2 and an error message instead of reporting a pass for a comparison it did not complete. The pairing of links inside one block is not separately bounded by default: with the default limits it has no budget of its own, and a block with thousands of links that cannot be resolved against a base URL can take time that grows with the square of the link count. The maxSimilarityWork limit is unbounded by default and covers both cases, so a library caller that compares untrusted documents should set it. In the case above, a limit of 2 000 000 made the pairing step stop after about 70 milliseconds, on top of the time spent parsing the two documents, and the whole call took under one second. The comparison functions `align` and `compare` throw an `AlignmentLimitError` there, while `run` turns it into a `RunError` with the same message, which the command line reports with exit code 2.
|
|
18
18
|
|
|
19
19
|
Offline mode reads the two files supplied by the caller. The output option writes a report to the selected path. Reports mask URL query values and fragments and remove any user name or password from a URL. Excerpts may contain private page content. Review reports before sharing them.
|
|
20
20
|
|
package/dist/src/cli.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { type FetchOptions, type FetchResult } from './fetch.js';
|
|
3
|
-
export declare const HELP = "markdown-parity-check 0.2.
|
|
3
|
+
export declare const HELP = "markdown-parity-check 0.2.33\nCompares the main content of a web page's HTML and Markdown representations and reports concrete\nmissing, added and changed blocks.\n\nUsage:\n markdown-parity-check --url <https://example.com/page> [--markdown-url <url>] [options]\n markdown-parity-check --html-file <page.html> --markdown-file <page.md> [--base-url <url>] [options]\n\nModes:\n --url <url> Fetch <url> twice: with Accept: text/html and with Accept: text/markdown.\n --markdown-url <url> Fetch the Markdown from this explicit address instead (requires --url).\n --html-file <path> Offline: local HTML file (requires --markdown-file).\n --markdown-file <path> Offline: local Markdown file (requires --html-file).\n --base-url <url> Offline: base for resolving relative links on both sides.\n\nOptions:\n --html-profile generic|starlight\n HTML extraction rules (default: generic). Starlight includes inactive tab panels.\n --selector <css> CSS selector for the HTML main content (default: main, article, [role=main], then body).\n --front-matter keep|strip\n Markdown front matter. keep (default) removes nothing and warns when the document\n starts with a YAML-looking fenced block; strip removes that leading block.\n --format text|json Report format (default: text).\n --output <path> Write the report to a file instead of stdout. Refuses to overwrite an input file.\n --timeout-ms <n> Timeout in milliseconds for each fetch and for the parse-and-compare step\n (default: 15000). When it runs out the exit code is 2.\n --max-bytes <n> Cap on decoded response bytes per fetch (default: 5242880).\n --strict Treat warnings as rejecting findings too.\n --help, -h Show this help.\n --version, -V Show the version.\n\nExit codes:\n 0 comparison completed, no rejecting finding\n 1 comparison completed, rejecting content or delivery differences found\n 2 input, fetch, parse or report error prevented a reliable comparison\n\nOnly http(s) URLs to public addresses are fetched; loopback, private, link-local and other non-public\naddresses are refused, also behind DNS and redirects. No JavaScript is executed. Exit 0 does not prove\nsemantic equivalence.\n";
|
|
4
4
|
export declare class CliError extends Error {
|
|
5
5
|
}
|
|
6
6
|
export interface CliArgs {
|
package/dist/src/fetch.js
CHANGED
|
@@ -8,6 +8,7 @@ import dns from 'node:dns';
|
|
|
8
8
|
import zlib from 'node:zlib';
|
|
9
9
|
import { assertPublicHost, assertPublicResolved, BlockedAddressError } from './netguard.js';
|
|
10
10
|
import { maskUrl, redactText } from './normalize.js';
|
|
11
|
+
import { TOOL_NAME, TOOL_VERSION } from './version.js';
|
|
11
12
|
export class FetchError extends Error {
|
|
12
13
|
kind;
|
|
13
14
|
url;
|
|
@@ -133,8 +134,11 @@ class Deadline {
|
|
|
133
134
|
if (this.expired)
|
|
134
135
|
req.destroy(this.error);
|
|
135
136
|
}
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
/** Forgets the request only if it is still the active one. The close event of a redirect hop fires after the
|
|
138
|
+
* next hop was attached, so an unconditional reset left the next hop outside the deadline. */
|
|
139
|
+
detach(req) {
|
|
140
|
+
if (this.active === req)
|
|
141
|
+
this.active = null;
|
|
138
142
|
}
|
|
139
143
|
/** Races a promise against the deadline. */
|
|
140
144
|
race(p) {
|
|
@@ -175,7 +179,7 @@ function requestOnce(url, address, options, deadline) {
|
|
|
175
179
|
headers: {
|
|
176
180
|
Accept: options.accept,
|
|
177
181
|
'Accept-Encoding': 'gzip, deflate, br',
|
|
178
|
-
'User-Agent': options.userAgent ??
|
|
182
|
+
'User-Agent': options.userAgent ?? `${TOOL_NAME}/${TOOL_VERSION} (+local content comparison)`,
|
|
179
183
|
},
|
|
180
184
|
// Explicit default: TLS verification is never disabled.
|
|
181
185
|
rejectUnauthorized: true,
|
|
@@ -245,7 +249,7 @@ function requestOnce(url, address, options, deadline) {
|
|
|
245
249
|
else
|
|
246
250
|
reject(new FetchError('network', url.href, err.message));
|
|
247
251
|
});
|
|
248
|
-
req.on('close', () => deadline.detach());
|
|
252
|
+
req.on('close', () => deadline.detach(req));
|
|
249
253
|
deadline.attach(req);
|
|
250
254
|
req.end();
|
|
251
255
|
});
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const TOOL_NAME = "markdown-parity-check";
|
|
2
|
-
export declare const TOOL_VERSION = "0.2.
|
|
2
|
+
export declare const TOOL_VERSION = "0.2.33";
|
package/dist/src/version.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
// Cloudflare Worker as well as under Node.js. test/version.test.ts fails the build when these differ
|
|
3
3
|
// from package.json, which stays the version the release workflow publishes.
|
|
4
4
|
export const TOOL_NAME = 'markdown-parity-check';
|
|
5
|
-
export const TOOL_VERSION = '0.2.
|
|
5
|
+
export const TOOL_VERSION = '0.2.33';
|
package/package.json
CHANGED