|
5 | 5 | import javascript |
6 | 6 |
|
7 | 7 | /** |
8 | | - * Classes and predicate modelling the `Busboy` library. |
| 8 | + * A source of remote flow from the `Busboy` library. |
9 | 9 | */ |
10 | | -private module Busboy { |
11 | | - /** |
12 | | - * A `Busboy` instance that has request data flowing into it. |
13 | | - */ |
14 | | - private DataFlow::NewNode busboy() { |
15 | | - result = DataFlow::moduleImport("busboy").getAnInstantiation() and |
16 | | - exists(MethodCallExpr pipe | |
17 | | - pipe.calls(any(HTTP::RequestExpr req), "pipe") and |
18 | | - result.flowsToExpr(pipe.getArgument(0)) |
19 | | - ) |
| 10 | +private class BusBoyRemoteFlow extends RemoteFlowSource { |
| 11 | + BusBoyRemoteFlow() { |
| 12 | + this = |
| 13 | + API::moduleImport("busboy") |
| 14 | + .getInstance() |
| 15 | + .getMember("on") |
| 16 | + .getParameter(1) |
| 17 | + .getAParameter() |
| 18 | + .getAnImmediateUse() |
20 | 19 | } |
21 | 20 |
|
22 | | - /** |
23 | | - * A source of remote flow from the `Busboy` library. |
24 | | - */ |
25 | | - class BusBoyRemoteFlow extends RemoteFlowSource { |
26 | | - BusBoyRemoteFlow() { this = busboy().getAMemberCall("on").getABoundCallbackParameter(1, _) } |
27 | | - |
28 | | - override string getSourceType() { result = "parsed user value from Busbuy" } |
29 | | - } |
| 21 | + override string getSourceType() { result = "parsed user value from Busbuy" } |
30 | 22 | } |
31 | 23 |
|
32 | 24 | /** |
33 | 25 | * A source of remote flow from the `Formidable` library parsing a HTTP request. |
34 | 26 | */ |
35 | 27 | private class FormidableRemoteFlow extends RemoteFlowSource { |
36 | 28 | FormidableRemoteFlow() { |
37 | | - exists(DataFlow::CallNode parse, DataFlow::InvokeNode formidable | |
38 | | - formidable = DataFlow::moduleImport("formidable").getACall() |
| 29 | + exists(API::Node formidable | |
| 30 | + formidable = API::moduleImport("formidable").getReturn() |
39 | 31 | or |
40 | | - formidable = DataFlow::moduleMember("formidable", "formidable").getACall() |
| 32 | + formidable = API::moduleImport("formidable").getMember("formidable").getReturn() |
41 | 33 | or |
42 | 34 | formidable = |
43 | | - DataFlow::moduleMember("formidable", ["IncomingForm", "Formidable"]).getAnInstantiation() |
| 35 | + API::moduleImport("formidable").getMember(["IncomingForm", "Formidable"]).getInstance() |
44 | 36 | | |
45 | | - parse = formidable.getAMemberCall("parse") and |
46 | | - parse.getArgument(0).asExpr() instanceof HTTP::RequestExpr and |
47 | | - this = parse.getABoundCallbackParameter(1, any(int i | i > 0)) |
| 37 | + this = |
| 38 | + formidable.getMember("parse").getACall().getABoundCallbackParameter(1, any(int i | i > 0)) |
48 | 39 | ) |
49 | 40 | } |
50 | 41 |
|
51 | 42 | override string getSourceType() { result = "parsed user value from Formidable" } |
52 | 43 | } |
53 | 44 |
|
54 | 45 | /** |
55 | | - * Predicates and classes modelling the `multiparty` library. |
| 46 | + * A source of remote flow from the `Multiparty` library. |
56 | 47 | */ |
57 | | -private module Multiparty { |
58 | | - /** |
59 | | - * Gets an instance of of `Multiparty` form parser that parses a HTTP request object. |
60 | | - * The `parse` call is the method call that receives the HTTP request object. |
61 | | - */ |
62 | | - private DataFlow::SourceNode form(DataFlow::MethodCallNode parse) { |
63 | | - result = DataFlow::moduleMember("multiparty", "Form").getAnInstantiation() and |
64 | | - parse = result.getAMethodCall("parse") and |
65 | | - parse.getArgument(0).asExpr() instanceof HTTP::RequestExpr |
66 | | - } |
67 | | - |
68 | | - /** |
69 | | - * A source of remote flow from the `Multiparty` library. |
70 | | - */ |
71 | | - class MultipartyRemoteFlow extends RemoteFlowSource { |
72 | | - MultipartyRemoteFlow() { |
73 | | - exists(DataFlow::MethodCallNode parse | exists(form(parse)) | |
74 | | - this = parse.getABoundCallbackParameter(1, any(int i | i > 0)) |
| 48 | +private class MultipartyRemoteFlow extends RemoteFlowSource { |
| 49 | + MultipartyRemoteFlow() { |
| 50 | + exists(API::Node form | form = API::moduleImport("multiparty").getMember("Form").getInstance() | |
| 51 | + exists(API::CallNode parse | parse = form.getMember("parse").getACall() | |
| 52 | + this = parse.getParameter(1).getAParameter().getAnImmediateUse() |
75 | 53 | ) |
76 | 54 | or |
77 | | - exists(DataFlow::MethodCallNode on | on = form(_).getAMethodCall("on") | |
| 55 | + exists(API::CallNode on | on = form.getMember("on").getACall() | |
78 | 56 | on.getArgument(0).mayHaveStringValue(["part", "file", "field"]) and |
79 | | - this = on.getABoundCallbackParameter(1, _) |
| 57 | + this = on.getParameter(1).getAParameter().getAnImmediateUse() |
80 | 58 | ) |
81 | | - } |
82 | | - |
83 | | - override string getSourceType() { result = "parsed user value from Multiparty" } |
| 59 | + ) |
84 | 60 | } |
| 61 | + |
| 62 | + override string getSourceType() { result = "parsed user value from Multiparty" } |
85 | 63 | } |
0 commit comments