@@ -68,6 +68,11 @@ class ClientRequest extends DataFlow::InvokeNode {
6868 * wrapped in a promise object.
6969 */
7070 DataFlow:: Node getAResponseDataNode ( ) { result = getAResponseDataNode ( _, _) }
71+
72+ /**
73+ * Gets a data-flow node that determines where in the file-system the result of the request should be saved.
74+ */
75+ DataFlow:: Node getASavePath ( ) { result = self .getASavePath ( ) }
7176}
7277
7378deprecated class CustomClientRequest = ClientRequest:: Range ;
@@ -103,6 +108,11 @@ module ClientRequest {
103108 * See the decription of `responseType` in `ClientRequest::getAResponseDataNode`.
104109 */
105110 DataFlow:: Node getAResponseDataNode ( string responseType , boolean promise ) { none ( ) }
111+
112+ /**
113+ * Gets a data-flow node that determines where in the file-system the result of the request should be saved.
114+ */
115+ DataFlow:: Node getASavePath ( ) { none ( ) }
106116 }
107117
108118 /**
@@ -180,6 +190,14 @@ module ClientRequest {
180190 }
181191
182192 override DataFlow:: Node getADataNode ( ) { result = getArgument ( 1 ) }
193+
194+ override DataFlow:: Node getASavePath ( ) {
195+ exists ( DataFlow:: CallNode write |
196+ write = DataFlow:: moduleMember ( "fs" , "createWriteStream" ) .getACall ( ) and
197+ write = this .getAMemberCall ( "pipe" ) .getArgument ( 0 ) .getALocalSource ( ) and
198+ result = write .getArgument ( 0 )
199+ )
200+ }
183201 }
184202
185203 /** Gets the string `url` or `uri`. */
@@ -632,6 +650,10 @@ module ClientRequest {
632650 override DataFlow:: Node getHost ( ) { none ( ) }
633651
634652 override DataFlow:: Node getADataNode ( ) { none ( ) }
653+
654+ override DataFlow:: Node getASavePath ( ) {
655+ result = this .getArgument ( 1 ) .getALocalSource ( ) .getAPropertyWrite ( "target" ) .getRhs ( )
656+ }
635657 }
636658
637659 /**
0 commit comments