Commit Graph

5074 Commits

Author SHA1 Message Date
murderteeth
1b87140ce7 Regenerate DatabaseAccesses.expected for new vercel.ts fixture
The CWE-089/untyped/vercel.ts fixture added in this PR introduces a
conn.query(...) call that DatabaseAccesses.ql reports, so its
.expected baseline needs the corresponding entry. Output produced by
`codeql test accept`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 15:57:06 +00:00
murderteeth
a6dba9eb25 Merge branch 'main' into js/vercel-node-framework 2026-04-25 14:19:43 -04:00
murderteeth
47915328e6 Address Copilot review nits
Fixes US spelling (recognised -> recognized) across docs, QLDoc,
change note, and test fixture comments. Clarifies the handler QLDoc
to note sync/async support. Renames the supported-frameworks entry
from "vercel" to "Vercel (@vercel/node)" to avoid implying broader
platform coverage.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 17:35:08 +00:00
murderteeth
cff07342f5 Recognize legacy @now/node type aliases
Extends the Vercel serverless handler detection to also match the
deprecated Zeit-era @now/node package with NowRequest/NowResponse
types. Per-review feedback from asgerf, these aliases still appear
in real-world code.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 17:31:29 +00:00
Tom Hvitved
7a48409e38 JS: Recognize Fastify per-route rate limiting 2026-04-13 11:31:34 +02:00
Tom Hvitved
fef582c858 JS: Add test case for Fastify per-route rate limiting 2026-04-13 11:24:41 +02:00
murderteeth
dfe05599d3 JS: Add support for @vercel/node serverless functions
This adds a framework model for Vercel serverless functions so that
CodeQL's existing JavaScript security queries can detect vulnerabilities
in handlers of the form

    export default function handler(req: VercelRequest, res: VercelResponse) { ... }

Handlers are identified as the default export of a module whose first
two parameters are typed as `VercelRequest`/`VercelResponse` from
`@vercel/node`. The default-export constraint excludes private helpers
that share the same signature. Type-based detection follows the same
pattern already used by `NextReqResHandler` in `Next.qll`.

