@@ -33,6 +33,9 @@ class SensitiveNode extends DataFlow::Node {
3333 }
3434}
3535
36+ /**
37+ * A function that sends or receives data over a network.
38+ */
3639abstract class SendRecv extends Function {
3740 /**
3841 * Gets the expression for the socket or similar object used for sending or
@@ -41,11 +44,15 @@ abstract class SendRecv extends Function {
4144 abstract Expr getSocketExpr ( Call call ) ;
4245
4346 /**
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`.
4549 */
4650 abstract Expr getDataExpr ( Call call ) ;
4751}
4852
53+ /**
54+ * A function that sends data over a network.
55+ */
4956class Send extends SendRecv instanceof RemoteFlowSinkFunction {
5057 override Expr getSocketExpr ( Call call ) {
5158 call .getTarget ( ) = this and
@@ -66,6 +73,9 @@ class Send extends SendRecv instanceof RemoteFlowSinkFunction {
6673 }
6774}
6875
76+ /**
77+ * A function that receives data over a network.
78+ */
6979class Recv extends SendRecv instanceof RemoteFlowSourceFunction {
7080 override Expr getSocketExpr ( Call call ) {
7181 call .getTarget ( ) = this and
@@ -89,18 +99,21 @@ class Recv extends SendRecv instanceof RemoteFlowSourceFunction {
8999/**
90100 * A function call that sends or receives data over a network.
91101 *
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
94104 * `cpp/cleartext-transmission` and perhaps `cpp/cleartext-storage-file`. In
95105 * 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.
98110 */
99111abstract class NetworkSendRecv extends FunctionCall {
100112 SendRecv target ;
101113
102114 NetworkSendRecv ( ) {
103115 this .getTarget ( ) = target and
116+ // exclude calls based on the socket...
104117 not exists ( GVN g |
105118 g = globalValueNumber ( target .getSocketExpr ( this ) ) and
106119 (
0 commit comments