Skip to content

Conversation

erik-krogh
Copy link
Contributor

@erik-krogh erik-krogh commented Mar 12, 2021

Gets a TP/TN for CVE-2021-3377

I decided to use StringReplaceCall::replaces/2 inside getAReplacementString because it gives me a natural way of getting the TP for the CVE, and I couldn't come up with a good reason for why not to do it (no test-case broke, and evaluation is clean).

Evaluation is good.
No change in performance or results.

@github-actions github-actions bot added the JS label Mar 12, 2021
@erik-krogh erik-krogh marked this pull request as ready for review March 16, 2021 20:28
@erik-krogh erik-krogh requested a review from a team as a code owner March 16, 2021 20:28
@erik-krogh erik-krogh added the no-change-note-required This PR does not need a change note label Mar 16, 2021
@@ -149,6 +149,19 @@ class StringReplaceCall extends DataFlow::MethodCallNode {
pr.flowsTo(replacer.getAReturn()) and
map.hasPropertyWrite(old, any(DataFlow::Node repl | repl.getStringValue() = new))
)
or
exists(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comment with a quick example of the syntax we're trying to match here?

For example

    // str.replace(regex, match => {
    //   if (match === 'old') return 'new';
    // })

Copy link
Contributor

@asgerf asgerf left a comment

Choose a reason for hiding this comment

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

LGTM. I suppose the polarity check is unlikely to change the evaluation outcome.

@codeql-ci codeql-ci merged commit d95b295 into github:main Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JS no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants