|
| 1 | +/** |
| 2 | + * Models the `ActionMailbox` library, which is part of Rails. |
| 3 | + * Version: 7.0.4. |
| 4 | + */ |
| 5 | + |
| 6 | +private import codeql.ruby.AST |
| 7 | +private import codeql.ruby.Concepts |
| 8 | +private import codeql.ruby.DataFlow |
| 9 | +private import codeql.ruby.dataflow.RemoteFlowSources |
| 10 | + |
| 11 | +/** |
| 12 | + * Models the `ActionMailbox` library, which is part of Rails. |
| 13 | + * Version: 7.0.4. |
| 14 | + */ |
| 15 | +module ActionMailbox { |
| 16 | + private DataFlow::ClassNode controller() { |
| 17 | + result = DataFlow::getConstant("ActionMailbox").getConstant("Base").getADescendentModule() |
| 18 | + } |
| 19 | + |
| 20 | + /** |
| 21 | + * A call to `mail` on the return value of |
| 22 | + * `ActionMailbox::Base#inbound_email`, or a direct call to |
| 23 | + * `ActionMailbox::Base#mail`, which is equivalent. The returned object |
| 24 | + * contains data from the incoming email. |
| 25 | + */ |
| 26 | + class Mail extends DataFlow::CallNode { |
| 27 | + Mail() { |
| 28 | + this = |
| 29 | + [ |
| 30 | + controller().getAnInstanceSelf().getAMethodCall("inbound_email").getAMethodCall("mail"), |
| 31 | + controller().getAnInstanceSelf().getAMethodCall("mail") |
| 32 | + ] |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * A method call on a `Mail::Message` object which may return data from a remote source. |
| 38 | + */ |
| 39 | + private class RemoteContent extends DataFlow::CallNode, RemoteFlowSource::Range { |
| 40 | + RemoteContent() { |
| 41 | + this = |
| 42 | + any(Mail m) |
| 43 | + .(DataFlow::LocalSourceNode) |
| 44 | + .getAMethodCall([ |
| 45 | + "body", "to", "from", "raw_source", "subject", "from_address", |
| 46 | + "recipients_addresses", "cc_addresses", "bcc_addresses", "in_reply_to", |
| 47 | + "references", "reply_to", "raw_envelope", "to_s", "encoded", "header", "bcc", "cc", |
| 48 | + "text_part", "html_part" |
| 49 | + ]) |
| 50 | + } |
| 51 | + |
| 52 | + override string getSourceType() { result = "ActionMailbox" } |
| 53 | + } |
| 54 | +} |
0 commit comments