Disable ts injections in import strings (#371)

Import paths like 'database/sql' are string literals and activate the
SQL injection. Adding a #not-has-ancestor predicate for
import_declaration prevents this.
pull/373/head
Matthew Sykes 9 months ago committed by GitHub
parent a370cb9327
commit da108721c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,6 +19,7 @@
(interpreted_string_literal)
(raw_string_literal)
] @sql
(#not-has-ancestor? @sql import_declaration)
(#match? @sql "(SELECT|select|INSERT|insert|UPDATE|update|DELETE|delete).+(FROM|from|INTO|into|VALUES|values|SET|set).*(WHERE|where|GROUP BY|group by)?")
(#offset! @sql 0 1 0 -1))
@ -29,6 +30,7 @@
(interpreted_string_literal)
(raw_string_literal)
] @sql
(#not-has-ancestor? @sql import_declaration)
(#contains? @sql "-- sql" "--sql" "ADD CONSTRAINT" "ALTER TABLE" "ALTER COLUMN"
"DATABASE" "FOREIGN KEY" "GROUP BY" "HAVING" "CREATE INDEX" "INSERT INTO"
"NOT NULL" "PRIMARY KEY" "UPDATE SET" "TRUNCATE TABLE" "LEFT JOIN" "add constraint" "alter table" "alter column" "database" "foreign key" "group by" "having" "create index" "insert into"

Loading…
Cancel
Save