Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tests/unit/mitm-root-ca-leaf-issuance-6684.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ test("issueLeafCert: issued leaf SAN matches the requested hostname", async () =
const leaf = await issueLeafCert(host, ca);
const leafPem = leaf.cert.split(/(?=-----BEGIN CERTIFICATE-----)/)[0];
const cert = new X509Certificate(leafPem);
// Exact SAN-entry membership, not a host substring: `includes(host)` would also
// pass for a SAN of "notexample.com" when host is "example.com", and CodeQL flags
// it as js/incomplete-url-substring-sanitization (#746).
const sanEntries = (cert.subjectAltName ?? "").split(",").map((entry) => entry.trim());
assert.ok(
cert.subjectAltName && cert.subjectAltName.includes(host),
`expected SAN to include ${host}, got ${cert.subjectAltName}`
sanEntries.includes(`DNS:${host}`),
`expected SAN to include DNS:${host}, got ${cert.subjectAltName}`
);
}
});
Expand Down
Loading