Skip to content

Commit 3c12e43

Browse files
author
Alvaro Muñoz
committed
feat(composite-actions): Fix summary and source queries for composite actions analysis
1 parent 7008827 commit 3c12e43

File tree

4 files changed

+32
-28
lines changed

4 files changed

+32
-28
lines changed

ql/lib/codeql/actions/dataflow/internal/DataFlowPrivate.qll

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -139,31 +139,6 @@ newtype TContent =
139139
name = any(JobsCtxAccessExpr a).getFieldName()
140140
}
141141

142-
/**
143-
* A reference contained in an object. Examples include instance fields, the
144-
* contents of a collection object, the contents of an array or pointer.
145-
*/
146-
class Content extends TContent {
147-
/** Gets the type of the contained data for the purpose of type pruning. */
148-
DataFlowType getType() { any() }
149-
150-
/** Gets a textual representation of this element. */
151-
abstract string toString();
152-
153-
/**
154-
* Holds if this element is at the specified location.
155-
* The location spans column `startcolumn` of line `startline` to
156-
* column `endcolumn` of line `endline` in file `filepath`.
157-
* For more information, see
158-
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
159-
*/
160-
predicate hasLocationInfo(
161-
string filepath, int startline, int startcolumn, int endline, int endcolumn
162-
) {
163-
filepath = "" and startline = 0 and startcolumn = 0 and endline = 0 and endcolumn = 0
164-
}
165-
}
166-
167142
predicate forceHighPrecision(Content c) { c instanceof FieldContent }
168143

169144
class ContentApprox = ContentSet;

ql/lib/codeql/actions/dataflow/internal/DataFlowPublic.qll

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,31 @@ class ContentSet instanceof Content {
130130
}
131131
}
132132

133+
/**
134+
* A reference contained in an object. Examples include instance fields, the
135+
* contents of a collection object, the contents of an array or pointer.
136+
*/
137+
class Content extends TContent {
138+
/** Gets the type of the contained data for the purpose of type pruning. */
139+
DataFlowType getType() { any() }
140+
141+
/** Gets a textual representation of this element. */
142+
abstract string toString();
143+
144+
/**
145+
* Holds if this element is at the specified location.
146+
* The location spans column `startcolumn` of line `startline` to
147+
* column `endcolumn` of line `endline` in file `filepath`.
148+
* For more information, see
149+
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
150+
*/
151+
predicate hasLocationInfo(
152+
string filepath, int startline, int startcolumn, int endline, int endcolumn
153+
) {
154+
filepath = "" and startline = 0 and startcolumn = 0 and endline = 0 and endcolumn = 0
155+
}
156+
}
157+
133158
/** A field of an object, for example an instance variable. */
134159
class FieldContent extends Content, TFieldContent {
135160
private string name;

ql/src/Security/CWE-020/CompositeActionSummaries.ql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ import codeql.actions.dataflow.ExternalFlow
1717

1818
private module MyConfig implements DataFlow::ConfigSig {
1919
predicate isSource(DataFlow::Node source) {
20-
source instanceof DataFlow::ParameterNode and
2120
exists(CompositeActionStmt c | c.getInputsStmt().getInputExpr(_) = source.asExpr())
2221
}
2322

2423
predicate isSink(DataFlow::Node sink) {
25-
sink instanceof DataFlow::ReturnNode and
2624
exists(CompositeActionStmt c | c.getOutputsStmt().getOutputExpr(_) = sink.asExpr())
2725
}
2826
}

ql/src/Security/CWE-020/CompositeActionsSources.ql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@ private module MyConfig implements DataFlow::ConfigSig {
2323
}
2424

2525
predicate isSink(DataFlow::Node sink) {
26-
sink instanceof DataFlow::ReturnNode and
2726
exists(CompositeActionStmt c | c.getOutputsStmt().getOutputExpr(_) = sink.asExpr())
2827
}
28+
29+
predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet set) {
30+
allowImplicitRead(node, set)
31+
or
32+
isSink(node) and
33+
set instanceof DataFlow::FieldContent
34+
}
2935
}
3036

3137
module MyFlow = TaintTracking::Global<MyConfig>;

0 commit comments

Comments
 (0)