Repository navigation
Add CI for pull requests, clear the sprintf-js Dependabot alert, fix coverage runs - #57
Merged
Merged
Conversation
toRegExp() and resolveAllowedConstant() are embedded in the code compile() generates through Function#toString(). When Istanbul instruments them, the text holds calls to coverage counters (`cov_xxx()`) that do not exist where the compiled code later runs, so four tests failed under `jest --coverage` (already the case on main). Shipped code is not affected: nothing instruments lib/. `istanbul ignore next` leaves the two functions as they are written. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Dependabot alert #89 (GHSA-hp3w-g68c-fv3c, DoS through unbounded precision in sprintf-js <= 1.1.3) has no patched release: 1.1.3 is the latest. The package is only reached by the test tooling, through jest > @jest/core > @jest/transform > babel-plugin-istanbul > @istanbuljs/load-nyc-config > js-yaml 3.x > argparse 1.x > sprintf-js, and js-yaml 4 (argparse 2) no longer depends on it. load-nyc-config only calls `require('js-yaml').load(...)` to read a .nycrc.yaml, which has the same meaning in js-yaml 4. Checked: the tests, a coverage run, loading a .nycrc.yaml through load-nyc-config, and both builds. The lockfile loses sprintf-js and esprima and changes only js-yaml and argparse. Nothing that ships is affected (`npm audit --omit=dev` was clean). Not addressed: braces <= 3.0.3 (GHSA-vfj7-8cjw-p6xm), which is also unpatched and comes from jest's own micromatch. GitHub auto-dismissed that alert (#88). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Until now the tests only ran when a release was published, so a pull request had no checks at all. The CI workflow runs on pull requests and on pushes to main: - Tests on Node 20, 22 and 24. - Tests with coverage: instrumented sources have to work too (this is what caught the functions compile() serialises with Function#toString()). - Build and smoke test of what is published, lib/ (Babel) and the minified browser bundle (scripts/smoke-build.cjs): the serialised functions only work while the build leaves them self-contained. - TypeScript definitions (`tsc --strict`; typescript is now a devDependency). - The PHP generated by dumpCompiled() evaluated by Symfony's own CompiledExpressionLanguage, against a Symfony commit pinned in the workflow, with the PHP of the runner. - `npm audit --omit=dev --audit-level=high`: the runtime dependencies only, as the development tools have advisories that no release fixes yet. - A final `CI` job aggregating the others, to require in branch protection. New npm scripts: test:coverage, test:types, test:build. The README's Contributing section lists them. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Summary
Three small, separate commits:
jest --coverage, which fails onmaintoday (4 tests).sprintf-js, #89) by movingjs-yamlto 4.x.1. Coverage runs were broken (already on
main)toRegExp()andresolveAllowedConstant()are serialised into the codecompile()generates withFunction#toString(). When Istanbul instruments them, the serialised text calls coverage counters (cov_xxx()) that don't exist where the compiled code later runs, sonpm test -- --coveragefailed 4 tests withReferenceError: cov_... is not defined. Shipped code is unaffected (nothing instrumentslib/). Anistanbul ignore nexthint on the two functions fixes it; coverage is now 96% statements / 91% branches.2. Dependabot
npm auditreports "34 vulnerabilities", but that is 2 advisories plus the 32 packages that depend on them. Both are in development tooling only;npm audit --omit=devis clean.sprintf-js<= 1.1.3, DoS via unbounded precision (#89, the only open alert)jest > ... > babel-plugin-istanbul > @istanbuljs/load-nyc-config > js-yaml 3.x > argparse 1.xbraces<= 3.0.3, stack exhaustion (GHSA-vfj7-8cjw-p6xm; alert #88)jest > @jest/core > micromatch, and@babel/cli > chokidarThe fix for
sprintf-js:overrides: { "js-yaml": "^4.1.0" }. js-yaml 4 usesargparse2, which no longer depends onsprintf-js. The only consumer,@istanbuljs/load-nyc-config, callsrequire('js-yaml').load(...)on a.nycrc.yaml, which means the same thing in v4. The lockfile losessprintf-jsandesprimaand changes onlyjs-yamlandargparse. Verified: tests, a coverage run, loading a real.nycrc.yamlthroughload-nyc-config, both builds. Dependabot should close #89 on its own after merge (the vulnerable package leaves the lockfile).Why
bracescan't be removed: it is jest's own glob engine (micromatch). Overriding Babel'schokidarwould not help, and@babel/cli8 means a full Babel 8 migration for no gain. It will clear when a patchedbracesis published.npm auditwill keep listing it until then, which is why the CI audit job is scoped to runtime dependencies.3. CI (
.github/workflows/ci.yml)Runs on pull requests, pushes to
main, and manually.lib/and the minified bundlescripts/smoke-build.cjs, 13 checks per bundle)tsc --strict)typescriptis now a devDependencynpm audit --omit=dev --audit-level=highCI(aggregate)New scripts:
test:coverage,test:types,test:build(documented in the README's Contributing section).Not verified locally
I ran every step on Node 22 / PHP 8.2 and from a clean
npm ci, but not on the runner. This PR's own run is the first real test of Node 20 and 24 and of the runner's PHP. If one of those fails for an environmental reason I'll fix it in a follow-up commit here.After merging, consider requiring the
CIcheck in the branch protection rules formain(a repo setting, so I haven't touched it).🤖 Generated with Claude Code