Skip to content

Commit 048daa9

Browse files
committed
Swift: QLDoc comments and metadata.
1 parent e011480 commit 048daa9

File tree

3 files changed

+32
-21
lines changed

3 files changed

+32
-21
lines changed

swift/ql/lib/codeql/swift/security/CommandInjectionExtensions.qll

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,34 +29,26 @@ class CommandInjectionAdditionalFlowStep extends Unit {
2929
abstract predicate step(DataFlow::Node nodeFrom, DataFlow::Node nodeTo);
3030
}
3131

32-
private class ProcessSink2 extends CommandInjectionSink instanceof DataFlow::Node {
33-
ProcessSink2() {
34-
exists(AssignExpr assign, ProcessHost s |
35-
assign.getDest() = s and
36-
this.asExpr() = assign.getSource()
37-
)
38-
or
39-
exists(AssignExpr assign, ProcessHost s, ArrayExpr a |
40-
assign.getDest() = s and
41-
a = assign.getSource() and
42-
this.asExpr() = a.getAnElement()
43-
)
44-
}
45-
}
46-
32+
/**
33+
* A reference to any member of `Process`.
34+
*/
4735
private class ProcessHost extends MemberRefExpr {
4836
ProcessHost() { this.getBase() instanceof ProcessRef }
4937
}
5038

51-
/** An expression of type `Process`. */
39+
/**
40+
* An expression of type `Process`.
41+
*/
5242
private class ProcessRef extends Expr {
5343
ProcessRef() {
5444
this.getType() instanceof ProcessType or
5545
this.getType() = any(OptionalType t | t.getBaseType() instanceof ProcessType)
5646
}
5747
}
5848

59-
/** The type `Process`. */
49+
/**
50+
* The type `Process`.
51+
*/
6052
private class ProcessType extends NominalType {
6153
ProcessType() { this.getFullName() = "Process" }
6254
}
@@ -77,6 +69,24 @@ private class ProcessSink extends CommandInjectionSink instanceof DataFlow::Node
7769
}
7870
}
7971

72+
/**
73+
* A `DataFlow::Node` that is written into a field of a `Process` object.
74+
*/
75+
private class ProcessSink2 extends CommandInjectionSink instanceof DataFlow::Node {
76+
ProcessSink2() {
77+
exists(AssignExpr assign, ProcessHost s |
78+
assign.getDest() = s and
79+
this.asExpr() = assign.getSource()
80+
)
81+
or
82+
exists(AssignExpr assign, ProcessHost s, ArrayExpr a |
83+
assign.getDest() = s and
84+
a = assign.getSource() and
85+
this.asExpr() = a.getAnElement()
86+
)
87+
}
88+
}
89+
8090
/**
8191
* A sink defined in a CSV model.
8292
*/

swift/ql/lib/codeql/swift/security/CommandInjectionQuery.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Provides a taint-tracking configuration for reasoning about system
3-
* commands built from user-controlled sources (that is, Command injection
3+
* commands built from user-controlled sources (that is, command injection
44
* vulnerabilities).
55
*/
66

@@ -11,7 +11,7 @@ import codeql.swift.dataflow.FlowSources
1111
import codeql.swift.security.CommandInjectionExtensions
1212

1313
/**
14-
* A taint configuration for tainted data that reaches a Command Injection sink.
14+
* A taint configuration for tainted data that reaches a command injection sink.
1515
*/
1616
module CommandInjectionConfig implements DataFlow::ConfigSig {
1717
predicate isSource(DataFlow::Node node) { node instanceof FlowSource }
@@ -26,6 +26,6 @@ module CommandInjectionConfig implements DataFlow::ConfigSig {
2626
}
2727

2828
/**
29-
* Detect taint flow of tainted data that reaches a Command Injection sink.
29+
* Detect taint flow of tainted data that reaches a command injection sink.
3030
*/
3131
module CommandInjectionFlow = TaintTracking::Global<CommandInjectionConfig>;

swift/ql/src/experimental/Security/CWE-078/CommandInjection.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @name System command built from user-controlled sources
3-
* @description Building a system command from user-controlled sources is vulnerable to insertion of malicious code by the user.
3+
* @description Building a system command from user-controlled sources may allow a malicious
4+
* user to change the meaning of the command.
45
* @kind path-problem
56
* @problem.severity error
67
* @security-severity 9.8

0 commit comments

Comments
 (0)