Correct the documentation where it disagreed with the library - #219
Merged
Merged
Conversation
An audit of every documented claim against the built library. All 40 worked examples (18 in the README block, 22 JSDoc @example) already passed; the inaccuracies were in prose and in generated signatures. Generated signatures (scripts/build-readme.ts): - Six signatures declared required parameters that carry defaults, two of them contradicting their own prose in the same bullet ("The default prefix is the well-known prefix 64:ff9b::/96" beside a signature saying you must pass it). TypeDoc sets isOptional inconsistently for defaulted parameters, so treat a default as optional too. - TypeScript `this` annotations rendered as arguments, so `isInSubnet(address)` read as taking two. Filter them out, and route function-valued properties through the same parameter rules. Prose: - Address4.reverseForm() was documented as returning ip6.arpa form. It returns in-addr.arpa, as the @PARAM two lines below already said. - 6to4 embeds a 32-bit IPv4 address in bits 16-47, not "the second 16 bits". - "Parses all standard IPv4 and IPv6 notations" claimed more than the library does: the inet_aton forms are rejected by design, which SECURITY.md already says. - group() and groupForV6() return HTML and said nothing about it. These are the surfaces GHSA-v2v4-37r5-5v8g was about. - AddressError.parseMessage had no description at all, though GHSA-v2v4-37r5-5v8g describes rendering it as HTML as "its documented purpose". - Address4's byte-array methods documented neither their throw conditions nor that they reject the signed bytes Address6 folds. The 11.0.0 tripwire in test/common-test.ts owns settling that split; this only writes down where it stands. - isHostInSubnet pointed at {@link common.isHostInSubnet}, a module the reference doesn't cover. Inlined instead. - Weekly download figures were stale (~66M against 85.7M actual). Badges and source links now use main, which is the default branch, so they no longer lean on GitHub's renamed-branch redirect. test/readme-test.ts guards the generator fix: no signature may expose a `this` parameter, defaulted parameters must render optional, and the HTML-returning methods must say so. All three fail against the previous README.
beaugunderson
force-pushed
the
bg-doc-accuracy
branch
from
August 10, 2026 05:28
b4ad4bb to
b1d3df4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An audit of every documented claim against the built library, prompted by GHSA-mxvh-v779-f36j (#218), where
fromURLdid not do what its docs promised. The question was whether anything else lied.All 40 worked examples already passed — 18 assertions in the README example block, 22 JSDoc
@exampleblocks. So did every range claim, throw claim, and classifier-delegation claim I could execute. The provenance statement is exact (10.2.1 onward carry SLSA attestations, 10.2.0 does not), all four published advisories do carry CVEs, there really are zero runtime dependencies, and ESM named imports genuinely work. The inaccuracies were in prose and in generated signatures.Generated signatures
scripts/build-readme.tsrendered six signatures with required parameters that actually carry defaults:Two of them contradicted their own prose in the same bullet — "The default prefix is the well-known prefix
64:ff9b::/96" sat directly beside a signature saying you must pass it. TypeDoc setsisOptionalinconsistently for defaulted parameters (possibleSubnets.subnetSizegetsisOptional=true default="128",regularExpression.substringSearchgetsisOptional=false default="false"), so the generator now treats the presence of a default as optional too.Separately, TypeScript
thisannotations were rendering as arguments, soisInSubnet: (this: Address4 | Address6, address: Address4 | Address6) => booleanread as a two-argument call when callers pass one. Those are filtered out, and function-valued properties now route through the same parameter rules as methods rather than raw type stringification.Prose
Address4.reverseForm()was documented as returning ip6.arpa form. It returns in-addr.arpa — as the@paramtwo lines below in the same comment block already said. Copy-paste from the IPv6 method.The 6to4 terminology entry said the protocol "embeds an IPv4 address as the second 16 bits" of a
2002::/16address. An IPv4 address is 32 bits and occupies bits 16–47, i.e. the second and third groups:192.0.2.4becomes2002:c000:204::."Parses all standard IPv4 and IPv6 notations" claimed more than the library does, and contradicted SECURITY.md, which correctly notes that
2130706433,0x7f000001and127.1are all rejected. That rejection is deliberate and right; the Features bullet now says so instead of overstating.group()andgroupForV6()return HTML<span>markup and said nothing about it —group()'s entire description was "Groups an address". These are precisely the surfaces GHSA-v2v4-37r5-5v8g was about, so a reader who can't tell the output is markup can't reason about escaping it. Both now say what they return, and that the address content is escaped (verified: a hostile zone id comes back as<img src=x onerror=alert(1)>).AddressError.parseMessagehad no description whatsoever, rendering as a bareparseMessage: string. Meanwhile GHSA-v2v4-37r5-5v8g describes rendering it as HTML as "its documented purpose — it already contains<span class="parse-error">markup". The behavior is real; the documentation the advisory appealed to was not. Now documented.Address4's byte-array methods documented neither their throw conditions nor the fact that they reject the signed bytes
Address6.fromByteArrayfolds. The 11.0.0 tripwire intest/common-test.tsalready owns settling that split — in the direction of making v6 strict — so this only writes down where things stand and notes that the contracts converge.isHostInSubnetpointed readers at{@link common.isHostInSubnet}, a module the API reference doesn't cover, so the pointer went nowhere. The substance is inlined instead.The weekly download figures were stale: ~66M claimed against 85.7M actual, plus smaller drift on cacache (~44M → 40M) and socks-proxy-agent (~57M → 55M).
Badges and
[src]links now point atmain. There is nomasterbranch on the remote; those 129 links resolved only through GitHub's renamed-branch redirect.Tests
test/readme-test.tsguards the generator fix, since CI already checks the README is current but nothing checked it was correct: no signature may expose athisparameter, the six defaulted parameters must render optional, and the HTML-returning methods must mention HTML. All three assertions fail against the previous README (8 leakedthisparameters, 3 required-but-defaulted signatures).