Repository navigation
Migrate scripts/affected.ts from js-yaml to yaml - #2950
Closed
Tommy Nguyen (tido64) with Copilot wants to merge 1 commit into
Closed
Tommy Nguyen (tido64) with Copilot wants to merge 1 commit into
Tommy Nguyen (tido64) with Copilot wants to merge 1 commit into
Conversation
Co-authored-by: tido64 <4123478+tido64@users.noreply.github.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
Replaces
js-yamlwithyaml(eemeli/yaml) as the YAML parsing dependency used byscripts/affected.tsto load.github/labeler.yml.Changes
package.json:"js-yaml": "^5.3.0"→"yaml": "^2.9.1"in devDependencies (lockfile updated)scripts/affected.ts:import * as yaml from "js-yaml"→import * as yaml from "yaml";yaml.load(yml)→yaml.parse(yml)(near drop-in, only read/parse is used — no dumping)Why
Investigated because new vulnerabilities keep being discovered in
js-yaml, generating alert noise for a narrow, low-risk use case (parsing a single static, trusted, repo-owned config file once per CI job — no untrusted input).Security track record
js-yaml!!omap, merge-key<<chains, flow collections — recurring, including in the current 5.x line), and prototype pollution via merge keys (CVE-2025-64718)yamlyamlalso has zero transitive runtime dependencies (removes theargparsesub-dependencyjs-yamlcarries for its CLI, which we don't use).Performance caveat
yamlis measurably slower thanjs-yaml, benchmarked against the actual.github/labeler.ymlfile on Node v22:Fresh-process (matches real usage —
affected.tsruns once per CI job as a newnodeprocess):js-yamlyamlyaml's CJS build is split across ~74 files vs.js-yaml's 2, sorequire()costs ~4x more;yaml.parse()itself is ~2.3x slower thanjs-yaml.load()since it builds a full CST before producing the JS value.Warm/JIT-optimized (20,000 iterations, order-independent):
js-yamlload()yamlparse()Practical impact: since
affected.tsparses once per fresh process, only the fresh-process numbers apply — an increase of ~25 ms per CI job invocation, negligible next to typical CI job durations. The security/dependency benefits outweigh this cost for our use case.Validation
yarn show-affectedstill parses.github/labeler.ymlcorrectly and falls back to matching all platforms when base commit isn't resolvable (expected in a shallow clone)oxlint(yarn lint:js) — cleanknip— no unused/missing dependency issuesjs-yamlreferences in the repo