Skip to content

Commit

Permalink
Ensure sql.raw doesn't perform any escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Azzolini committed May 10, 2018
1 parent cdf8caf commit 6f00342
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/sql.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,11 @@ describe('sql', () => {
expect(sql`SELECT * FROM a WHERE 1 = 1 ${sql.raw(childExpr)}`)
.toEqual("SELECT * FROM a WHERE 1 = 1 AND id = '2'")
})

test("raw expressions don't help against SQL injection", () => {
const name = "Robert'); DROP TABLE Students; --"

expect(sql`SELECT * FROM oh_no WHERE name IN ('${sql.raw(name)}')`)
.toEqual("SELECT * FROM oh_no WHERE name IN ('Robert'); DROP TABLE Students; --')")
})
})

0 comments on commit 6f00342

Please sign in to comment.