Repository navigation
roots: Build the accepted roots into a minified snippet for each zone - #70
Merged
Merged
Conversation
Rather than fetching each log's accepted roots at runtime, ACCEPTED_ROOTS in the source holds placeholders (the URLs of CTLogs' PEM bundles), which npm run build (tools/build.mjs) fetches and replaces with the hashes of the roots' subject names. So the snippet makes no subrequests besides forwarding, and works on any plan. logEnvironments entries are grouped by Cloudflare zone, in conditions on ZONE, and the build writes a snippet for each zone (ct.sectigo.com and ctlabs.sectigo.com), with only its logs and lists, and a generic one with no zone's. Each Sectigo log now has its accepted roots checked. The source moves to src/, and the minified snippets to dist/. --offline rebuilds them with the lists that they already have (as CI's tests do), and the minification workflow also runs hourly, to pick up changes to the lists. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CodeQL (js/incomplete-hostname-regexp) assumed that a placeholder URL in a logEnvironments entry could reach search(), which would compile a string as a regular expression; it can't, as only an entry's first element, which must be a RegExp, is used as its pattern. test() takes no string, so there's nothing to flag. It starts at lastIndex for a pattern with the g or y flag, so that's reset first, as search() did. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Merged
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.
What
Build-time roots lists.
ACCEPTED_ROOTSin the source holds placeholders: the URLs of the CTLogs PEM bundles, which are authoritative.npm run build(tools/build.mjs) fetches each bundle and replaces it with the sorted FNV-1a hashes of the roots' subject names, as a hex string. The snippet no longer fetches roots at runtime. Its only subrequest is the forward, so it fits every plan's subrequest limit and has no exposure to error 1201.rootsCacheSeconds, and the "CF_CTreq Accepted Roots v1" format, along with theroots-hashesscript.Every Sectigo log gets its roots checked:
sectigo: Monument, Statue, Elephant and Tiger (monument-ca-roots.pem)One snippet per zone.
logEnvironmentsentries are grouped in conditions onZONE. Terser (compress.passes: 2) removes the other zones' entries and lists.dist/cf_ctreq.ct.sectigo.com.min.jsdist/cf_ctreq.ctlabs.sectigo.com.min.jsdist/cf_ctreq.min.js(generic: no zone's logs)Layout. The source is now
src/cf_ctreq.js, and the generated snippets are indist/.Build and CI.
npm run build -- --offlinerebuilds with the lists the snippets already have; CI's test jobs use it.ACCEPTED_ROOTSorder.dist/and now also runs hourly, to pick up changes to the CTLogs bundles.Tests and docs.
dist/file matches the source.test:forwardingruns the local build for the log's zone.Testing
npm testandnpm run test:minifiedpass in all four environments.npm run test:differentialreports no false rejections, against both the source anddist/cf_ctreq.min.js.dist/files exactly.Before deploying
dist/cf_ctreq.ct.sectigo.com.min.jsanddist/cf_ctreq.ctlabs.sectigo.com.min.jsto their zones.test:resubmitagainst Standee and Dumbo, then against a production log once it's enabled there.get-rootsreturned 8 roots that aren't in the PEM bundle. Chains to those roots would be rejected until the logs are updated to match CTLogs.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com