Skip to content

Commit 821cc0e

Browse files
asgerfCopilot
andcommitted
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>
1 parent 5db30c9 commit 821cc0e

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

docs/codeql/codeql-language-guides/customizing-library-models-for-javascript.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ Adds a new taint source. Most taint-tracking queries will use the new source.
406406

407407
- **type**: Name of a type from which to evaluate **path**.
408408
- **path**: Access path leading to the source.
409-
- **kind**: Kind of source to add. Currently only **remote** is used.
409+
- **kind**: Kind of source to add. See the section on :ref:`source kinds <threat-models-javascript>` for supported values.
410410

411411
Example:
412412

@@ -553,7 +553,16 @@ Kinds
553553
Source kinds
554554
~~~~~~~~~~~~
555555

556-
See documentation below for :ref:`Threat models <threat-models-javascript>`.
556+
- **remote**: A general source of remote flow.
557+
- **browser**: A source in the browser environment that does not fit a more specific browser kind.
558+
- **browser-url-query**: A source derived from the query parameters of the browser URL, such as ``location.search``.
559+
- **browser-url-fragment**: A source derived from the fragment part of the browser URL, such as ``location.hash``.
560+
- **browser-url-path**: A source derived from the pathname of the browser URL, such as ``location.pathname``.
561+
- **browser-url**: A source derived from the browser URL, where the untrusted part is prefixed by trusted data such as the scheme and hostname.
562+
- **browser-window-name**: A source derived from the window name, such as ``window.name``.
563+
- **browser-message-event**: A source derived from cross-window message passing, such as ``event`` in ``window.onmessage = event => {...}``.
564+
565+
See also :ref:`Threat models <threat-models-javascript>`.
557566

558567
Sink kinds
559568
~~~~~~~~~~

javascript/ql/lib/semmle/javascript/security/dataflow/RemoteFlowSources.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,16 @@ class ClientSideRemoteFlowKind extends string {
8585
*/
8686
predicate isUrl() { this = "browser-url" }
8787

88-
/** Holds if this is the `query` or `fragment` kind. */
88+
/** Holds if this is the `browser-url-query` or `browser-url-fragment` kind. */
8989
predicate isQueryOrFragment() { this.isQuery() or this.isFragment() }
9090

91-
/** Holds if this is the `path`, `query`, or `fragment` kind. */
91+
/** Holds if this is the `browser-url-path`, `browser-url-query`, or `browser-url-fragment` kind. */
9292
predicate isPathOrQueryOrFragment() { this.isPath() or this.isQuery() or this.isFragment() }
9393

94-
/** Holds if this is the `path` or `url` kind. */
94+
/** Holds if this is the `browser-url-path` or `browser-url` kind. */
9595
predicate isPathOrUrl() { this.isPath() or this.isUrl() }
9696

97-
/** Holds if this is the `name` kind, describing sources derived from the window name, such as `window.name`. */
97+
/** Holds if this is the `browser-window-name` kind, describing sources derived from the window name, such as `window.name`. */
9898
predicate isWindowName() { this = "browser-window-name" }
9999

100100
/**

javascript/ql/test/query-tests/Security/CWE-918/clientSide.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ export function MyComponent() {
2424
request(window.location.href + '?q=123');
2525

2626
const custom = require('testlib').getBrowserSource(); // $ Source[js/client-side-request-forgery]
27-
request(custom) // $ Alert[js/client-side-request-forgery];
27+
request(custom); // $ Alert[js/client-side-request-forgery]
2828
}

javascript/ql/test/query-tests/Security/CWE-918/serverSide.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,4 @@ var server2 = http.createServer(function (req, res) {
148148
});
149149

150150
const custom = require('testlib').getServerSource(); // $ Source[js/request-forgery]
151-
request(custom) // $ Alert[js/request-forgery];
151+
request(custom); // $ Alert[js/request-forgery]

0 commit comments

Comments
 (0)