-
Notifications
You must be signed in to change notification settings - Fork 1.9k
JavaScript: Allow specifying additional remote flow sources through JSON. #4802
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
JavaScript: Allow specifying additional remote flow sources through JSON. #4802
Conversation
|
I haven't evaluated performance or written proper documentation yet, but putting this up anyway to facilitate discussion. (@asgerf) @muglug, would this format work for you? The one thing that's currently missing is restricting the scope of a remote flow source to a single source file. I wasn't sure we want that, since the sources are (at the moment anyway) global variables anyway. Do you have specific use cases where you want different sets of (global) flow sources for different files? |
|
That format would work great! |
|
Is there also a way to list TypeScript types as sources? e.g. export type TeamSettings = {
teamName: string; // RemoteFlowSource: user input
logoUrl: string;
accentColor: string;
};These types are typically mapped to JSON requests inside application code. |
|
Ah, good question. I think that should be possible, but may need a few more extensions. |
fd1f932 to
be35e85
Compare
|
Performance looks unproblematic (internal link). I'd suggest we tackle the extension to TypeScript in a separate PR. Still need to add documentation in the appropriate places, though. |
asgerf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation LGTM. 👍
|
I have added a brief write-up in @mchammer01, could you take a look? (And let me know if this isn't the right location or the right format.) |
|
Hi @max-schaefer 👋🏻 - Unfortunately, I don't have time to look at this (heads down with documentation work for GHES 3.0) but someone else in the team will review this for you, hopefully shortly 🙂 |
Hey @max-schaefer MC is heads down on GitHub docs so I'll take a look at this for you |
|
I've just pushed a commit that adds a short introduction to the article, which is also used in the table of contents on the |
|
Awesome work team! Let's ship this as a beta for the CodeQL JavaScript/TypeScript analysis and learn from how people use it. We'll then consider whether (and how) we can integrate this into the CodeQL analysis for other languages. @jf205 / @max-schaefer: could you make sure to include the "beta" label in the documentation please? Thanks all! |
jf205
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a beta note and reviewed the rest of the text. Looks pretty much good to go 👍🏻
docs/codeql/codeql-language-guides/specifying-additional-remote-flow-sources-for-javascript.rst
Outdated
Show resolved
Hide resolved
docs/codeql/codeql-language-guides/specifying-additional-remote-flow-sources-for-javascript.rst
Outdated
Show resolved
Hide resolved
docs/codeql/codeql-language-guides/specifying-additional-remote-flow-sources-for-javascript.rst
Show resolved
Hide resolved
docs/codeql/codeql-language-guides/specifying-additional-remote-flow-sources-for-javascript.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: James Fletcher <42464962+jf205@users.noreply.github.com>
|
Thanks, @jf205! We may need to iterate a bit more on
I think this could be misinterpreted as referring to untrusted input coming from external files, which of course isn't what this is about. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Here's another attempt.
docs/codeql/codeql-language-guides/specifying-additional-remote-flow-sources-for-javascript.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: James Fletcher <42464962+jf205@users.noreply.github.com>
|
Perfect, thanks! |
jf205
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs LGTM!
Fixes #4785.
With this PR, you can add one or more JSON files named
codeql-javascript-remote-flow-sources.jsonto your database (either by including them somewhere in the source tree or by extracting and importing them separately) to specify additional remote flow sources, which will give rise to newRemoteFlowSources at the QL level.As an example of the syntax, this JSON file
{ "user input": [ "window.user.name", "window.user.address", "window.dob" ], "uncontrolled path": [ "window.upload" ] }marks
window.user.name,window.user.address,window.dob, andwindow.uploadas remote flow sources, the former three with source type "user input", the last one with source type "uncontrolled path".We use inter-procedural data flow to identify accesses to the new remote flow sources, so a property access of the form
getWindow().uploadwheregetWindow()returns a reference to the global object is also recognised as a remote flow source.