")); // $ Alert
+ $(["
"].join()); // $ Alert
function indirection1(attrs) {
return '
' + content + '
';
@@ -17,6 +17,6 @@ function test() {
function indirection2(attrs) {
return '
'.concat(content)).concat('
');
}
- $(indirection1(document.location.search.attrs)); // NOT OK
- $(indirection2(document.location.search.attrs)); // NOT OK
+ $(indirection1(document.location.search.attrs)); // $ Alert
+ $(indirection2(document.location.search.attrs)); // $ Alert
};
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/ExceptionXss/ajv.js b/javascript/ql/test/query-tests/Security/CWE-079/ExceptionXss/ajv.js
index 36dd5181a1b5..43c6618430e2 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/ExceptionXss/ajv.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/ExceptionXss/ajv.js
@@ -8,7 +8,7 @@ ajv.addSchema({type: 'object', additionalProperties: {type: 'number'}}, 'pollDat
app.post('/polldata', (req, res) => {
if (!ajv.validate('pollData', req.body)) {
- res.send(ajv.errorsText()); // NOT OK
+ res.send(ajv.errorsText()); // $ Alert
}
});
@@ -21,6 +21,6 @@ const joiSchema = joi.object().keys({
app.post('/votedata', (req, res) => {
const val = joiSchema.validate(req.body);
if (val.error) {
- res.send(val.error); // NOT OK
+ res.send(val.error); // $ Alert
}
});
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/ExceptionXss/exception-xss.js b/javascript/ql/test/query-tests/Security/CWE-079/ExceptionXss/exception-xss.js
index 150b9e204fda..f8a3d5c09486 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/ExceptionXss/exception-xss.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/ExceptionXss/exception-xss.js
@@ -8,31 +8,31 @@
try {
unknown(foo);
} catch (e) {
- $('myId').html(e); // NOT OK!
+ $('myId').html(e); // $ Alert
}
try {
inner(foo);
} catch (e) {
- $('myId').html(e); // NOT OK!
+ $('myId').html(e); // $ Alert
}
try {
unknown(foo + "bar");
} catch (e) {
- $('myId').html(e); // NOT OK!
+ $('myId').html(e); // $ Alert
}
try {
unknown({ prop: foo });
} catch (e) {
- $('myId').html(e); // NOT OK! - but not detected due to not tainting object that have a tainted propety. [INCONSISTENCY]
+ $('myId').html(e); // $ MISSING: Alert - - but not detected due to not tainting object that have a tainted propety.
}
try {
unknown(["bar", foo]);
} catch (e) {
- $('myId').html(e); // NOT OK!
+ $('myId').html(e); // $ Alert
}
function deep(x) {
@@ -45,13 +45,13 @@
try {
deep("bar" + foo);
} catch (e) {
- $('myId').html(e); // NOT OK!
+ $('myId').html(e); // $ Alert
}
try {
var tmp = "bar" + foo;
} catch (e) {
- $('myId').html(e); // OK
+ $('myId').html(e);
}
function safe(x) {
@@ -61,13 +61,13 @@
try {
safe(foo);
} catch (e) {
- $('myId').html(e); // OK
+ $('myId').html(e);
}
try {
safe.call(null, foo);
} catch (e) {
- $('myId').html(e); // OK
+ $('myId').html(e);
}
var myWeirdInner;
try {
@@ -75,12 +75,12 @@
inner(x);
}
} catch (e) {
- $('myId').html(e); // OK
+ $('myId').html(e);
}
try {
myWeirdInner(foo);
} catch (e) {
- $('myId').html(e); // NOT OK!
+ $('myId').html(e); // $ Alert
}
$('myId').html(foo); // Direct leak, reported by other query.
@@ -88,13 +88,13 @@
try {
unknown(foo.match(/foo/));
} catch (e) {
- $('myId').html(e); // NOT OK!
+ $('myId').html(e); // $ Alert
}
try {
unknown([foo, "bar"]);
} catch (e) {
- $('myId').html(e); // NOT OK!
+ $('myId').html(e); // $ Alert
}
try {
@@ -104,7 +104,7 @@
// nothing
}
} catch (e) {
- $('myId').html(e); // NOT OK!
+ $('myId').html(e); // $ Alert
}
});
@@ -116,7 +116,7 @@ app.get('/user/:id', function (req, res) {
try {
unknown(req.params.id);
} catch (e) {
- res.send("Exception: " + e); // NOT OK!
+ res.send("Exception: " + e); // $ Alert
}
});
@@ -127,7 +127,7 @@ app.get('/user/:id', function (req, res) {
try {
unknown(sessionStorage.getItem('exceptionSession'));
} catch (e) {
- $('myId').html(e); // NOT OK
+ $('myId').html(e); // $ Alert
}
})();
@@ -135,10 +135,10 @@ app.get('/user/:id', function (req, res) {
app.get('/user/:id', function (req, res) {
unknown(req.params.id, (error, res) => {
if (error) {
- $('myId').html(error); // NOT OK
+ $('myId').html(error); // $ Alert
return;
}
- $('myId').html(res); // OK (for now?)
+ $('myId').html(res); // OK - for now?
});
});
@@ -146,25 +146,25 @@ app.get('/user/:id', function (req, res) {
var foo = document.location.search;
new Promise(resolve => unknown(foo, resolve)).catch((e) => {
- $('myId').html(e); // NOT OK
+ $('myId').html(e); // $ Alert
});
try {
null[foo];
} catch (e) {
- $('myId').html(e); // NOT OK
+ $('myId').html(e); // $ Alert
}
try {
unknown()[foo];
} catch (e) {
- $('myId').html(e); // OK. We are not sure that `unknown()` is null-ish.
+ $('myId').html(e); // OK - We are not sure that `unknown()` is null-ish.
}
try {
"foo"[foo]
} catch (e) {
- $('myId').html(e); // OK
+ $('myId').html(e);
}
function inner(tainted, resolve) {
@@ -172,16 +172,16 @@ app.get('/user/:id', function (req, res) {
}
new Promise(resolve => inner(foo, resolve)).catch((e) => {
- $('myId').html(e); // NOT OK
+ $('myId').html(e); // $ Alert
});
})();
app.get('/user/:id', function (req, res) {
unknown(req.params.id, (error, res) => {
if (error) {
- $('myId').html(error); // NOT OK
+ $('myId').html(error); // $ Alert
}
- $('myId').html(res); // OK - does not contain an error, and `res` is otherwise unknown.
+ $('myId').html(res); // OK - does not contain an error, and `res` is otherwise unknown.
});
});
@@ -189,7 +189,7 @@ app.get('/user/:id', function (req, res) {
try {
res.send(req.params.id);
} catch(err) {
- res.send(err); // OK (the above `res.send()` is already reported by js/xss)
+ res.send(err); // OK - (the above `res.send()` is already reported by js/xss)
}
});
@@ -210,7 +210,7 @@ var fs = require("fs");
log.info(foo);
localStorage.setItem(foo);
} catch (e) {
- $('myId').html(e); // OK
+ $('myId').html(e);
}
})();
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXss.js b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXss.js
index c3b1cbc2da8a..ef82f644a049 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXss.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXss.js
@@ -4,8 +4,7 @@ var app = express();
app.get('/user/:id', function(req, res) {
if (!isValidUserId(req.params.id)) {
- // BAD: a request parameter is incorporated without validation into the response
- res.send("Unknown user: " + req.params.id);
+ res.send("Unknown user: " + req.params.id); // $ Alert - a request parameter is incorporated without validation into the response
moreBadStuff(req.params, res);
} else {
// TODO: do something exciting
@@ -14,32 +13,32 @@ app.get('/user/:id', function(req, res) {
});
function moreBadStuff(params, res) {
- res.send("Unknown user: " + params.id); // NOT OK
+ res.send("Unknown user: " + params.id); // $ Alert
}
var marked = require("marked");
app.get('/user/:id', function(req, res) {
- res.send(req.body); // NOT OK
- res.send(marked(req.body)); // NOT OK
+ res.send(req.body); // $ Alert
+ res.send(marked(req.body)); // $ Alert
});
var table = require('markdown-table')
app.get('/user/:id', function(req, res) {
- res.send(req.body); // NOT OK
+ res.send(req.body); // $ Alert
var mytable = table([
['Name', 'Content'],
['body', req.body]
]);
- res.send(mytable); // NOT OK - FIXME: only works in OLD dataflow, add implicit reads before library-contributed taint steps
+ res.send(mytable); // $ Alert - FIXME: only works in OLD dataflow, add implicit reads before library-contributed taint steps
});
var showdown = require('showdown');
var converter = new showdown.Converter();
app.get('/user/:id', function(req, res) {
- res.send(req.body); // NOT OK
- res.send(converter.makeHtml(req.body)); // NOT OK
+ res.send(req.body); // $ Alert
+ res.send(converter.makeHtml(req.body)); // $ Alert
});
var unified = require('unified');
@@ -53,7 +52,7 @@ var sanitize = require("rehype-sanitize");
const { resetExtensions } = require('showdown');
app.get('/user/:id', function (req, res) {
- res.send(req.body); // NOT OK
+ res.send(req.body); // $ Alert
unified()
.use(markdown)
@@ -62,17 +61,17 @@ app.get('/user/:id', function (req, res) {
.use(format)
.use(html)
.process(req.body, function (err, file) {
- res.send(file); // NOT OK
+ res.send(file); // $ Alert
});
- res.send(remark().processSync(req.body).toString()); // NOT OK
+ res.send(remark().processSync(req.body).toString()); // $ Alert
- res.send(remark().use(sanitize).processSync(req.body).toString()); // OK
+ res.send(remark().use(sanitize).processSync(req.body).toString());
- res.send(unified().use(markdown).processSync(req.body).toString); // NOT OK
+ res.send(unified().use(markdown).processSync(req.body).toString); // $ Alert
remark().process(req.body, (e, f) => {
- res.send(f); // NOT OK
+ res.send(f); // $ Alert
})
});
@@ -80,9 +79,9 @@ import snarkdown from 'snarkdown';
var snarkdown2 = require("snarkdown");
app.get('/user/:id', function (req, res) {
- res.send(req.body); // NOT OK
- res.send(snarkdown(req.body)); // NOT OK
- res.send(snarkdown2(req.body)); // NOT OK
+ res.send(req.body); // $ Alert
+ res.send(snarkdown(req.body)); // $ Alert
+ res.send(snarkdown2(req.body)); // $ Alert
});
const markdownIt = require('markdown-it')({
@@ -94,20 +93,20 @@ const markdownIt3 = require('markdown-it')({html: true})
.use(require('markdown-it-highlightjs'));
app.get('/user/:id', function (req, res) {
- res.send(req.body); // NOT OK
- res.send(markdownIt.render(req.body)); // NOT OK
+ res.send(req.body); // $ Alert
+ res.send(markdownIt.render(req.body)); // $ Alert
res.send(markdownIt2.render(req.body)); // OK - no html
- res.send(markdownIt3.render(req.body)); // NOT OK
+ res.send(markdownIt3.render(req.body)); // $ Alert
- res.send(markdownIt.use(require('markdown-it-sanitizer')).render(req.body)); // OK - HTML is sanitized.
- res.send(markdownIt.use(require('markdown-it-abbr')).use(unknown).render(req.body)); // NOT OK
+ res.send(markdownIt.use(require('markdown-it-sanitizer')).render(req.body)); // OK - HTML is sanitized.
+ res.send(markdownIt.use(require('markdown-it-abbr')).use(unknown).render(req.body)); // $ Alert
});
var Hapi = require('hapi');
var hapi = new Hapi.Server();
hapi.route({
handler: function (request){
- return request.query.p; // NOT OK
+ return request.query.p; // $ Alert
}});
app.get("invalid/keys/:id", async (req, res) => {
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXssContentTypes.js b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXssContentTypes.js
index 64acfded0a63..cf89f45b9692 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXssContentTypes.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXssContentTypes.js
@@ -7,7 +7,7 @@ app.get('/user/:id', function (req, res) {
res.send("FOO: " + req.params.id); // OK - content type is plain text
} else {
res.set('Content-Type', 'text/html');
- res.send("FOO: " + req.params.id); // NOT OK - content type is HTML.
+ res.send("FOO: " + req.params.id); // $ Alert - content type is HTML.
}
});
@@ -17,7 +17,7 @@ app.get('/user/:id', function (req, res) {
res.send("FOO: " + req.params.id); // OK - content type is JSON
} else {
res.writeHead(404);
- res.send("FOO: " + req.params.id); // NOT OK - content type is not set.
+ res.send("FOO: " + req.params.id); // $ Alert - content type is not set.
}
});
@@ -36,10 +36,10 @@ app.get('/user/:id', function (req, res) {
app.get('/user/:id', function (req, res) {
if (err) {
res.statusCode = 404;
- res.end("FOO: " + req.params.id); // NOT OK
+ res.end("FOO: " + req.params.id); // $ Alert
} else {
res.setHeader('Content-Type', 'text/plain;charset=utf8');
- res.end("FOO: " + req.params.id); // OK
+ res.end("FOO: " + req.params.id);
}
});
@@ -50,10 +50,10 @@ function textContentType() {
app.get('/user/:id', function (req, res) {
if (err) {
res.header({'Content-Type': textContentType()});
- res.end("FOO: " + req.params.id); // OK
+ res.end("FOO: " + req.params.id);
} else {
res.setHeader('Content-Type', 'text/plain;charset=utf8');
- res.end("FOO: " + req.params.id); // OK
+ res.end("FOO: " + req.params.id);
}
});
@@ -67,13 +67,13 @@ app.get('/user/:id', function (req, res) {
somethingMore();
while(Math.random()) {};
res.writeHead(404);
- res.send("FOO: " + req.params.id); // NOT OK - content type is not set.
+ res.send("FOO: " + req.params.id); // $ Alert - content type is not set.
});
app.get('/user/:id', function (req, res) {
res.header({'Content-Type': textContentType()});
myFancyFunction(() => {
- res.send("FOO: " + req.params.id); // OK
+ res.send("FOO: " + req.params.id);
});
- res.end("FOO: " + req.params.id); // OK
+ res.end("FOO: " + req.params.id);
});
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXssGood.js b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXssGood.js
index c6635459f42f..a92226bff122 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXssGood.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXssGood.js
@@ -5,7 +5,7 @@ var app = express();
app.get('/user/:id', function(req, res) {
if (!isValidUserId(req.params.id))
- // GOOD: request parameter is sanitized before incorporating it into the response
+ // OK - request parameter is sanitized before incorporating it into the response
res.send("Unknown user: " + escape(req.params.id));
else
// TODO: do something exciting
@@ -15,13 +15,13 @@ app.get('/user/:id', function(req, res) {
app.get('/user/:id', function(req, res) {
if (!isValidUserId(req.params.id))
- // GOOD: templating prevents XSS
+ // OK - templating prevents XSS
res.render(invalidUserIdTemplate, { id: req.params.id });
});
app.get('/user/:id', function(req, res) {
if (!isValidUserId(req.params.id)) {
- // GOOD: response content type set to text
+ // OK - response content type set to text
res.set('Content-Type', 'text/plain');
res.send("Unknown user: " + req.params.id);
} else
@@ -35,7 +35,7 @@ function textContentType() {
app.get('/user/:id', function(req, res) {
if (!isValidUserId(req.params.id)) {
- // GOOD: response content type set to text
+ // OK - response content type set to text
res.set('Content-Type', textContentType());
res.send("Unknown user: " + req.params.id);
} else
@@ -53,7 +53,7 @@ app.get('/echo', function(req, res) {
app.get('/user/:id', function(req, res) {
const url = req.params.id;
if (!/["'&<>]/.exec(url)) {
- res.send(url); // OK
+ res.send(url);
}
});
@@ -66,7 +66,7 @@ function escapeHtml1 (str) {
app.get('/user/:id', function(req, res) {
const url = req.params.id;
- res.send(escapeHtml1(url)); // OK
+ res.send(escapeHtml1(url));
});
const matchHtmlRegExp = /["'&<>]/;
@@ -82,6 +82,6 @@ function escapeHtml2 (string) {
app.get('/user/:id', function(req, res) {
const url = req.params.id;
- res.send(escapeHtml2(url)); // OK
+ res.send(escapeHtml2(url));
});
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXssGood3.js b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXssGood3.js
index 2217ab783ac7..5ab9f9d6f265 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXssGood3.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/ReflectedXssGood3.js
@@ -134,9 +134,9 @@ function escapeHtml4(s) {
app.get('/user/:id', function (req, res) {
const url = req.params.id;
- res.send(escapeHtml1(url)); // OK
- res.send(escapeHtml2(url)); // OK
- res.send(escapeHtml3(url)); // OK - but FP [INCONSISTENCY]
- res.send(escapeHtml4(url)); // OK
+ res.send(escapeHtml1(url));
+ res.send(escapeHtml2(url));
+ res.send(escapeHtml3(url)); // $ SPURIOUS: Alert - FP
+ res.send(escapeHtml4(url));
});
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/cookies.js b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/cookies.js
index c30ab48a511d..3fba93d3b4a7 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/cookies.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/cookies.js
@@ -5,6 +5,6 @@ var app = express();
app.use(cookieParser());
app.get('/cookie/:name', function(req, res) {
- // OK
+
res.send("Here, have a cookie: " + req.cookies[req.params.name]);
});
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/formatting.js b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/formatting.js
index 45ad3a94920c..448f12270783 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/formatting.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/formatting.js
@@ -2,7 +2,7 @@ var express = require('express');
express().get('/user/', function(req, res) {
var evil = req.query.evil;
- res.send(console.log("
%s
", evil)); // OK (returns undefined)
- res.send(util.format("
%s
", evil)); // NOT OK
- res.send(require("printf")("
%s
", evil)); // NOT OK
+ res.send(console.log("
%s
", evil)); // OK - returns undefined
+ res.send(util.format("
%s
", evil)); // $ Alert
+ res.send(require("printf")("
%s
", evil)); // $ Alert
});
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/live-server.js b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/live-server.js
index aed560fc0767..cd6ca0c9e3da 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/live-server.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/live-server.js
@@ -3,13 +3,13 @@ var liveServer = require("live-server");
const middleware = [function(req, res, next) {
const tainted = req.url;
- res.end(`${tainted}`); // NOT OK
+ res.end(`${tainted}`); // $ Alert
}];
middleware.push(function(req, res, next) {
const tainted = req.url;
- res.end(`${tainted}`); // NOT OK
+ res.end(`${tainted}`); // $ Alert
});
var params = {
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/partial.js b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/partial.js
index 4b2edd4e4faf..105080e5fba2 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/partial.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/partial.js
@@ -7,7 +7,7 @@ let app = express();
app.get("/some/path", (req, res) => {
function sendResponse(x, y) {
- res.send(x + y); // NOT OK
+ res.send(x + y); // $ Alert
}
let callback = sendResponse.bind(null, req.url);
@@ -16,7 +16,7 @@ app.get("/some/path", (req, res) => {
app.get("/underscore", (req, res) => {
function sendResponse(x, y) {
- res.send(x + y); // NOT OK
+ res.send(x + y); // $ Alert
}
let callback = underscore.partial(sendResponse, req.url);
@@ -25,7 +25,7 @@ app.get("/underscore", (req, res) => {
app.get("/lodash", (req, res) => {
function sendResponse(x, y) {
- res.send(x + y); // NOT OK
+ res.send(x + y); // $ Alert
}
let callback = lodash.partial(sendResponse, req.url);
@@ -34,7 +34,7 @@ app.get("/lodash", (req, res) => {
app.get("/ramda", (req, res) => {
function sendResponse(x, y) {
- res.send(x + y); // NOT OK
+ res.send(x + y); // $ Alert
}
let callback = R.partial(sendResponse, [req.url]);
@@ -49,7 +49,7 @@ app.get("/return", (req, res) => {
let callback = getFirst.bind(null, req.url);
res.send(callback); // OK - the callback itself is not tainted
- res.send(callback()); // NOT OK - but not currently detected [INCONSISTENCY]
+ res.send(callback()); // $ MISSING: Alert - not currently detected
res.send(getFirst("Hello")); // OK - argument is not tainted from this call site
});
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/promises.js b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/promises.js
index d48ec23af5f1..392a1f7ec612 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/promises.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/promises.js
@@ -3,9 +3,9 @@ let app = express();
app.get("/some/path", (req, res) => {
new Promise((resolve, reject) => resolve(req.query.data))
- .then(x => res.send(x)); // NOT OK
+ .then(x => res.send(x)); // $ Alert
new Promise((resolve, reject) => resolve(req.query.data))
.then(x => escapeHtml(x))
- .then(x => res.send(x)); // OK
+ .then(x => res.send(x));
});
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/tst2.js b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/tst2.js
index 60399a9b63d6..35021ea39120 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/tst2.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/tst2.js
@@ -4,8 +4,8 @@ var app = express();
app.get('/user/:id', function(req, res) {
let { p, q: r } = req.params;
- res.send(p); // NOT OK
- res.send(r); // NOT OK
+ res.send(p); // $ Alert
+ res.send(r); // $ Alert
});
const aKnownValue = "foo";
@@ -14,13 +14,13 @@ app.get('/bar', function(req, res) {
let { p } = req.params;
if (p == aKnownValue)
- res.send(p); // OK
- res.send(p); // NOT OK
+ res.send(p);
+ res.send(p); // $ Alert
if (p != aKnownValue)
- res.send(p); // NOT OK
+ res.send(p); // $ Alert
else
- res.send(p); // OK
+ res.send(p);
});
@@ -33,8 +33,8 @@ app.get('/baz', function(req, res) {
obj.p = p;
var other = clone(obj);
- res.send(p); // NOT OK
- res.send(other.p); // NOT OK
+ res.send(p); // $ Alert
+ res.send(other.p); // $ Alert
});
const serializeJavaScript = require('serialize-javascript');
@@ -44,11 +44,11 @@ app.get('/baz', function(req, res) {
var serialized = serializeJavaScript(p);
- res.send(serialized); // OK
+ res.send(serialized);
var unsafe = serializeJavaScript(p, {unsafe: true});
- res.send(unsafe); // NOT OK
+ res.send(unsafe); // $ Alert
});
const fclone = require('fclone');
@@ -60,8 +60,8 @@ app.get('/baz', function(req, res) {
obj.p = p;
var other = fclone(obj);
- res.send(p); // NOT OK
- res.send(other.p); // NOT OK
+ res.send(p); // $ Alert
+ res.send(other.p); // $ Alert
});
const jc = require('json-cycle');
@@ -72,8 +72,8 @@ app.get('/baz', function(req, res) {
obj.p = p;
var other = jc.retrocycle(jc.decycle(obj));
- res.send(p); // NOT OK
- res.send(other.p); // NOT OK
+ res.send(p); // $ Alert
+ res.send(other.p); // $ Alert
});
const sortKeys = require('sort-keys');
@@ -85,6 +85,6 @@ app.get('/baz', function(req, res) {
obj.p = p;
var other = sortKeys(obj);
- res.send(p); // NOT OK
- res.send(other.p); // NOT OK
+ res.send(p); // $ Alert
+ res.send(other.p); // $ Alert
});
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/tst3.js b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/tst3.js
index c7d0fd91a4a0..61d153498e74 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/tst3.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/ReflectedXss/tst3.js
@@ -3,11 +3,11 @@ var express = require('express');
var app = express();
app.enable('x-powered-by').disable('x-powered-by').get('/', function (req, res) {
let { p } = req.params;
- res.send(p); // NOT OK
+ res.send(p); // $ Alert
});
const prettier = require("prettier");
app.post("foobar", function (reg, res) {
const code = prettier.format(reg.body, { semi: false, parser: "babel" });
- res.send(code); // NOT OK
+ res.send(code); // $ Alert
});
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/StoredXss/xss-through-filenames.js b/javascript/ql/test/query-tests/Security/CWE-079/StoredXss/xss-through-filenames.js
index c04e0d784efc..be96d05a400a 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/StoredXss/xss-through-filenames.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/StoredXss/xss-through-filenames.js
@@ -5,7 +5,7 @@ var express = require('express');
express().get('/', function(req, res) {
fs.readdir("/myDir", function (error, files1) {
- res.send(files1); // NOT OK
+ res.send(files1); // $ Alert
});
});
@@ -23,18 +23,18 @@ http.createServer(function (req, res) {
}
fs.readdir("/myDir", function (error, files1) {
- res.write(files1); // NOT OK
+ res.write(files1); // $ Alert
var dirs = [];
var files2 = [];
files1.forEach(function (file) {
files2.push(file);
});
- res.write(files2); // NOT OK
+ res.write(files2); // $ Alert
var files3 = format(files2);
- res.write(files3); // NOT OK
+ res.write(files3); // $ Alert
});
});
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/StoredXss/xss-through-torrent.js b/javascript/ql/test/query-tests/Security/CWE-079/StoredXss/xss-through-torrent.js
index dcf530e3ef5c..4f712f2604e7 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/StoredXss/xss-through-torrent.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/StoredXss/xss-through-torrent.js
@@ -4,5 +4,5 @@ const parseTorrent = require('parse-torrent'),
express().get('/user/:id', function(req, res) {
let torrent = parseTorrent(unknown),
name = torrent.name;
- res.send(name); // NOT OK
+ res.send(name); // $ Alert
});
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/jquery-plugin.js b/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/jquery-plugin.js
index 6a133a747bdd..fb229199e687 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/jquery-plugin.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/jquery-plugin.js
@@ -5,11 +5,11 @@
factory(jQuery);
}
}(function ($) {
- $("
" + $.trim("foo") + ""); // OK
+ $("
" + $.trim("foo") + "");
}));
$.fn.myPlugin = function (stuff, options) {
- $("#foo").html("
" + options.foo + ""); // NOT OK
+ $("#foo").html("
" + options.foo + ""); // $ Alert
- $("#foo").html("
" + stuff + ""); // NOT OK
+ $("#foo").html("
" + stuff + ""); // $ Alert
}
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/lib/src/MyNode.ts b/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/lib/src/MyNode.ts
index 91e81238605a..9c48ed8c23f5 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/lib/src/MyNode.ts
+++ b/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/lib/src/MyNode.ts
@@ -1,4 +1,4 @@
export function trivialXss(s: string) {
- const html = "
" + s + ""; // NOT OK
+ const html = "
" + s + ""; // $ Alert
document.querySelector("#html").innerHTML = html;
}
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/lib2/index.ts b/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/lib2/index.ts
index 4e5e4730547e..3ec0e2007396 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/lib2/index.ts
+++ b/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/lib2/index.ts
@@ -1,10 +1,10 @@
export function trivialXss(s: string) {
- const html = "
" + s + ""; // NOT OK - this file is recognized as a main file.
+ const html = "
" + s + ""; // $ Alert - this file is recognized as a main file.
document.querySelector("#html").innerHTML = html;
}
export function objectStuff(settings: any, i: number) {
- document.querySelector("#html").innerHTML = "
" + settings + ""; // NOT OK
+ document.querySelector("#html").innerHTML = "
" + settings + ""; // $ Alert
var name;
if (settings.mySetting && settings.mySetting.length !== 0) {
@@ -15,7 +15,7 @@ export function objectStuff(settings: any, i: number) {
name = "";
}
- document.querySelector("#html").innerHTML = "
" + name + ""; // NOT OK
+ document.querySelector("#html").innerHTML = "
" + name + ""; // $ Alert
}
}
}
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/lib2/src/MyNode.ts b/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/lib2/src/MyNode.ts
index e28325ce0cf8..9566ce8468a8 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/lib2/src/MyNode.ts
+++ b/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/lib2/src/MyNode.ts
@@ -1,4 +1,4 @@
export function trivialXss(s: string) {
- const html = "
" + s + ""; // NOT OK - this file is not recognized as a main file.
+ const html = "
" + s + ""; // $ Alert - this file is not recognized as a main file.
document.querySelector("#html").innerHTML = html;
}
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/main.js b/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/main.js
index 01d376a2f8be..369643121368 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/main.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/main.js
@@ -1,15 +1,15 @@
module.exports.xssThroughHTMLConstruction = function (s) {
- const html = "
" + s + "";// NOT OK
+ const html = "
" + s + "";// $ Alert
document.querySelector("#html").innerHTML = html;
}
module.exports.xssThroughXMLParsing = function (s) {
- const doc = new DOMParser().parseFromString(s, "text/xml"); // NOT OK
+ const doc = new DOMParser().parseFromString(s, "text/xml"); // $ Alert
document.querySelector("#xml").appendChild(doc.documentElement);
}
module.exports.xssThroughMoreComplexXMLParsing = function (s) {
- const doc = new DOMParser().parseFromString(s, "text/xml"); // NOT OK
+ const doc = new DOMParser().parseFromString(s, "text/xml"); // $ Alert
const xml = doc.documentElement;
const tmp = document.createElement('span');
@@ -19,13 +19,13 @@ module.exports.xssThroughMoreComplexXMLParsing = function (s) {
const markdown = require('markdown-it')({html: true});
module.exports.xssThroughMarkdown = function (s) {
- const html = markdown.render(s); // NOT OK
+ const html = markdown.render(s); // $ Alert
document.querySelector("#markdown").innerHTML = html;
}
const striptags = require('striptags');
module.exports.sanitizedHTML = function (s) {
- const html = striptags("
" + s + ""); // OK
+ const html = striptags("
" + s + "");
document.querySelector("#sanitized").innerHTML = html;
}
@@ -44,7 +44,7 @@ class Foo {
doXss() {
// not called here, but still bad.
- document.querySelector("#class").innerHTML = "
" + this.step + ""; // NOT OK
+ document.querySelector("#class").innerHTML = "
" + this.step + ""; // $ Alert
}
}
@@ -59,35 +59,35 @@ $.fn.xssPlugin = function (options) {
};
const settings = $.extend(defaults, options);
return this.each(function () {
- $("
" + settings.name + "").appendTo(this); // NOT OK
+ $("
" + settings.name + "").appendTo(this); // $ Alert
});
}
module.exports.guards = function (attrVal) {
- document.querySelector("#id").innerHTML = "
![\""]()
"; // NOT OK
- document.querySelector("#id").innerHTML = "
![\""]()
"; // OK
+ document.querySelector("#id").innerHTML = "
![\""]()
"; // $ Alert
+ document.querySelector("#id").innerHTML = "
![\""]()
";
if (attrVal.indexOf("\"") === -1 && attrVal.indexOf("'") === -1) {
- document.querySelector("#id").innerHTML = "
![\""]()
"; // OK
+ document.querySelector("#id").innerHTML = "
![\""]()
";
}
}
module.exports.intentionalTemplate = function (obj) {
- const html = "
" + obj.spanTemplate + ""; // OK
+ const html = "
" + obj.spanTemplate + "";
document.querySelector("#template").innerHTML = html;
}
module.exports.types = function (val) {
if (typeof val === "string") {
- $("#foo").html("
" + val + ""); // NOT OK
+ $("#foo").html("
" + val + ""); // $ Alert
} else if (typeof val === "number") {
- $("#foo").html("
" + val + ""); // OK
+ $("#foo").html("
" + val + "");
} else if (typeof val === "boolean") {
- $("#foo").html("
" + val + ""); // OK
+ $("#foo").html("
" + val + "");
}
}
function createHTML(x) {
- return "
" + x + ""; // NOT OK
+ return "
" + x + ""; // $ Alert
}
module.exports.usesCreateHTML = function (x) {
@@ -96,24 +96,24 @@ module.exports.usesCreateHTML = function (x) {
const myMermaid = require('mermaid');
module.exports.usesCreateHTML = function (x) {
- myMermaid.render("id", x, function (svg) { // NOT OK
+ myMermaid.render("id", x, function (svg) { // $ Alert
$("#foo").html(svg);
});
- $("#foo").html(myMermaid.render("id", x)); // NOT OK
+ $("#foo").html(myMermaid.render("id", x)); // $ Alert
- mermaid.render("id", x, function (svg) {// NOT OK
+ mermaid.render("id", x, function (svg) {// $ Alert
$("#foo").html(svg);
});
- $("#foo").html(mermaid.render("id", x)); // NOT OK
+ $("#foo").html(mermaid.render("id", x)); // $ Alert
- mermaid.mermaidAPI.render("id", x, function (svg) {// NOT OK
+ mermaid.mermaidAPI.render("id", x, function (svg) {// $ Alert
$("#foo").html(svg);
});
}
module.exports.xssThroughMarkdown = function (s) {
- const html = markdown.render(s); // NOT OK
+ const html = markdown.render(s); // $ Alert
document.querySelector("#markdown").innerHTML = html;
}
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/typed.ts b/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/typed.ts
index 0f04e92cdc04..a00719d74408 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/typed.ts
+++ b/javascript/ql/test/query-tests/Security/CWE-079/UnsafeHtmlConstruction/typed.ts
@@ -1,11 +1,11 @@
export function basicHtmlConstruction(s: string) {
- const html = "
" + s + ""; // NOT OK
+ const html = "
" + s + ""; // $ Alert
document.body.innerHTML = html;
}
export function insertIntoCreatedDocument(s: string) {
const newDoc = document.implementation.createHTMLDocument("");
- newDoc.body.innerHTML = "
" + s + ""; // OK - inserted into document disconnected from the main DOM. [INCONSISTENCY]
+ newDoc.body.innerHTML = "
" + s + ""; // $ SPURIOUS: Alert - inserted into document disconnected from the main DOM.
}
export function id(s: string) {
@@ -14,7 +14,7 @@ export function id(s: string) {
export function notVulnerable() {
const s = id("x");
- const html = "
" + s + ""; // OK
+ const html = "
" + s + "";
document.body.innerHTML = html;
}
\ No newline at end of file
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/UnsafeJQueryPlugin/unsafe-jquery-plugin.js b/javascript/ql/test/query-tests/Security/CWE-079/UnsafeJQueryPlugin/unsafe-jquery-plugin.js
index bda981fe2b7d..896c4f8af210 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/UnsafeJQueryPlugin/unsafe-jquery-plugin.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/UnsafeJQueryPlugin/unsafe-jquery-plugin.js
@@ -1,63 +1,63 @@
(function(){
$.fn.my_plugin = function my_plugin(options) {
- $(options); // NOT OK (or is it?)
+ $(options); // $ Alert - or is it?
- $(options.target); // NOT OK
+ $(options.target); // $ Alert
if (isElement(options.target)) {
- $(options.target); // OK
+ $(options.target);
}
var target = options.target;
if (isElement(target)) {
- $(target); // OK
+ $(target);
}
if (typeof target != "string") {
- $(target); // OK
+ $(target);
}
if (target.jquery === undefined) {
- $(target); // NOT OK
+ $(target); // $ Alert
} else {
- $(target); // OK
+ $(target);
}
if (target.jquery !== undefined) {
- $(target); // OK
+ $(target);
} else {
- $(target); // NOT OK
+ $(target); // $ Alert
}
if (typeof target.jquery !== "undefined") {
- $(target); // OK
+ $(target);
} else {
- $(target); // NOT OK
+ $(target); // $ Alert
}
if (typeof target.jquery === "undefined") {
- $(target); // NOT OK
+ $(target); // $ Alert
} else {
- $(target); // OK
+ $(target);
}
if (target.jquery) {
- $(target); // OK
+ $(target);
} else {
- $(target); // NOT OK
+ $(target); // $ Alert
}
if (!target.jquery) {
- $(target); // NOT OK
+ $(target); // $ Alert
} else {
- $(target); // OK
+ $(target);
}
if (!!target.jquery) {
- $(target); // OK
+ $(target);
} else {
- $(target); // NOT OK
+ $(target); // $ Alert
}
};
@@ -65,20 +65,20 @@
$.fn.my_plugin = function my_plugin(element, options) {
this.$element = $(element);
this.options = $.extend({}, options);
- if (this.options.parent) this.$parent = $(this.options.parent) // NOT OK
+ if (this.options.parent) this.$parent = $(this.options.parent) // $ Alert
};
$.fn.my_plugin = function my_plugin(options) {
- $(options.foo.bar.baz); // NOT OK
- $(options.html); // OK
+ $(options.foo.bar.baz); // $ Alert
+ $(options.html);
};
$.fn.my_plugin = function my_plugin(options) {
- $(x).appendTo(options.foo.bar.baz); // NOT OK
+ $(x).appendTo(options.foo.bar.baz); // $ Alert
};
$.fn.my_plugin = function my_plugin(options) {
- $("#" + options.target); // OK
+ $("#" + options.target);
};
$.fn.my_plugin = function my_plugin(options) {
@@ -87,7 +87,7 @@
var t = this.o.target;
console.log(t);
- $(t); // NOT OK
+ $(t); // $ Alert
}
f(options);
};
@@ -95,7 +95,7 @@
$.fn.my_plugin = function my_plugin(options) {
var target = options.target;
if (safe.has(target))
- $(target); // OK
+ $(target);
};
$.fn.my_plugin = function my_plugin(options) {
@@ -103,8 +103,8 @@
menu: '
',
target: '.my_plugin'
}, options);
- $(options.menu); // OK
- $(options.target); // NOT OK
+ $(options.menu);
+ $(options.target); // $ Alert
};
$.fn.my_plugin.defaults = {
@@ -113,38 +113,38 @@
};
$.fn.my_plugin = function my_plugin(options) {
options = $.extend({}, $.fn.my_plugin.defaults, options);
- $(options.menu); // OK
- $(options.target); // NOT OK
+ $(options.menu);
+ $(options.target); // $ Alert
};
var pluginName = "my_plugin";
$.fn[pluginName] = function my_plugin(options) {
- $(options.target); // NOT OK
+ $(options.target); // $ Alert
};
$.extend($.fn, {
my_plugin: function my_plugin(options) {
- $(options.target); // NOT OK
+ $(options.target); // $ Alert
}
});
$.fn.affix = function my_plugin(options) {
- $(options.target); // NOT OK
+ $(options.target); // $ Alert
};
$.fn.tooltip = function my_plugin(options) {
- $(options.viewport.selector); // NOT OK
+ $(options.viewport.selector); // $ Alert
};
$.fn.my_plugin = function my_plugin(options) {
let intentional1 = options.target || `
hello
`;
- $(intentional1); // OK
+ $(intentional1);
let intentional2 = `
${options.target}
`;
- $(intentional2); // OK
+ $(intentional2);
let intentional3 = `
` + options.target `
`;
- $(intentional3); // OK
+ $(intentional3);
let unintentional = `
`;
$(unintentional); // OK - but should be flagged by another query
@@ -152,22 +152,22 @@
$.fn.my_plugin = function my_plugin(options) {
let target = options.target;
- target === DEFAULTS.target? $(target): $(document).find(target); // OK
- options.target === DEFAULTS.target? $(options.target): $(document).find(options.target); // OK
- options.targets.a === DEFAULTS.target? $(options.target.a): $(document).find(options.target.a); // OK - should be sanitized by `MembershipTestSanitizer` - but still flagged because `AccessPath` can't handle these deeply nested properties [INCONSISTENCY]
+ target === DEFAULTS.target? $(target): $(document).find(target);
+ options.target === DEFAULTS.target? $(options.target): $(document).find(options.target);
+ options.targets.a === DEFAULTS.target? $(options.target.a): $(document).find(options.target.a); // $ SPURIOUS: Alert - should be sanitized by `MembershipTestSanitizer` - but still flagged because `AccessPath` can't handle these deeply nested properties
}
$.fn.my_plugin = function my_plugin(options) {
- $(anyPrefix + options.target); // OK (unlikely to be a html/css prefix confusion)
+ $(anyPrefix + options.target); // OK - unlikely to be a html/css prefix confusion
- $(something.replace("%PLACEHOLDER%", options.target)); // OK (unlikely to be a html/css prefix confusion);
+ $(something.replace("%PLACEHOLDER%", options.target)); // OK - (unlikely to be a html/css prefix confusion);
let target = options.target;
if (target.foo) {
- $(target); // OK (unlikely to be a string)
+ $(target); // OK - unlikely to be a string
}
if (target.length) {
- $(target); // NOT OK (can still be a string)
+ $(target); // $ Alert - can still be a string
}
}
@@ -176,10 +176,10 @@
$.fn.my_plugin = o.f
}
setupPlugin({f: function(options) {
- $(options.target); // NOT OK
+ $(options.target); // $ Alert
}});
setupPlugin({f:function(options) {
- $(document).find(options.target); // OK
+ $(document).find(options.target);
}});
$.fn.position = function( options ) {
@@ -189,14 +189,14 @@
// extending options
options = $.extend( {}, options );
- var target = $( options.of ); // NOT OK
+ var target = $( options.of ); // $ Alert
console.log(target);
};
$.fn.blockReceiver = function( options ) {
$.extend({
foo() {
- $(this); // OK
+ $(this);
}
},
options,
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/XssThroughDom/angular.ts b/javascript/ql/test/query-tests/Security/CWE-079/XssThroughDom/angular.ts
index 15207cb5059c..e9ca1f400890 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/XssThroughDom/angular.ts
+++ b/javascript/ql/test/query-tests/Security/CWE-079/XssThroughDom/angular.ts
@@ -13,24 +13,24 @@ export class Foo {
safeField: string = "";
setInput1(event) {
- document.write(event.target.value); // NOT OK
+ document.write(event.target.value); // $ Alert
}
setInput2(target) {
- document.write(target.value); // NOT OK
+ document.write(target.value); // $ Alert
}
setOtherInput(e) {
- document.write(e.target.value); // OK
- document.write(e.value); // OK
+ document.write(e.target.value);
+ document.write(e.value);
}
blah(form: NgForm) {
- document.write(form.value.foo); // NOT OK
+ document.write(form.value.foo); // $ Alert
}
useField() {
- document.write(this.field); // NOT OK
- document.write(this.safeField); // OK
+ document.write(this.field); // $ Alert
+ document.write(this.safeField);
}
}
diff --git a/javascript/ql/test/query-tests/Security/CWE-079/XssThroughDom/forms.js b/javascript/ql/test/query-tests/Security/CWE-079/XssThroughDom/forms.js
index b91b7490bb2d..c78fc9284a15 100644
--- a/javascript/ql/test/query-tests/Security/CWE-079/XssThroughDom/forms.js
+++ b/javascript/ql/test/query-tests/Security/CWE-079/XssThroughDom/forms.js
@@ -6,10 +6,10 @@ const FormikBasic = () => (
{
- $("#id").html(values.foo); // NOT OK
+ $("#id").html(values.foo); // $ Alert
}}
onSubmit={(values, { setSubmitting }) => {
- $("#id").html(values.bar); // NOT OK
+ $("#id").html(values.bar); // $ Alert
}}
>
{(inputs) => (
@@ -22,19 +22,19 @@ const FormikBasic = () => (
const FormikEnhanced = withFormik({
mapPropsToValues: () => ({ name: '' }),
validate: values => {
- $("#id").html(values.email); // NOT OK
+ $("#id").html(values.email); // $ Alert
},
handleSubmit: (values, { setSubmitting }) => {
- $("#id").html(values.email); // NOT OK
+ $("#id").html(values.email); // $ Alert
}
})(MyForm);
(function () {
const { values, submitForm } = useFormikContext();
- $("#id").html(values.email); // NOT OK
+ $("#id").html(values.email); // $ Alert
- $("#id").html(submitForm.email); // OK
+ $("#id").html(submitForm.email);
})
import { Form } from 'react-final-form'
@@ -42,7 +42,7 @@ import { Form } from 'react-final-form'
const App = () => (