Skip to content

JS: Add steps through date-formatting functions#4567

Merged
codeql-ci merged 8 commits intogithub:mainfrom
asgerf:js/date-functions
Nov 11, 2020
Merged

JS: Add steps through date-formatting functions#4567
codeql-ci merged 8 commits intogithub:mainfrom
asgerf:js/date-functions

Conversation

@asgerf
Copy link
Contributor

@asgerf asgerf commented Oct 28, 2020

Not sure these will have much impact tbh, but now we've got them covered at least.

@asgerf asgerf added the JS label Oct 28, 2020
@asgerf asgerf requested a review from a team as a code owner October 28, 2020 15:56
*/
private class MomentFormatStep extends TaintTracking::AdditionalTaintStep, DataFlow::CallNode {
MomentFormatStep() {
this = API::moduleImport("moment").getASuccessor*().getMember("format").getACall()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think getASuccessor() is a bit too general.
If you look at this LGTM query you can see some stuff that is included by getASuccessor(), that I don't think should be included.

I think a recursive predicate that uses getAMember() and getReturn() is the way to go.

@@ -0,0 +1,61 @@
private import javascript

private API::Node formatFunction() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is date-fns specific, but the predicate name doesn't convey that message.

How about moving the date-fns specific classes/predicates into a DateFns module?

Comment on lines 11 to 18
private API::Node formatFunctionCurried() {
result =
API::moduleImport(["date-fns/fp", "date-fns/fp/utc"]).getMember(["format", "lightFormat"])
or
result =
API::moduleImport(["date-fns/fp/format", "date-fns/fp/lightFormat", "date-fns/fp/utc/format",
"date-fns/fp/utc/lightFormat"])
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you missed the date-fns/esm folder. (Documentation)

The esm folder also contains a esm/fp sub folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, After a closer look it seems the utc folder doesn't actually exist in the latest version of date-fns 1.x nor in 2.x, so I removed that at the same time.

@asgerf
Copy link
Contributor Author

asgerf commented Nov 2, 2020

I snuck in support for the dateformat package as well.

@asgerf
Copy link
Contributor Author

asgerf commented Nov 2, 2020

...and moment-timezone as well, which seems to re-export the moment API with more features.

I better stop here and run and evaluation.

@asgerf asgerf added the Awaiting evaluation Do not merge yet, this PR is waiting for an evaluation to finish label Nov 2, 2020
Copy link
Contributor

@erik-krogh erik-krogh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're just missing the new libraries from the change-log.

Otherwise LGTM (assuming the evaluation works out).

erik-krogh
erik-krogh previously approved these changes Nov 2, 2020
@asgerf
Copy link
Contributor Author

asgerf commented Nov 6, 2020

A smoke-test evaluation looks fine.

Rebased and reverted changes to the 1.26 change notes and added some for 1.27 in the new format ✨

@asgerf asgerf removed the Awaiting evaluation Do not merge yet, this PR is waiting for an evaluation to finish label Nov 6, 2020
@codeql-ci codeql-ci merged commit f9d62ad into github:main Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants