mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
less duplicated headers in the sql-injection samples
This commit is contained in:
@@ -80,14 +80,14 @@ to ensure that the user input is interpreted as a literal value
|
||||
and not as a query object:
|
||||
</p>
|
||||
|
||||
<sample src="examples/NoSqlInjectionFix2.js" />
|
||||
<sample src="examples/NoSqlInjectionFix.js" />
|
||||
|
||||
<p>
|
||||
Alternatively check that the user input is a
|
||||
literal value and not a query object before using it:
|
||||
</p>
|
||||
|
||||
<sample src="examples/NoSqlInjectionFix.js" />
|
||||
<sample src="examples/NoSqlInjectionFix2.js" />
|
||||
</example>
|
||||
|
||||
<references>
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
const express = require("express");
|
||||
const mongoose = require("mongoose");
|
||||
const Todo = mongoose.model(
|
||||
"Todo",
|
||||
new mongoose.Schema({ text: { type: String } }, { timestamps: true })
|
||||
);
|
||||
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: false }));
|
||||
|
||||
app.delete("/api/delete", async (req, res) => {
|
||||
let id = req.body.id;
|
||||
await Todo.deleteOne({ _id: { $eq: id } }); // GOOD: using $eq operator for the comparison
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
const express = require("express");
|
||||
const mongoose = require("mongoose");
|
||||
const Todo = mongoose.model(
|
||||
"Todo",
|
||||
new mongoose.Schema({ text: { type: String } }, { timestamps: true })
|
||||
);
|
||||
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: false }));
|
||||
|
||||
app.delete("/api/delete", async (req, res) => {
|
||||
let id = req.body.id;
|
||||
if (typeof id !== "string") {
|
||||
|
||||
Reference in New Issue
Block a user