Skip to content

JS: Recognize serverless handlers in .mjs and .cjs files - #23191

Open
ebickle wants to merge 1 commit into
github:mainfrom
ebickle:js/serverless-js-extensions
Open

ebickle wants to merge 1 commit into
github:mainfrom
ebickle:js/serverless-js-extensions

Conversation

@ebickle

@ebickle ebickle commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

getAServerlessHandler only resolved handlers declared in .js files, so handlers in .mjs and .cjs files, which the AWS Lambda Node.js runtime supports natively, were not treated as remote flow sources.

This extends the handler file lookup to .mjs and .cjs, and adds a test with an ES module handler and a CommonJS handler declared in a serverless.yml.

@ebickle
ebickle requested a review from a team as a code owner November 20, 2026 17:38
Copilot AI adaptive review requested due to automatic review settings November 20, 2026 17:39

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.

🟢 Approval recommended

No active review issues are recorded for the expanded Serverless handler support.

No open issues 🎉

What changed in this PR

This PR extends CodeQL’s JavaScript Serverless model to recognize handlers in .mjs and .cjs files, allowing their event parameters to be treated as remote flow sources.

Changes:

  • Expands handler lookup beyond .js to include both module-specific extensions.
  • Adds ES module and CommonJS fixtures with expected source results.
  • Documents the analysis improvement in a change note.
File Description
javascript/​ql/​test/​library-tests/​frameworks/​ServerLess/​tst8/​serverless.yml Declares both new handler fixtures.
javascript/​ql/​test/​library-tests/​frameworks/​ServerLess/​tst8/​esm.mjs Adds an ES module handler fixture.
javascript/​ql/​test/​library-tests/​frameworks/​ServerLess/​tst8/​cjs.cjs Adds a CommonJS handler fixture.
javascript/​ql/​test/​library-tests/​frameworks/​ServerLess/​test.expected Records expected event sources for both handlers.
javascript/​ql/​lib/​semmle/​javascript/​frameworks/​ServerLess.qll Extends handler resolution to .mjs and .cjs.
javascript/​ql/​lib/​change-notes/​2026-11-20-serverless-mjs-cjs.md Documents the expanded remote-source recognition.

Review effort: Balanced (adaptive)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants