(call)
method calls
clojure
(call receiver? args?)Where:
Matching:
- regular calls, e.g.
foo() - calls with receivers, e.g.
obj.foo() - calls without parentheses, e.g.
foo x
Behavior
- Receiver matching only supports identifier method names (operator methods like
+are not supported).
Examples
Find shell-outs that pass string commands.
clojure
(call (id system) (arg 1 (str)))Selects in lines { 1, 3 } but not in { 2 }:
ruby
system("ls -la")
system(cmd)
Kernel.system("whoami")Locate puts calls that print debug strings.
clojure
(call (id puts) (arg 1 (str /^DEBUG:/)))Selects in lines { 1 } but not in { 2, 3 }:
ruby
puts "DEBUG: start"
puts "INFO: start"
logger.info("DEBUG: start")Find gsub calls that replace spaces with underscores.
clojure
(call (id gsub) (:and (arg 1 (str " ")) (arg 2 (str "_"))))Selects in lines { 1 } but not in { 2, 3 }:
ruby
title.gsub(" ", "_")
title.gsub("-", "_")
name.sub(" ", "_")Arguments
receiver
• Identifier: shorthand for (id)
• Pattern: shorthand for (id)
• (:kind) • (:ref) • (:text) • (call) • (id) • (num) • (proc) • (str) • (:into) • (:and) • (:or) • (:not) • (:replace) • (:capture)
args
• (arg)
• (:into) • (:and) • (:or) • (:not) • (:text) • (:kind) • (:replace) • (:capture)