Make EmailSender an extendable API

This commit is contained in:
jorgectf
2021-11-13 14:23:11 +01:00
parent 63eadc8441
commit dbdf102ea6

View File

@@ -297,10 +297,15 @@ class HeaderDeclaration extends DataFlow::Node {
DataFlow::Node getValueArg() { result = range.getValueArg() }
}
/** Provides classes for modeling Email APIs. */
module EmailSender {
/**
* An operation that sends an email.
* A data-flow node that sends an email.
*
* Extend this class to model new APIs. If you want to refine existing API models,
* extend `EmailSender` instead.
*/
abstract class EmailSender extends DataFlow::CallCfgNode {
abstract class Range extends DataFlow::Node {
/**
* Gets a data flow node holding the plaintext version of the email body.
*/
@@ -325,9 +330,47 @@ abstract class EmailSender extends DataFlow::CallCfgNode {
* Gets a data flow node holding the subject of the email.
*/
abstract DataFlow::Node getSubject();
}
}
/**
* A data-flow node that sends an email..
*
* Extend this class to refine existing API models. If you want to model new APIs,
* extend `EmailSender::Range` instead.
*/
class EmailSender extends DataFlow::Node {
EmailSender::Range range;
EmailSender() { this = range }
/**
* Gets a data flow node holding the plaintext version of the email body.
*/
DataFlow::Node getPlainTextBody() { result = range.getPlainTextBody() }
/**
* Gets a data flow node holding the html version of the email body.
*/
DataFlow::Node getHtmlBody() { result = range.getHtmlBody() }
/**
* Gets a data flow node holding the recipients of the email.
*/
DataFlow::Node getTo() { result = range.getTo() }
/**
* Gets a data flow node holding the senders of the email.
*/
DataFlow::Node getFrom() { result = range.getFrom() }
/**
* Gets a data flow node holding the subject of the email.
*/
DataFlow::Node getSubject() { result = range.getSubject() }
/**
* Gets a data flow node that refers to the HTML body or plaintext body of the email.
*/
DataFlow::Node getABody() { result in [getPlainTextBody(), getHtmlBody()] }
DataFlow::Node getABody() { result in [range.getPlainTextBody(), range.getHtmlBody()] }
}