@@ -58,7 +58,7 @@ class FlowToPrint extends DataFlow::Configuration {
5858}
5959
6060/** Holds if the provided CallNode's result flows to a Printer call as argument. */
61- predicate flowsToPrinter ( DataFlow:: CallNode authCodeURLCall ) {
61+ predicate resultFlowsToPrinter ( DataFlow:: CallNode authCodeURLCall ) {
6262 exists ( FlowToPrint cfg , DataFlow:: PathNode source , DataFlow:: PathNode sink |
6363 cfg .hasFlowPath ( source , sink ) and
6464 cfg .isSource ( source .getNode ( ) , authCodeURLCall )
@@ -78,16 +78,24 @@ predicate rootContainsCallToStdinScanner(DataFlow::CallNode authCodeURLCall) {
7878 )
7979}
8080
81+ /**
82+ * Holds if the authCodeURLCall seems to be done within a terminal
83+ * because there are calls to a Printer (fmt.Println and similar),
84+ * and a call to a Scanner (fmt.Scan and similar),
85+ * all of which are typically done within a terminal session.
86+ */
87+ predicate seemsLikeDoneWithinATerminal ( DataFlow:: CallNode authCodeURLCall ) {
88+ resultFlowsToPrinter ( authCodeURLCall ) and
89+ rootContainsCallToStdinScanner ( authCodeURLCall )
90+ }
91+
8192from
8293 ConstantStateFlowConf cfg , DataFlow:: PathNode source , DataFlow:: PathNode sink ,
8394 DataFlow:: CallNode sinkCall
8495where
8596 cfg .hasFlowPath ( source , sink ) and
8697 cfg .isSink ( sink .getNode ( ) , sinkCall ) and
8798 // Exclude cases that seem to be oauth flows done from within a terminal:
88- not (
89- flowsToPrinter ( sinkCall ) and
90- rootContainsCallToStdinScanner ( sinkCall )
91- )
99+ not seemsLikeDoneWithinATerminal ( sinkCall )
92100select sink .getNode ( ) , source , sink , "Using a constant $@ to create oauth2 URLs." , source .getNode ( ) ,
93101 "state string"
0 commit comments