Skip to content

fix: resolve remaining CodeQL code-scanning alerts - #167

Merged
adityathebe merged 1 commit into
mainfrom
claude/codeql-security-reports-0xz5ku
Jul 17, 2026
Merged

fix: resolve remaining CodeQL code-scanning alerts#167
adityathebe merged 1 commit into
mainfrom
claude/codeql-security-reports-0xz5ku

Conversation

@adityathebe

Copy link
Copy Markdown
Member

Summary

Resolves the open CodeQL code-scanning alerts:

Alert Location Severity Fix
Inclusion of functionality from an untrusted source docs/layouts/partials/footer_js.html:88 Medium Add SRI + crossorigin to the highlight.js script
Incorrect suffix check js/shared.js:40 High Guard endsWith against an over-long suffix
Client-side XSS (×2) docs/static/js/search.js:25,35 High Already fixed on main (see below)

Details

Inclusion of functionality from an untrusted source — footer_js.html

The highlight.js bundle was loaded from a hardcoded CDN URL with no integrity check, so a compromised/hijacked CDN response would execute arbitrary script on the docs site. Added a Subresource Integrity hash and crossorigin="anonymous", and moved to the maintained highlight.js v11.11.1 build.

  • The SRI hash is derived from the official @highlightjs/cdn-assets@11.11.1 npm artifact, which jsdelivr serves byte-for-byte — so the integrity value is guaranteed to match what browsers fetch.
  • v11 removed initHighlightingOnLoad(); replaced with hljs.highlightAll().
<script src="https://cdn.jsdelivr.net/npm/@highlightjs/cdn-assets@11.11.1/highlight.min.js"
        integrity="sha384-RH2xi4eIQ/gjtbs9fUXM68sLSi99C7ZWBRX1vDrVv6GQXRibxXLbwO2NGZB74MbU"
        crossorigin="anonymous"></script>
<script>hljs.highlightAll();</script>

Incorrect suffix check — js/shared.js

endsWith() computed s.substring(s.length - search.length) without checking that search isn't longer than s. When it is, the start index is negative, substring clamps it to 0, and the check reduces to s === search — the error-prone pattern CodeQL flags. Added an explicit search.length <= s.length guard.

The manual implementation is kept intentionally: shared.js is embedded and evaluated in the ES5 otto runtime, which has no native String.prototype.endsWith. Behavior is unchanged for all valid inputs (verified against a set of cases).

Client-side cross-site scripting — search.js

These two alerts were already resolved on main in #165, which switched the reflected search query from $(...).replaceWith(searchQuery) (an HTML sink) to $(...).text(searchQuery) (text, not HTML). No further change is needed; they will auto-close on the next scan.

Verification

  • go build ./... and go vet ./js/... pass (the embedded shared.js is valid ES5).
  • endsWith behavior validated against edge cases (suffix longer than string, empty strings, exact match).

Note (not in scope of these alerts)

docs/config.toml also loads fuse.js and mark.js from cdnjs without SRI. CodeQL does not flag those because they reach the template through a variable ({{ . | absURL }}) rather than a literal URL, but they're the same class of issue and could be given SRI in a follow-up.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GAXAPgXCc5TpEeZiFbwkhf


Generated by Claude Code

Addresses the open CodeQL code-scanning findings:

- Inclusion of functionality from an untrusted source
  (docs/layouts/partials/footer_js.html): the highlight.js bundle was
  loaded from a CDN over a hardcoded URL with no integrity check. Add a
  Subresource Integrity (SRI) hash and crossorigin attribute, and move to
  the maintained highlight.js v11.11.1 build. The integrity hash is derived
  from the official @highlightjs/cdn-assets npm artifact, which jsdelivr
  serves byte-for-byte, so the hash is guaranteed to match. v11 replaces the
  removed initHighlightingOnLoad() with highlightAll().

- Incorrect suffix check (js/shared.js): endsWith() computed
  s.substring(s.length - search.length) without guarding against a search
  string longer than s (a negative start index). Add an explicit
  search.length <= s.length guard. Kept the manual implementation because
  this file is embedded and evaluated in the ES5 otto runtime, which lacks
  String.prototype.endsWith.

The two client-side XSS findings in docs/static/js/search.js were already
resolved on main (replaceWith -> text); all findings will auto-close on the
next CodeQL scan.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GAXAPgXCc5TpEeZiFbwkhf
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jul 17, 2026
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown

Benchstat

Base: 62d3b94d83f2b1abd89664d7b53b949c403c9518
Head: b5884951086ae2d4b81798588f7bb8559cec98c2

2 minor regression(s) (all within 5% threshold)

Benchmark Base Head Change p-value
Serialize_NoNativeTypes/Size-100-4 89.96µ 90.52µ +0.62% 0.004
Serialize/Size-1000-4 3.484m 3.500m +0.48% 0.041
1 improvement(s)
Benchmark Base Head Change p-value
RunExpressionContext/cacheHit/smallEnv-4 1.812µ 1.796µ -0.91% 0.048
Full benchstat output
goos: linux
goarch: amd64
pkg: github.com/flanksource/gomplate/v3
cpu: AMD EPYC 7763 64-Core Processor                
                                               │ bench-base.txt │          bench-head.txt           │
                                               │     sec/op     │   sec/op     vs base              │
