@@ -26,7 +26,7 @@ private module Sendgrid {
2626 }
2727
2828 /** Gets a reference to a `SendGridAPIClient` instance call with `send` or `post`. */
29- private DataFlow :: CallCfgNode sendgridApiSendCall ( ) {
29+ private API :: CallNode sendgridApiSendCall ( ) {
3030 result = sendgridApiClient ( ) .getMember ( "send" ) .getACall ( )
3131 or
3232 result =
@@ -62,7 +62,7 @@ private module Sendgrid {
6262 * * `getFrom()`'s result would be `"from@example.com"`.
6363 * * `getSubject()`'s result would be `"Sending with SendGrid is Fun"`.
6464 */
65- private class SendGridMail extends DataFlow :: CallCfgNode , EmailSender:: Range {
65+ private class SendGridMail extends API :: CallNode , EmailSender:: Range {
6666 SendGridMail ( ) { this = sendgridApiSendCall ( ) }
6767
6868 private DataFlow:: CallCfgNode getMailCall ( ) {
@@ -118,40 +118,28 @@ private module Sendgrid {
118118 or
119119 result = this .sendgridWrite ( "html_content" )
120120 or
121- exists ( KeyValuePair content , Dict generalDict , KeyValuePair typePair , KeyValuePair valuePair |
122- content .getKey ( ) .( StrConst ) .getText ( ) = "content" and
123- content .getValue ( ) .( List ) .getAnElt ( ) = generalDict and
124- // declare KeyValuePairs keys and values
125- typePair .getKey ( ) .( StrConst ) .getText ( ) = "type" and
126- typePair .getValue ( ) .( StrConst ) .getText ( ) = [ "text/html" , "text/x-amp-html" ] and
127- valuePair .getKey ( ) .( StrConst ) .getText ( ) = "value" and
128- result .asExpr ( ) = valuePair .getValue ( ) and
129- // correlate generalDict with previously set KeyValuePairs
130- generalDict .getAnItem ( ) in [ typePair , valuePair ] and
131- [ this .getArg ( 0 ) , this .getArgByName ( "request_body" ) ] .getALocalSource ( ) .asExpr ( ) =
132- any ( Dict d | d .getAnItem ( ) = content )
121+ exists ( API:: Node contentElement |
122+ contentElement =
123+ this .getKeywordParameter ( "request_body" ) .getSubscript ( "content" ) .getASubscript ( )
124+ |
125+ contentElement .getSubscript ( "type" ) .getAValueReachingSink ( ) .asExpr ( ) .( StrConst ) .getText ( ) =
126+ [ "text/html" , "text/x-amp-html" ] and
127+ result = contentElement .getSubscript ( "value" ) .getAValueReachingSink ( )
133128 )
134129 or
135- exists ( KeyValuePair footer , Dict generalDict , KeyValuePair enablePair , KeyValuePair htmlPair |
136- footer .getKey ( ) .( StrConst ) .getText ( ) = [ "footer" , "subscription_tracking" ] and
137- footer .getValue ( ) = generalDict and
138- // check footer is enabled
139- enablePair .getKey ( ) .( StrConst ) .getText ( ) = "enable" and
140- exists ( enablePair .getValue ( ) .( True ) ) and
141- // get html content
142- htmlPair .getKey ( ) .( StrConst ) .getText ( ) = "html" and
143- result .asExpr ( ) = htmlPair .getValue ( ) and
144- // correlate generalDict with previously set KeyValuePairs
145- generalDict .getAnItem ( ) in [ enablePair , htmlPair ] and
146- exists ( KeyValuePair k |
147- k .getKey ( ) =
148- [ this .getArg ( 0 ) , this .getArgByName ( "request_body" ) ]
149- .getALocalSource ( )
150- .asExpr ( )
151- .( Dict )
152- .getAKey ( ) and
153- k .getValue ( ) = any ( Dict d | d .getAKey ( ) = footer .getKey ( ) )
154- )
130+ exists ( API:: Node html |
131+ html =
132+ this .getKeywordParameter ( "request_body" )
133+ .getSubscript ( "tracking_settings" )
134+ .getSubscript ( "subscription_tracking" )
135+ or
136+ html =
137+ this .getKeywordParameter ( "request_body" )
138+ .getSubscript ( "mail_settings" )
139+ .getSubscript ( "footer" )
140+ |
141+ html .getSubscript ( "enable" ) .getAValueReachingSink ( ) .asExpr ( ) instanceof True and
142+ result = html .getSubscript ( "html" ) .getAValueReachingSink ( )
155143 )
156144 }
157145
0 commit comments