|
13 | 13 |
|
14 | 14 | import javascript |
15 | 15 |
|
16 | | -/** |
17 | | - * Gets an options object for a TLS connection. |
18 | | - */ |
19 | | -DataFlow::ObjectLiteralNode tlsOptions() { |
20 | | - exists(DataFlow::InvokeNode invk | result.flowsTo(invk.getAnArgument()) | |
21 | | - invk instanceof ClientRequest |
22 | | - or |
23 | | - invk = DataFlow::moduleMember("https", "Agent").getAnInstantiation() |
24 | | - or |
25 | | - exists(DataFlow::NewNode new | |
26 | | - new = DataFlow::moduleMember("tls", "TLSSocket").getAnInstantiation() |
27 | | - | |
28 | | - invk = new or |
29 | | - invk = new.getAMethodCall("renegotiate") |
30 | | - ) |
31 | | - or |
32 | | - invk = DataFlow::moduleMember("tls", ["connect", "createServer"]).getACall() |
| 16 | +/** Gets options argument for a potential TLS connection */ |
| 17 | +DataFlow::InvokeNode tlsInvocation() { |
| 18 | + result instanceof ClientRequest |
| 19 | + or |
| 20 | + result = DataFlow::moduleMember("https", "Agent").getAnInstantiation() |
| 21 | + or |
| 22 | + exists(DataFlow::NewNode new | |
| 23 | + new = DataFlow::moduleMember("tls", "TLSSocket").getAnInstantiation() |
| 24 | + | |
| 25 | + result = new or |
| 26 | + result = new.getAMethodCall("renegotiate") |
33 | 27 | ) |
| 28 | + or |
| 29 | + result = DataFlow::moduleMember("tls", ["connect", "createServer"]).getACall() |
34 | 30 | } |
35 | 31 |
|
| 32 | +/** Gets an options object for a TLS connection. */ |
| 33 | +DataFlow::ObjectLiteralNode tlsOptions() { result.flowsTo(tlsInvocation().getAnArgument()) } |
| 34 | + |
36 | 35 | from DataFlow::PropWrite disable |
37 | 36 | where |
38 | 37 | exists(DataFlow::SourceNode env | |
|
41 | 40 | disable.getRhs().mayHaveStringValue("0") |
42 | 41 | ) |
43 | 42 | or |
44 | | - disable = tlsOptions().getAPropertyWrite("rejectUnauthorized") and |
| 43 | + ( |
| 44 | + disable = tlsOptions().getAPropertyWrite("rejectUnauthorized") |
| 45 | + or |
| 46 | + // the same thing, but with API-nodes if they happen to be available |
| 47 | + exists(API::Node tlsInvk | tlsInvk.getAnInvocation() = tlsInvocation() | |
| 48 | + disable.getRhs() = tlsInvk.getAParameter().getMember("rejectUnauthorized").getARhs() |
| 49 | + ) |
| 50 | + ) and |
45 | 51 | disable.getRhs().(AnalyzedNode).getTheBooleanValue() = false |
46 | 52 | select disable, "Disabling certificate validation is strongly discouraged." |
0 commit comments