RunExpressionContext/cacheHit/smallEnv-4           1.812µ ± 13%   1.796µ ± 1%  -0.91% (p=0.048 n=6)
RunExpressionContext/cacheHit/largeEnv-4           10.83µ ±  0%   10.83µ ± 6%       ~ (p=0.937 n=6)
RunExpressionContextCompile/compile/smallEnv-4     348.9µ ±  1%   350.0µ ± 0%       ~ (p=0.180 n=6)
RunExpressionContextCompile/compile/largeEnv-4     361.2µ ±  1%   361.0µ ± 1%       ~ (p=0.818 n=6)
Serialize/Size-10-4                                36.35µ ±  1%   36.30µ ± 1%       ~ (p=0.937 n=6)
Serialize/Size-100-4                               348.7µ ±  1%   349.8µ ± 1%       ~ (p=0.093 n=6)
Serialize/Size-1000-4                              3.484m ±  0%   3.500m ± 0%  +0.48% (p=0.041 n=6)
Serialize/Size-10000-4                             38.48m ±  2%   38.80m ± 1%       ~ (p=0.180 n=6)
Serialize_NoNativeTypes/Size-100-4                 89.96µ ±  1%   90.52µ ± 2%  +0.62% (p=0.004 n=6)
Serialize_NoNativeTypes/Size-1000-4                912.0µ ±  2%   911.3µ ± 1%       ~ (p=0.394 n=6)
Serialize_NoNativeTypes/Size-10000-4               9.227m ±  1%   9.190m ± 0%       ~ (p=0.074 n=6)
geomean                                            316.4µ         316.7µ       +0.09%

                                               │ bench-base.txt │            bench-head.txt            │
                                               │      B/op      │     B/op      vs base                │
RunExpressionContext/cacheHit/smallEnv-4             664.0 ± 0%     664.0 ± 0%       ~ (p=1.000 n=6) ¹
RunExpressionContext/cacheHit/largeEnv-4           2.445Ki ± 0%   2.445Ki ± 0%       ~ (p=1.000 n=6) ¹
RunExpressionContextCompile/compile/smallEnv-4     194.3Ki ± 0%   194.4Ki ± 0%       ~ (p=0.227 n=6)
RunExpressionContextCompile/compile/largeEnv-4     196.3Ki ± 0%   196.3Ki ± 0%       ~ (p=0.219 n=6)
Serialize/Size-10-4                                11.06Ki ± 0%   11.06Ki ± 0%       ~ (p=1.000 n=6) ¹
Serialize/Size-100-4                               95.51Ki ± 0%   95.51Ki ± 0%       ~ (p=0.736 n=6)
Serialize/Size-1000-4                              952.7Ki ± 0%   952.6Ki ± 0%       ~ (p=1.000 n=6)
Serialize/Size-10000-4                             10.04Mi ± 0%   10.04Mi ± 0%       ~ (p=0.418 n=6)
Serialize_NoNativeTypes/Size-100-4                 36.33Ki ± 0%   36.33Ki ± 0%       ~ (p=1.000 n=6) ¹
Serialize_NoNativeTypes/Size-1000-4                365.6Ki ± 0%   365.6Ki ± 0%       ~ (p=1.000 n=6)
Serialize_NoNativeTypes/Size-10000-4               3.584Mi ± 0%   3.584Mi ± 0%       ~ (p=0.526 n=6)
geomean                                            110.7Ki        110.7Ki       +0.00%
¹ all samples are equal

                                               │ bench-base.txt │           bench-head.txt            │
                                               │   allocs/op    │  allocs/op   vs base                │
RunExpressionContext/cacheHit/smallEnv-4             20.00 ± 0%    20.00 ± 0%       ~ (p=1.000 n=6) ¹
RunExpressionContext/cacheHit/largeEnv-4             101.0 ± 0%    101.0 ± 0%       ~ (p=1.000 n=6) ¹
RunExpressionContextCompile/compile/smallEnv-4      2.254k ± 0%   2.254k ± 0%       ~ (p=1.000 n=6) ¹
RunExpressionContextCompile/compile/largeEnv-4      2.337k ± 0%   2.337k ± 0%       ~ (p=1.000 n=6) ¹
Serialize/Size-10-4                                  268.0 ± 0%    268.0 ± 0%       ~ (p=1.000 n=6) ¹
Serialize/Size-100-4                                2.518k ± 0%   2.518k ± 0%       ~ (p=1.000 n=6) ¹
Serialize/Size-1000-4                               25.80k ± 0%   25.80k ± 0%       ~ (p=1.000 n=6)
Serialize/Size-10000-4                              265.0k ± 0%   265.0k ± 0%       ~ (p=0.636 n=6)
Serialize_NoNativeTypes/Size-100-4                   911.0 ± 0%    911.0 ± 0%       ~ (p=1.000 n=6) ¹
Serialize_NoNativeTypes/Size-1000-4                 9.758k ± 0%   9.758k ± 0%       ~ (p=1.000 n=6) ¹
Serialize_NoNativeTypes/Size-10000-4                100.1k ± 0%   100.1k ± 0%       ~ (p=0.567 n=6)
geomean                                             2.641k        2.641k       -0.00%
¹ all samples are equal

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@adityathebe, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 27 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 88c6bb2a-207d-4b78-8852-e6277e788a3b

📥 Commits

Reviewing files that changed from the base of the PR and between 62d3b94 and b588495.

📒 Files selected for processing (2)
  • docs/layouts/partials/footer_js.html
  • js/shared.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/codeql-security-reports-0xz5ku
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/codeql-security-reports-0xz5ku

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@adityathebe
adityathebe merged commit 83d82e2 into main Jul 17, 2026
9 checks passed
@adityathebe
adityathebe deleted the claude/codeql-security-reports-0xz5ku branch July 17, 2026 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants