Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

JavaScript: Restricting isSource predicate leads to more alerts #7790

Copy link
Copy link
Open
@max-schaefer

Description

@max-schaefer
Issue body actions

I have the following test file for the UnvalidatedDynamicMethodCall query:

var express = require('express');
var app = express();

var actions = {
    play(data) {
        // ...
    },
    pause(data) {
        // ...
    }
}

app.get('/perform/:action/:payload', function(req, res) {
    if (actions.hasOwnProperty(req.params.action)) {
        let action = actions[req.params.action];
        if (typeof action === 'function') {
            res.end(action(req.params.payload));
            return;
        }
    }
    res.end("Unsupported action.");
});

Running the query on it (using CodeQL 2.7.6) does not flag an alert.

Now I change the UnvalidatedDynamicMethCallQuery library by adding the following conjunct in its isSource predicate:

(...)  and
source.getStartLine() = 15

And suddenly I get an alert on the call to action.

Quite apart from the question of whether or not this alert is correct, I don't see how adding a conjunct to the isSource predicate, thereby making it smaller (in this particular case, one source instead of three), can lead to more alerts being reported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    JSbugSomething isn't workingSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.