Skip to content

Commit 80deee8

Browse files
committed
PS: Fixup PowerShell after github#21051.
1 parent 065ff29 commit 80deee8

File tree

4 files changed

+52
-30
lines changed

4 files changed

+52
-30
lines changed

powershell/ql/lib/semmle/code/powershell/dataflow/FlowSummary.qll

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,48 @@ private module Summaries {
1818
import EngineIntrinsics
1919
}
2020

21-
/** A callable with a flow summary, identified by a unique string. */
22-
abstract class SummarizedCallable extends LibraryCallable, Impl::Public::SummarizedCallable {
23-
bindingset[this]
24-
SummarizedCallable() { any() }
25-
26-
override predicate propagatesFlow(
27-
string input, string output, boolean preservesValue, string model
28-
) {
29-
this.propagatesFlow(input, output, preservesValue) and model = ""
30-
}
21+
class Provenance = Impl::Public::Provenance;
22+
23+
/** Provides the `Range` class used to define the extent of `SummarizedCallable`. */
24+
module SummarizedCallable {
25+
/** A callable with a flow summary, identified by a unique string. */
26+
abstract class Range extends LibraryCallable, Impl::Public::SummarizedCallable {
27+
bindingset[this]
28+
Range() { any() }
29+
30+
override predicate propagatesFlow(
31+
string input, string output, boolean preservesValue, Provenance p, boolean isExact,
32+
string model
33+
) {
34+
this.propagatesFlow(input, output, preservesValue) and
35+
p = "manual" and
36+
isExact = true and
37+
model = ""
38+
}
3139

32-
/**
33-
* Holds if data may flow from `input` to `output` through this callable.
34-
*
35-
* `preservesValue` indicates whether this is a value-preserving step or a taint-step.
36-
*/
37-
predicate propagatesFlow(string input, string output, boolean preservesValue) { none() }
38-
39-
/**
40-
* Gets the synthesized parameter that results from an input specification
41-
* that starts with `Argument[s]` for this library callable.
42-
*/
43-
DataFlow::ParameterNode getParameter(string s) {
44-
exists(ParameterPosition pos |
45-
DataFlowImplCommon::parameterNode(result, TLibraryCallable(this), pos) and
46-
s = Impl::Input::encodeParameterPosition(pos)
47-
)
40+
/**
41+
* Holds if data may flow from `input` to `output` through this callable.
42+
*
43+
* `preservesValue` indicates whether this is a value-preserving step or a taint-step.
44+
*/
45+
predicate propagatesFlow(string input, string output, boolean preservesValue) { none() }
46+
47+
/**
48+
* Gets the synthesized parameter that results from an input specification
49+
* that starts with `Argument[s]` for this library callable.
50+
*/
51+
DataFlow::ParameterNode getParameter(string s) {
52+
exists(ParameterPosition pos |
53+
DataFlowImplCommon::parameterNode(result, TLibraryCallable(this), pos) and
54+
s = Impl::Input::encodeParameterPosition(pos)
55+
)
56+
}
4857
}
4958
}
59+
60+
final private class SummarizedCallableFinal = SummarizedCallable::Range;
61+
62+
/** A callable with a flow summary, identified by a unique string. */
63+
final class SummarizedCallable extends SummarizedCallableFinal,
64+
Impl::Public::RelevantSummarizedCallable
65+
{ }

powershell/ql/lib/semmle/code/powershell/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ module Input implements InputSig<Location, DataFlowImplSpecific::PowershellDataF
1818

1919
class SinkBase = Void;
2020

21+
predicate callableFromSource(SummarizedCallableBase c) { none() }
22+
2123
ArgumentPosition callbackSelfParameterPosition() { none() }
2224

2325
ReturnKind getStandardReturnValueKind() { result instanceof NormalReturnKind }

powershell/ql/lib/semmle/code/powershell/frameworks/data/ModelsAsData.qll

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ private class RemoteFlowSourceFromCsv extends RemoteFlowSource::Range {
2121
override string getSourceType() { result = "Remote flow (from model)" }
2222
}
2323

24-
private class SummarizedCallableFromModel extends SummarizedCallable {
24+
private class SummarizedCallableFromModel extends SummarizedCallable::Range {
2525
string type;
2626
string path;
2727

@@ -38,9 +38,13 @@ private class SummarizedCallableFromModel extends SummarizedCallable {
3838
}
3939

4040
override predicate propagatesFlow(
41-
string input, string output, boolean preservesValue, string model
41+
string input, string output, boolean preservesValue, Provenance p, boolean isExact, string model
4242
) {
43-
exists(string kind | ModelOutput::relevantSummaryModel(type, path, input, output, kind, model) |
43+
exists(string kind |
44+
ModelOutput::relevantSummaryModel(type, path, input, output, kind, model) and
45+
p = "manual" and
46+
isExact = true
47+
|
4448
kind = "value" and
4549
preservesValue = true
4650
or

powershell/ql/lib/semmle/code/powershell/typetracking/internal/TypeTrackingImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private module SummaryTypeTrackerInput implements SummaryTypeTracker::Input {
118118
predicate propagatesFlow(
119119
SummaryComponentStack input, SummaryComponentStack output, boolean preservesValue
120120
) {
121-
super.propagatesFlow(input, output, preservesValue, _)
121+
super.propagatesFlow(input, output, preservesValue, _, _, _)
122122
}
123123
}
124124

0 commit comments

Comments
 (0)