Repository navigation
Fix CodeQL alerts in benchmark comments and regex dump - #403
Merged
Merged
Conversation
Post Benchmark Results pasted the PR number from the benchmark artifact into its github-script source. The artifact is written by the PR's own copy of the Benchmarks workflow, so a fork could inject code that runs with a token that can write PR comments. Accept only a decimal PR number, pass it through an environment variable, and comment only when that PR's head commit is the one that was benchmarked. The regex bytecode dump located the characters after MatchNChar8 and MatchNCharICase8 with insn + sizeof(regex::Insn). That is pointer arithmetic on the instruction type and works only because sizeof(Insn) is 1. Use insn + 1, as the regex executor does. Output is unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the benchmark-comment workflow hardening and regex bytecode dump changes.
No open issues 🎉
What changed in this PR
This PR addresses three CodeQL alerts by hardening benchmark-result commenting and correcting pointer arithmetic in regex bytecode dumps.
Changes:
- Validates artifact-supplied PR numbers and passes them through an environment variable rather than embedding them in JavaScript.
- Checks that the target PR’s current head matches the benchmark workflow’s head commit before commenting.
- Uses
insn + 1to locate trailing character data in two regex instructions, preserving dump output.
| File | Description |
|---|---|
lib/Regex/RegexSerialization.cpp |
Corrects character-data pointer arithmetic for two regex instruction dumps. |
.github/workflows/benchmark-comment.yml |
Validates PR numbers, avoids script interpolation, and adds a head-commit check. |
Review effort: Balanced
Vladimir Morozov (vmoroz)
enabled auto-merge (squash)
November 3, 2026 00:15
Nikolai Aristov (NikoAri)
approved these changes
Nov 3, 2026
Benchmark ResultsTotal benchmarks: 204 Inputs: baseline/baseline.json, bench_result.json v8 (6176ms, 3666ms) -40.6%
test-suites (317886ms, 168009ms) -47.1%
micros (60876ms, 41289ms) -32.2%
jit-benches (8563ms, 4426ms) -48.3%
many-subclasses (73437ms, 40694ms) -44.6%
map-objects (3627ms, 1927ms) -46.9%
map-strings (4335ms, 2483ms) -42.7%
nbody (3448ms, 1733ms) -49.7%
string-switch (6503ms, 3117ms) -52.1%
raytracer (5608ms, 3142ms) -44.0%
MiniReact (30332ms, 16694ms) -45.0%
widgets (12934ms, 6987ms) -46.0%
|
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
Fixes the three open CodeQL alerts from the new advanced setup.
workflow pasted the PR number from the benchmark artifact straight into its
github-scriptsource. That artifact is written by the PR's own copy of theBenchmarks workflow, so a fork could inject code that runs in the base
repository with a token that can write PR comments. The workflow now accepts
only a decimal PR number, passes it through an environment variable, and
comments only when that PR's head commit is the one that was benchmarked, so
a forged number cannot target another PR.
dump found the characters after
MatchNChar8andMatchNCharICase8withinsn + sizeof(regex::Insn), which is pointer arithmetic on the instructiontype. It worked only because
sizeof(regex::Insn)is 1. It now usesinsn + 1, as the regex executor does. Output is unchanged. The same codeis in upstream Hermes.
Test Plan
.\dev build --targets hermesc --platform x64 --configuration release(separate output folder): passed.
hermesc -dump-bytecode -target=HBC -non-strict test\hermes\regexp_bytecode.jsand
hermesc -O -dump-bytecode test\BCGen\HBC\store_to_env.js: output isbyte-identical to a
hermescbuilt before this change, and contains everyMatchNChar8andMatchNCharICase8CHECK line in both tests.402and401\n; rejects1');require('child_process').execSync('id');//,0x1F, an empty fileand an 11-digit value.
actionlinton both benchmark workflows: passed.benchmark comment exercises it.
Microsoft Reviewers: Open in CodeFlow