5. Decide what AST element to match
Specify to write an AST rule for different element type. The element type specifies that particular node of the AST you focus on. This node will be the entry point of your analysis rules.
try block:
check a try/except blockfunction call:
check a function call in Python (e.g. function(val1, val2))function definition:
check the definition of a function (e.g. def myfunction(val1, val2):)for loop:
check a for loop (e.g. for i in ...)if condition:
check a if condition (e.g. if foo == bar:)import:
check an import statement (e.g. import mypackage or from mypackage import foo)assignment:
check an assignment (e.g. foo = "bar" or foo = bar(baz))
Before you start writing your rule, think about what element of a program you want to check, which will indicate the correct value for the element checked.
Let's go!
Start interacting with the tutorial!
Rule type