The framework model covers:
- Route handler recognition (default-exported typed handlers only)
- Request input sources: `query`, `body`, `cookies`, and `url`
  (the last inherited from Node's `IncomingMessage`)
- Named header accesses like `req.headers.host` and `req.headers.referer`,
  modelled as `Http::RequestHeaderAccess` so header-specific queries fire
- Response sinks: `res.send`, `res.status(...).send`, `res.redirect`
- Header definitions via `res.setHeader`

Includes a library test exercising each model predicate (including a
negative case for private helpers) and query consistency fixtures
demonstrating end-to-end detection for js/reflected-xss,
js/request-forgery, js/sql-injection, and js/command-line-injection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 19:17:18 +00:00
Asger F
22f16dda85 Merge pull request #21368 from asgerf/browser-sources
JS: Add 'browser' source kinds
2026-03-16 09:24:54 +01:00
Asger F
821cc0e875 JS: Address PR review comments
- Fix misplaced semicolons in test files (was inside comment, moved before it)
- Update QLdoc comments to reference new browser source kind names
- Update docs to list browser source kinds and fix outdated 'only remote' note

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-13 14:58:04 +01:00
Asger F
b8c44be599 Add QL test for bun/tsx shebang recognition in TypeScript files
Add test files with #!/usr/bin/env bun, #!/usr/bin/env tsx, and
#!/usr/bin/env node shebangs. The query lists extracted .ts files,
verifying that all three shebangs are recognized and the files are
not skipped by the extractor.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-12 10:09:56 +01:00
Asger F
4a001f960f JS: Add tests in request forgery queries 2026-03-11 13:53:25 +01:00
Asger F
c9fa7fa283 Merge pull request #21369 from asgerf/js/this-bindings
JS: Emit variables for 'this'
2026-03-05 13:36:38 +01:00
Owen Mansel-Chan
99a4fe4828 Update expected test output column numbers 2026-03-04 15:02:53 +00:00
Owen Mansel-Chan
ea30f02271 js: Inline expectation should have space before $ 2026-03-04 13:11:35 +00:00
Owen Mansel-Chan
0eccd902c2 js: Inline expectation should have space after $
This was a regex-find-replace from `// \$(?! )` (using a negative lookahead) to `// $ `.
2026-03-04 12:45:03 +00:00
Asger F
47895b3334 JS: Update test for UniquePropertyNames test
This query now reports the alert previously found by DuplicateProperty
2026-02-27 13:37:29 +01:00
Asger F
71fb6bf915 JS: Mark corresponding lost result for the getter 2026-02-27 13:35:43 +01:00
Asger F
c673bd9151 JS: Document a missing alert due to limitation in structural comparison 2026-02-27 13:34:55 +01:00
Asger F
4a3b86c652 JS: Update test output 2026-02-27 11:13:50 +01:00
Asger F
f0e665d08c Merge pull request #21349 from asgerf/mobx-wrapper
Support React components wrapped by 'mobx-react'
2026-02-25 09:24:45 +01:00
Asger F
a684943bb7 JS: Model mobx-react{-lite} as higher-order component builders 2026-02-19 11:26:46 +01:00
Asger F
a0099d64c8 JS: Add mobx-react and mobx-react-lite tests 2026-02-19 11:26:44 +01:00
yoff
75bd4a7a12 javascript: add MaD model
- consider if the model is in the right place
- consider if the barrier kind (sink kind) is the appropriate one
2026-01-22 17:30:24 +01:00
yoff
da2f77d615 javascript: remove sanitizer to be replaced by model 2026-01-22 17:30:24 +01:00
yoff
3dbfb9fa4b python: add machinery for MaD barriers
and reinstate previously removed barrier
now as a MaD row
2026-01-22 17:30:24 +01:00
Asger F
bedb80346a Merge pull request #20940 from asgerf/js/detect-minified-files
JS: Skip minified file if avg line length > 200
2026-01-19 14:31:09 +01:00
Asger F
077bbb24ac Merge pull request #21159 from asgerf/js/vue-prop-function
JS: Add support for props callbacks in Vue router configs
2026-01-19 10:13:49 +01:00
Asger F
ff580410fe Merge pull request #20733 from asgerf/js/incremental-api-graphs
JS: Incremental API graph
2026-01-14 12:49:41 +01:00
Asger F
2892ab61ae JS: Make sure a file is not seen as minified 2026-01-14 11:40:01 +01:00
Asger F
84f6b6f67a JS: Accept test change due to file no longer being extracted 2026-01-14 11:40:01 +01:00
Asger F
e430aa97f3 Merge pull request #20916 from asgerf/js/next-folders2
JS: Handle Next.js files named 'page' or 'route'
2026-01-14 11:10:57 +01:00
Asger F
7cd820ea86 JS: Add support for props callbacks in router configs 2026-01-13 11:46:12 +01:00
Asger F
40c35341d1 JS: Add props to Vue router test case 2026-01-13 11:44:07 +01:00
Asger F
ca52fe59e8 Merge pull request #20918 from asgerf/js/response-default-content-type
JS: Handle default 'content-type' header in Response() objects
2026-01-13 10:34:40 +01:00
Asger F
962c128f20 JS: Update test output to reflect Node.toString() change 2026-01-07 11:05:41 +01:00
Asger F
c8108d109d JS: Localize charpred of API::EntryPoint
This is needed for localizing ApiLabel later
2026-01-07 11:05:41 +01:00
tesseractjh
2e840dcd5f Add use cache directives 2025-12-09 08:59:16 +01:00
Anders Schack-Mulligen
78e1879c9e Use more flowTo. 2025-12-03 14:12:08 +01:00
Asger F
7c0243fc6d Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-27 13:18:11 +01:00
Eliav2
69ba764e9d Merge branch 'main' into 20823-globalVarRef-document-defaultView 2025-11-26 23:26:26 +02:00
Asger F
cc7bf4e880 JS: Handle default 'content-type' header in Response() objects 2025-11-26 13:49:48 +01:00
Asger F
037f354abf JS: Update another expected file 2025-11-26 11:42:39 +01:00
Asger F
f0ecf1599c JS: Add test with file named 'page' 2025-11-26 11:16:12 +01:00
Asger F
e54789d1bd JS: Recognise route.ts outside api folder 2025-11-26 11:16:11 +01:00
Asger F
f52f5b63e6 JS: Add test with route.ts outside 'api' 2025-11-26 11:16:09 +01:00
Asger F
5b4e114955 JS: Add test 2025-11-25 16:04:30 +01:00
Eliav2
6df789d114 Merge branch 'main' into 20823-globalVarRef-document-defaultView 2025-11-20 15:18:15 +02:00
eliav
91451b73ef javascript: Update expected results for global variable references 2025-11-20 15:15:06 +02:00
eliav
30cc91421d javascript: Add support for document.defaultView in global variable references
Updated the data flow analysis to include `document.defaultView` as a source node for global variable references. Added a new test file `tst4.js` and updated existing tests to verify the inclusion of `defaultView` and its properties in the expected results.
2025-11-17 00:52:06 +02:00
Taus
889209719b JS: Overlay annotations for some failing tests
Locally these seem to get rid of the compilation warnings, but of course
CI is the true arbiter here.
2025-11-13 09:46:03 +01:00