forked from webschik/tslint-config-security
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ts.lint
22 lines (16 loc) · 778 Bytes
/
test.ts.lint
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const userId = 1;
let query = `SELECT * FROM users WHERE id = ${userId}`;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Found possible SQL injection]
query = `SELECT *FROM users WHERE id = ` + userId;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Found possible SQL injection]
query = ' SELECT * FROM users WHERE id =' + userId;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Found possible SQL injection]
db.query(query);
const columns = 'id, name';
Users.query( ` SELECT ${columns} FROM users` );
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Found possible SQL injection]
const query = sql`SELECT * FROM users WHERE id = ${userId}`;
db.query(query);
Users.query(`SELECT id, name FROM users`);
const punctuation = '!';
console.log(`Not SQL${punctuation}`);