add model for the formatByString and formatByNumber functions in @date-io

This commit is contained in:
Erik Krogh Kristensen
2021-06-21 11:33:41 +02:00
parent 2a4570eaaa
commit cdf3cdcf71
4 changed files with 127 additions and 0 deletions

View File

@@ -53,6 +53,28 @@ private module DateFns {
}
}
/**
* Provides classes and predicates modelling the `@date-io` libraries.
*/
private module DateIO {
private class FormatStep extends TaintTracking::SharedTaintStep {
override predicate stringManipulationStep(DataFlow::Node pred, DataFlow::Node succ) {
exists(API::CallNode formatCall |
formatCall =
API::moduleImport("@date-io/" +
["date-fns", "moment", "luxon", "dayjs", "date-fns-jalali", "jalaali", "hijri"])
.getInstance()
// the `format` function only select between a predefined list of formats, but the `formatByString` function formats using any string.
.getMember(["formatByString", "formatNumber"])
.getACall()
|
pred = formatCall.getArgument(1) and
succ = formatCall
)
}
}
}
private module Moment {
/** Gets a reference to a `moment` object. */
private API::Node moment() {