less duplicated headers in the sql-injection samples

This commit is contained in:
erik-krogh
2023-05-31 13:51:38 +02:00
parent 98820780af
commit 1e08105863
3 changed files with 2 additions and 24 deletions

View File

@@ -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>

View File

@@ -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

View File

@@ -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") {