Skip to content

Commit dbdf102

Browse files
committed
Make EmailSender an extendable API
1 parent 63eadc8 commit dbdf102

1 file changed

Lines changed: 51 additions & 8 deletions

File tree

python/ql/src/experimental/semmle/python/Concepts.qll

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -297,37 +297,80 @@ class HeaderDeclaration extends DataFlow::Node {
297297
DataFlow::Node getValueArg() { result = range.getValueArg() }
298298
}
299299

300+
/** Provides classes for modeling Email APIs. */
301+
module EmailSender {
302+
/**
303+
* A data-flow node that sends an email.
304+
*
305+
* Extend this class to model new APIs. If you want to refine existing API models,
306+
* extend `EmailSender` instead.
307+
*/
308+
abstract class Range extends DataFlow::Node {
309+
/**
310+
* Gets a data flow node holding the plaintext version of the email body.
311+
*/
312+
abstract DataFlow::Node getPlainTextBody();
313+
314+
/**
315+
* Gets a data flow node holding the html version of the email body.
316+
*/
317+
abstract DataFlow::Node getHtmlBody();
318+
319+
/**
320+
* Gets a data flow node holding the recipients of the email.
321+
*/
322+
abstract DataFlow::Node getTo();
323+
324+
/**
325+
* Gets a data flow node holding the senders of the email.
326+
*/
327+
abstract DataFlow::Node getFrom();
328+
329+
/**
330+
* Gets a data flow node holding the subject of the email.
331+
*/
332+
abstract DataFlow::Node getSubject();
333+
}
334+
}
335+
300336
/**
301-
* An operation that sends an email.
337+
* A data-flow node that sends an email..
338+
*
339+
* Extend this class to refine existing API models. If you want to model new APIs,
340+
* extend `EmailSender::Range` instead.
302341
*/
303-
abstract class EmailSender extends DataFlow::CallCfgNode {
342+
class EmailSender extends DataFlow::Node {
343+
EmailSender::Range range;
344+
345+
EmailSender() { this = range }
346+
304347
/**
305348
* Gets a data flow node holding the plaintext version of the email body.
306349
*/
307-
abstract DataFlow::Node getPlainTextBody();
350+
DataFlow::Node getPlainTextBody() { result = range.getPlainTextBody() }
308351

309352
/**
310353
* Gets a data flow node holding the html version of the email body.
311354
*/
312-
abstract DataFlow::Node getHtmlBody();
355+
DataFlow::Node getHtmlBody() { result = range.getHtmlBody() }
313356

314357
/**
315358
* Gets a data flow node holding the recipients of the email.
316359
*/
317-
abstract DataFlow::Node getTo();
360+
DataFlow::Node getTo() { result = range.getTo() }
318361

319362
/**
320363
* Gets a data flow node holding the senders of the email.
321364
*/
322-
abstract DataFlow::Node getFrom();
365+
DataFlow::Node getFrom() { result = range.getFrom() }
323366

324367
/**
325368
* Gets a data flow node holding the subject of the email.
326369
*/
327-
abstract DataFlow::Node getSubject();
370+
DataFlow::Node getSubject() { result = range.getSubject() }
328371

329372
/**
330373
* Gets a data flow node that refers to the HTML body or plaintext body of the email.
331374
*/
332-
DataFlow::Node getABody() { result in [getPlainTextBody(), getHtmlBody()] }
375+
DataFlow::Node getABody() { result in [range.getPlainTextBody(), range.getHtmlBody()] }
333376
}

0 commit comments

Comments
 (0)