mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
modified query and added tests
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
var express = require('express');
|
||||
var app = express();
|
||||
|
||||
var actions = new Map();
|
||||
actions.put("play", function play(data) {
|
||||
// ...
|
||||
});
|
||||
actions.put("pause", function pause(data) {
|
||||
// ...
|
||||
});
|
||||
|
||||
app.get('/perform/:action/:payload', function(req, res) {
|
||||
let action = actions.get(req.params.action);
|
||||
res.end(action.get(req.params.payload)); // NOT OK
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
var express = require('express');
|
||||
var app = express();
|
||||
|
||||
var actions = new Map();
|
||||
actions.put("play", function play(data) {
|
||||
// ...
|
||||
});
|
||||
actions.put("pause", function pause(data) {
|
||||
// ...
|
||||
});
|
||||
|
||||
app.get('/perform/:action/:payload', function(req, res) {
|
||||
if (actions.has(req.params.action)){
|
||||
let action = actions.get(req.params.action);
|
||||
res.end(action.get(req.params.payload)); // NOT OK, but not flagged [INCONSISTENCY]
|
||||
}
|
||||
});
|
||||
@@ -2,17 +2,20 @@ var express = require('express');
|
||||
var app = express();
|
||||
|
||||
var actions = new Map();
|
||||
actions.put("play", function (data) {
|
||||
actions.put("play", function play(data) {
|
||||
// ...
|
||||
});
|
||||
actions.put("pause", function(data) {
|
||||
actions.put("pause", function pause(data) {
|
||||
// ...
|
||||
});
|
||||
|
||||
app.get('/perform/:action/:payload', function(req, res) {
|
||||
app.get('/perform/:action/:payload', function (req, res) {
|
||||
if (actions.has(req.params.action)) {
|
||||
let action = actions.get(req.params.action);
|
||||
res.end(action(req.params.payload));
|
||||
if (typeof actions.get(req.params.action) === 'function') {
|
||||
let action = actions.get(req.params.action);
|
||||
// GOOD: `action` is either the `play` or the `pause` function from above
|
||||
res.end(action(req.params.payload));
|
||||
}
|
||||
} else {
|
||||
res.end("Unsupported action.");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
var express = require('express');
|
||||
var app = express();
|
||||
|
||||
var actions = new Map();
|
||||
actions.put("play", function play(data) {
|
||||
// ...
|
||||
});
|
||||
actions.put("pause", function pause(data) {
|
||||
// ...
|
||||
});
|
||||
|
||||
app.get('/perform/:action/:payload', function (req, res) {
|
||||
if (typeof actions.get(req.params.action) === 'function') {
|
||||
let action = actions.get(req.params.action);
|
||||
// GOOD: `action` is either the `play` or the `pause` function from above
|
||||
res.end(action(req.params.payload));
|
||||
} else {
|
||||
res.end("Unsupported action.");
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user