Skip to content

Fix CodeQL comment tag filter finding - #1180

Closed
brunoborges wants to merge 1 commit into
mainfrom
brunoborges-fix-codeql-tag-filter
Closed

Fix CodeQL comment tag filter finding#1180
brunoborges wants to merge 1 commit into
mainfrom
brunoborges-fix-codeql-tag-filter

Conversation

@brunoborges

Copy link
Copy Markdown
Contributor

Summary

  • patch the transitive is-unsafe XML comment-close detector during builds to recognize --!> as well as -->
  • fail fast if the dependency source changes unexpectedly
  • regenerate setup and cleanup distributions

Dependency path

@actions/cache@azure/storage-blob@azure/core-xmlfast-xml-parseris-unsafe

Validation

  • npm run check
  • verified both generated bundles contain /--!?>/ and no longer contain /-->/

Patch is-unsafe's XML comment-close detector during builds so generated bundles recognize both HTML comment end forms and satisfy CodeQL until the dependency publishes a fix.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 277302b1-aa95-4012-817b-9752cdaee14e
Copilot AI review requested due to automatic review settings July 29, 2026 20:19
@brunoborges
brunoborges requested a review from a team as a code owner July 29, 2026 20:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR mitigates a CodeQL finding by patching a transitive dependency (is-unsafe) during builds so its XML comment-close detector recognizes both --> and --!> when generating the action bundles.

Changes:

  • Add a build-time patch script that rewrites the is-unsafe XML detector pattern from /-->/ to /--!?>/ with a guard against unexpected source changes.
  • Run the patch script as part of npm run build before ncc bundling.
  • Regenerate dist/setup and dist/cleanup bundles to include the patched pattern.
Show a summary per file
File Description
scripts/patch-is-unsafe.mjs New build-time script to patch the transitive dependency’s XML comment-close pattern.
package.json Updates the build script to run the patch step before bundling.
dist/setup/index.js Updates bundled dependency code to use /--!?>/ for XML comment close detection.
dist/cleanup/index.js Updates bundled dependency code to use /--!?>/ for XML comment close detection.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/4 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment on lines +8 to +20
// CodeQL treats this XML detector as an incomplete HTML comment-end filter.
if (source.includes(safePattern)) {
process.exit(0);
}

const occurrences = source.split(vulnerablePattern).length - 1;
if (occurrences !== 1) {
throw new Error(
`Expected one ${JSON.stringify(vulnerablePattern)} in ${sourcePath.pathname}, found ${occurrences}`
);
}

await writeFile(sourcePath, source.replace(vulnerablePattern, safePattern));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants