Skip to content

Commit b8d652c

Browse files
authored
Merge pull request #18132 from asgerf/jss/deprecation
JS: Deprecations and related refactorings
2 parents 071189a + 3f0d0e3 commit b8d652c

File tree

107 files changed

+1348
-1646
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+1348
-1646
lines changed

javascript/ql/lib/semmle/javascript/dataflow/AdditionalFlowSteps.qll

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ private import semmle.javascript.internal.CachedStages
2828
*
2929
* This class is a singleton, and thus subclasses do not need to specify a characteristic predicate.
3030
*
31+
* As an alternative to this class, consider using `DataFlow::SummarizedCallable`.
32+
*
3133
* Note: For performance reasons, all subclasses of this class should be part
32-
* of the standard library. Override `Configuration::isAdditionalFlowStep`
33-
* for analysis-specific flow steps.
34+
* of the standard library. Use `isAdditionalFlowStep` for query-specific flow steps.
3435
*/
3536
class AdditionalFlowStep extends Unit {
3637
/**

javascript/ql/lib/semmle/javascript/dataflow/AdditionalTaintSteps.qll

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ private import semmle.javascript.internal.CachedStages
1111
*
1212
* This class is a singleton, and thus subclasses do not need to specify a characteristic predicate.
1313
*
14+
* As an alternative to this class, consider using `DataFlow::SummarizedCallable`.
15+
*
1416
* Note: For performance reasons, all subclasses of this class should be part
15-
* of the standard library. Override `Configuration::isAdditionalTaintStep`
16-
* for analysis-specific taint steps.
17+
* of the standard library. Use `isAdditionalFlowStep` for query-specific taint steps.
1718
*/
1819
class AdditionalTaintStep extends Unit {
1920
/**

javascript/ql/lib/semmle/javascript/dataflow/Configuration.qll

+111-90
Large diffs are not rendered by default.

javascript/ql/lib/semmle/javascript/dataflow/DataFlow.qll

+1
Original file line numberDiff line numberDiff line change
@@ -1935,4 +1935,5 @@ module DataFlow {
19351935
import internal.FunctionWrapperSteps
19361936
import internal.sharedlib.DataFlow
19371937
import internal.BarrierGuards
1938+
import FlowSummary
19381939
}

javascript/ql/lib/semmle/javascript/dataflow/FlowSummary.qll

+46-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,49 @@ private import semmle.javascript.dataflow.internal.FlowSummaryPrivate
66
private import semmle.javascript.dataflow.internal.sharedlib.DataFlowImplCommon as DataFlowImplCommon
77
private import semmle.javascript.dataflow.internal.DataFlowPrivate
88

9-
/** A callable with a flow summary, identified by a unique string. */
9+
/**
10+
* A model for a function that can propagate data flow.
11+
*
12+
* This class makes it possible to model flow through functions, using the same mechanism as
13+
* `summaryModel` as described in the [library customization docs](https://codeql.github.com/docs/codeql-language-guides/customizing-library-models-for-javascript).
14+
*
15+
* Extend this class to define summary models directly in CodeQL.
16+
* Data extensions and `summaryModel` are usually preferred; but there are a few cases where direct use of this class may be needed:
17+
*
18+
* - The relevant call sites cannot be matched by the access path syntax, and require the full power of CodeQL.
19+
* For example, complex overloading patterns might require more local reasoning at the call site.
20+
* - The input/output behaviour cannot be described statically in the access path syntax, but the relevant access paths
21+
* can be generated dynamically in CodeQL, based on the usages found in the codebase.
22+
*
23+
* Subclasses should bind `this` to a unique identifier for the function being modelled. There is no special
24+
* interpreation of the `this` value, it should just not clash with the `this`-value used by other classes.
25+
*
26+
* For example, this models flow through calls such as `require("my-library").myFunction()`:
27+
* ```codeql
28+
* class MyFunction extends SummarizedCallable {
29+
* MyFunction() { this = "MyFunction" }
30+
*
31+
* override predicate propagatesFlow(string input, string output, boolean preservesValues) {
32+
* input = "Argument[0]" and
33+
* output = "ReturnValue" and
34+
* preservesValue = false
35+
* }
36+
*
37+
* override DataFlow::InvokeNode getACall() {
38+
* result = API::moduleImport("my-library").getMember("myFunction").getACall()
39+
* }
40+
* }
41+
* ```
42+
* This would be equivalent to the following model written as a data extension:
43+
* ```yaml
44+
* extensions:
45+
* - addsTo:
46+
* pack: codeql/javascript-all
47+
* extensible: summaryModel
48+
* data:
49+
* - ["my-library", "Member[myFunction]", "Argument[0]", "ReturnValue", "taint"]
50+
* ```
51+
*/
1052
abstract class SummarizedCallable extends LibraryCallable, Impl::Public::SummarizedCallable {
1153
bindingset[this]
1254
SummarizedCallable() { any() }
@@ -15,6 +57,9 @@ abstract class SummarizedCallable extends LibraryCallable, Impl::Public::Summari
1557
* Holds if data may flow from `input` to `output` through this callable.
1658
*
1759
* `preservesValue` indicates whether this is a value-preserving step or a taint-step.
60+
*
61+
* See the [library customization docs](https://codeql.github.com/docs/codeql-language-guides/customizing-library-models-for-javascript) for
62+
* the syntax of the `input` and `output` parameters.
1863
*/
1964
pragma[nomagic]
2065
predicate propagatesFlow(string input, string output, boolean preservesValue) { none() }

0 commit comments

Comments
 (0)