Skip to content

Commit 6722671

Browse files
jorgectfyoff
andcommitted
Refactor sendgridApiClient and sendgridApiSendCall
Co-authored-by: yoff <lerchedahl@gmail.com>
1 parent 3159d8e commit 6722671

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

  • python/ql/src/experimental/semmle/python/frameworks

python/ql/src/experimental/semmle/python/frameworks/Sendgrid.qll

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,21 @@ private module Sendgrid {
2424
private DataFlow::CallCfgNode sendgridMailCall() { result = sendgridMailInstance().getACall() }
2525

2626
/** Gets a reference to a `SendGridAPIClient` instance. */
27-
private DataFlow::LocalSourceNode sendgridApiClient(DataFlow::TypeTracker t) {
28-
t.start() and
29-
result.(DataFlow::AttrRead).getObject*().getALocalSource() =
30-
sendgrid().getMember("SendGridAPIClient").getReturn().getAUse()
31-
or
32-
exists(DataFlow::TypeTracker t2 | result = sendgridApiClient(t2).track(t2, t))
33-
}
34-
35-
/** Gets a reference to a `SendGridAPIClient` instance use. */
36-
private DataFlow::Node sendgridApiClient() {
37-
sendgridApiClient(DataFlow::TypeTracker::end()).flowsTo(result)
27+
private API::Node sendgridApiClient() {
28+
result = sendgrid().getMember("SendGridAPIClient").getReturn()
3829
}
3930

4031
/** Gets a reference to a `SendGridAPIClient` instance call with `send` or `post`. */
41-
private DataFlow::Node sendgridApiSendCall() {
42-
result = sendgridApiClient() and
43-
result.(DataFlow::AttrRead).getAttributeName() in ["send", "post"]
32+
private DataFlow::CallCfgNode sendgridApiSendCall() {
33+
result = sendgridApiClient().getMember("send").getACall()
34+
or
35+
result =
36+
sendgridApiClient()
37+
.getMember("client")
38+
.getMember("mail")
39+
.getMember("send")
40+
.getMember("post")
41+
.getACall()
4442
}
4543

4644
private DataFlow::Node sendgridContent(DataFlow::CallCfgNode contentCall, string mime) {

0 commit comments

Comments
 (0)