Skip to content

JS: Make API graphs use steps from summaries #19012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 18, 2025

Conversation

asgerf
Copy link
Contributor

@asgerf asgerf commented Mar 13, 2025

Makes API graphs use Content internally and use steps from summaries.

Steps from summaries are already converted into type-tracking steps, we just need to use them in API graphs.

The handling of Content/ContentSet is the same as in Ruby: the graph is generated using getAStoreContent (both for use and def nodes) and queried using getAReadContent. We want to avoid materialising a graph based on getAReadContent() because that set can be huge.

Based on this we can now implement getArrayElement() properly. This looks through things like .map() and .pop() based on the existing models for arrays. This in turn fixes some issues with the ArrayElement MaD token, as shown in the new test case.

@github-actions github-actions bot added the JS label Mar 13, 2025
@asgerf asgerf force-pushed the js/api-graph-array-element branch 4 times, most recently from b8f6522 to aa11c0e Compare March 14, 2025 21:51
asgerf added 5 commits March 14, 2025 23:04
…ement()

Although they mean slightly different things, every single call site
of getUnknownMember() just used it as a way to get array elements.

Since there is no known use-case for the original meaning of
getUnknownMember() I am deprecating it for now.
@asgerf asgerf force-pushed the js/api-graph-array-element branch from aa11c0e to cd39092 Compare March 14, 2025 22:08
@asgerf asgerf added the no-change-note-required This PR does not need a change note label Mar 18, 2025
The use of AnyMember was a workaround until the bugfix in this PR landed.
@asgerf asgerf marked this pull request as ready for review March 18, 2025 10:26
@Copilot Copilot AI review requested due to automatic review settings March 18, 2025 10:26
@asgerf asgerf requested a review from a team as a code owner March 18, 2025 10:26
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request updates API graphs to use steps from summaries and refactors how array elements are handled in various test and configuration files.

  • Updates the tests by adding an array source function to exercise new API graph handling.
  • Changes the dynamic property read in the API graph to use ArrayElement.
  • Modifies configuration files for test extensions and tanstack models to support the new array element representation.

Reviewed Changes

Copilot reviewed 5 out of 18 changed files in this pull request and generated no comments.

Show a summary per file
File Description
javascript/ql/test/library-tests/frameworks/data/test.js Adds tests for array source function calls using testlib.
javascript/ql/test/ApiGraphs/dynamic-prop-read/index.js Updates the dynamic call from getUnknownMember() to getArrayElement().
javascript/ql/test/library-tests/frameworks/data/test.ext.yml Extends test configuration with ArrayElement return for testlib.
javascript/ql/lib/ext/tanstack.model.yml Adjusts tanstack API queries to return ArrayElement for useQueries.
javascript/ql/test/query-tests/Security/CWE-079/DomBasedXssWithResponseThreat/testUseQueries.vue Updates comment markers to reflect correct source and alert tags.
Files not reviewed (13)
  • javascript/ql/lib/semmle/javascript/ApiGraphs.qll: Language not supported
  • javascript/ql/lib/semmle/javascript/dataflow/internal/Contents.qll: Language not supported
  • javascript/ql/lib/semmle/javascript/frameworks/D3.qll: Language not supported
  • javascript/ql/lib/semmle/javascript/frameworks/Puppeteer.qll: Language not supported
  • javascript/ql/lib/semmle/javascript/frameworks/Vuex.qll: Language not supported
  • javascript/ql/lib/semmle/javascript/frameworks/data/internal/ApiGraphModelsSpecific.qll: Language not supported
  • javascript/ql/lib/semmle/javascript/internal/CachedStages.qll: Language not supported
  • javascript/ql/lib/semmle/javascript/internal/flow_summaries/Arrays.qll: Language not supported
  • javascript/ql/lib/semmle/javascript/security/dataflow/ExternalAPIUsedWithUntrustedDataCustomizations.qll: Language not supported
  • javascript/ql/src/experimental/Security/CWE-347/JWT.qll: Language not supported
  • javascript/ql/src/experimental/semmle/javascript/Execa.qll: Language not supported
  • javascript/ql/test/library-tests/frameworks/data/test.expected: Language not supported
  • javascript/ql/test/query-tests/Security/CWE-079/DomBasedXssWithResponseThreat/Xss.expected: Language not supported

Tip: Copilot code review supports C#, Go, Java, JavaScript, Markdown, Python, Ruby and TypeScript, with more languages coming soon. Learn more

Copy link
Contributor

@erik-krogh erik-krogh left a comment

Choose a reason for hiding this comment

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

Nice 👍

Although I feel the latest DCA evaluation hints towards a minor performance regression?
I've started another evaluation to see whether that's just a spurious result.

@erik-krogh
Copy link
Contributor

Peformance is fine.

👍

@asgerf asgerf merged commit 1324c11 into github:main Mar 18, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JS no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants