@@ -33,6 +33,9 @@ class SensitiveNode extends DataFlow::Node {
33
33
}
34
34
}
35
35
36
+ /**
37
+ * A function that sends or receives data over a network.
38
+ */
36
39
abstract class SendRecv extends Function {
37
40
/**
38
41
* Gets the expression for the socket or similar object used for sending or
@@ -41,11 +44,15 @@ abstract class SendRecv extends Function {
41
44
abstract Expr getSocketExpr ( Call call ) ;
42
45
43
46
/**
44
- * Gets the expression for the buffer to be sent from / received into.
47
+ * Gets the expression for the buffer to be sent from / received into through
48
+ * the function call `call`.
45
49
*/
46
50
abstract Expr getDataExpr ( Call call ) ;
47
51
}
48
52
53
+ /**
54
+ * A function that sends data over a network.
55
+ */
49
56
class Send extends SendRecv instanceof RemoteFlowSinkFunction {
50
57
override Expr getSocketExpr ( Call call ) {
51
58
call .getTarget ( ) = this and
@@ -66,6 +73,9 @@ class Send extends SendRecv instanceof RemoteFlowSinkFunction {
66
73
}
67
74
}
68
75
76
+ /**
77
+ * A function that receives data over a network.
78
+ */
69
79
class Recv extends SendRecv instanceof RemoteFlowSourceFunction {
70
80
override Expr getSocketExpr ( Call call ) {
71
81
call .getTarget ( ) = this and
@@ -89,18 +99,21 @@ class Recv extends SendRecv instanceof RemoteFlowSourceFunction {
89
99
/**
90
100
* A function call that sends or receives data over a network.
91
101
*
92
- * note: functions such as `write` may be writing to a network source or a
93
- * file. We could attempt to determine which, and sort results into
102
+ * note: function calls such as `write` may be writing to a network source
103
+ * or a file. We could attempt to determine which, and sort results into
94
104
* `cpp/cleartext-transmission` and perhaps `cpp/cleartext-storage-file`. In
95
105
* practice it usually isn't very important which query reports a result as
96
- * long as its reported exactly once. See `checkSocket` to narrow this down
97
- * somewhat.
106
+ * long as its reported exactly once.
107
+ *
108
+ * We do exclude function calls that specify a constant socket, which is
109
+ * likely to mean standard input, standard output or a similar channel.
98
110
*/
99
111
abstract class NetworkSendRecv extends FunctionCall {
100
112
SendRecv target ;
101
113
102
114
NetworkSendRecv ( ) {
103
115
this .getTarget ( ) = target and
116
+ // exclude calls based on the socket...
104
117
not exists ( GVN g |
105
118
g = globalValueNumber ( target .getSocketExpr ( this ) ) and
106
119
(
0 commit comments