|
|
|
@ -9,12 +9,27 @@
|
|
|
|
|
(argument_list
|
|
|
|
|
(interpreted_string_literal) @sql))
|
|
|
|
|
(#any-of? @_field "Exec" "GetContext" "ExecContext" "SelectContext" "In"
|
|
|
|
|
"RebindNamed" "Rebind" "QueryRowxContext" "NamedExec" "MustExec" "Get" "Queryx")
|
|
|
|
|
"RebindNamed" "Rebind" "Query" "QueryRow" "QueryRowxContext" "NamedExec" "MustExec" "Get" "Queryx")
|
|
|
|
|
(#offset! @sql 0 1 0 -1))
|
|
|
|
|
|
|
|
|
|
; ----------------------------------------------------------------
|
|
|
|
|
; a general query injection
|
|
|
|
|
; still buggy for nvim 0.10
|
|
|
|
|
((call_expression
|
|
|
|
|
(selector_expression
|
|
|
|
|
field: (field_identifier) @_field (#any-of? @_field "Exec" "GetContext" "ExecContext" "SelectContext" "In" "RebindNamed" "Rebind" "Query" "QueryRow" "QueryRowxContext" "NamedExec" "MustExec" "Get" "Queryx"))
|
|
|
|
|
(argument_list
|
|
|
|
|
(interpreted_string_literal) @injection.content))
|
|
|
|
|
(#offset! @injection.content 0 1 0 -1)
|
|
|
|
|
(#set! injection.language "sql"))
|
|
|
|
|
|
|
|
|
|
; neovim nightly 0.10
|
|
|
|
|
([
|
|
|
|
|
(interpreted_string_literal)
|
|
|
|
|
(raw_string_literal)
|
|
|
|
|
] @injection.content
|
|
|
|
|
(#match? @injection.content "(SELECT|select|INSERT|insert|UPDATE|update|DELETE|delete).+(FROM|from|INTO|into|VALUES|values|SET|set).*(WHERE|where|GROUP BY|group by)?")
|
|
|
|
|
(#set! injection.language "sql"))
|
|
|
|
|
|
|
|
|
|
; a general query injection
|
|
|
|
|
([
|
|
|
|
|
(interpreted_string_literal)
|
|
|
|
|
(raw_string_literal)
|
|
|
|
@ -35,6 +50,19 @@
|
|
|
|
|
"not null" "primary key" "update set" "truncate table" "left join")
|
|
|
|
|
(#offset! @sql 0 1 0 -1))
|
|
|
|
|
|
|
|
|
|
; nvim 0.10
|
|
|
|
|
([
|
|
|
|
|
(interpreted_string_literal)
|
|
|
|
|
(raw_string_literal)
|
|
|
|
|
] @injection.content
|
|
|
|
|
(#contains? @injection.content "-- 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"
|
|
|
|
|
"not null" "primary key" "update set" "truncate table" "left join")
|
|
|
|
|
(#offset! @injection.content 0 1 0 -1)
|
|
|
|
|
(#set! injection.language "sql"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; should I use a more exhaustive list of keywords?
|
|
|
|
|
; "ADD" "ADD CONSTRAINT" "ALL" "ALTER" "AND" "ASC" "COLUMN" "CONSTRAINT" "CREATE" "DATABASE" "DELETE" "DESC" "DISTINCT" "DROP" "EXISTS" "FOREIGN KEY" "FROM" "JOIN" "GROUP BY" "HAVING" "IN" "INDEX" "INSERT INTO" "LIKE" "LIMIT" "NOT" "NOT NULL" "OR" "ORDER BY" "PRIMARY KEY" "SELECT" "SET" "TABLE" "TRUNCATE TABLE" "UNION" "UNIQUE" "UPDATE" "VALUES" "WHERE"
|
|
|
|
|
|
|
|
|
@ -54,3 +82,22 @@
|
|
|
|
|
(raw_string_literal) @json))
|
|
|
|
|
(#lua-match? @_var ".*[J|j]son.*")
|
|
|
|
|
(#offset! @json 0 1 0 -1))
|
|
|
|
|
|
|
|
|
|
; nvim 0.10
|
|
|
|
|
|
|
|
|
|
(const_spec
|
|
|
|
|
name: ((identifier) @_const(#lua-match? @_const ".*[J|j]son.*"))
|
|
|
|
|
value: (expression_list (raw_string_literal) @injection.content
|
|
|
|
|
(#set! injection.language "json")))
|
|
|
|
|
|
|
|
|
|
(short_var_declaration
|
|
|
|
|
left: (expression_list (identifier) @_var (#lua-match? @_var ".*[J|j]son.*"))
|
|
|
|
|
right: (expression_list (raw_string_literal) @injection.content)
|
|
|
|
|
(#offset! @injection.content 0 1 0 -1)
|
|
|
|
|
(#set! injection.language "json"))
|
|
|
|
|
|
|
|
|
|
(var_spec
|
|
|
|
|
name: ((identifier) @_const(#lua-match? @_const ".*[J|j]son.*"))
|
|
|
|
|
value: (expression_list (raw_string_literal) @injection.content
|
|
|
|
|
(#set! injection.language "json")))
|
|
|
|
|
|
|
|
|
|