-
Notifications
You must be signed in to change notification settings - Fork 19
Abstraction Functions
Here you can read descriptions about the core instance methods used by the abstraction functionality of the radar template rule syntax.
to_result(self)Converts the current node and its children into a dictionary format suitable for serialization and further processing as a finding result location.
find_by_parent(self, parent_ident: str) -> ASTNodeListFinds all nodes whose parent has the specified identifier and returns them as an ASTNodeList.
find_chained_calls(self, *idents: tuple[str, ...]) -> ASTNodeListGroupFinds sequences of sequential nodes matching the specified identifiers and returns them as an ASTNodeListGroup.
find_by_access_path(self, access_path: str, keyword: str) -> ASTNodeListFinds nodes whose access_path contains the specified keyword within the specified access path and returns them as an ASTNodeList.
access_path is a value representing the sequence of AST nodes walked until indexing of the node, that did not get indexed (due to not being a prime node).
find_comparisons_between(self, ident1: str, ident2: str)Finds binary comparisons between the specified identifiers within the AST and returns them as an ASTNodeList.
find_comparison_involving(self, ident: str)Finds any node involved in a comparison with the specified identifier and returns them as an ASTNodeList.
find_negative_of_operation(self, operation_name: str, *args: tuple) -> ASTNodeListFinds nodes that do not match the results of the specified operation and returns them as an ASTNodeList.
"operation" refers to an ASTNode instance method.
find_functions_by_names(self, *function_names: tuple[str, ...]) -> ASTNodeListFinds function nodes that match any of the specified function names and returns them as an ASTNodeList.
find_by_names(self, *idents: tuple[str, ...]) -> ASTNodeListFinds nodes that match any of the specified identifiers within the AST and returns them as an ASTNodeList.
find_method_calls(self, caller: str, method: str) -> ASTNodeListFinds method call nodes where the caller matches the specified identifier and the method name matches the specified method and returns them as an ASTNodeList.
find_assignments(self, ident: str, value_ident: str) -> ASTNodeListFinds assignment nodes where the left-hand side matches the specified identifier and the right-hand side matches the specified value identifier and returns them as an ASTNodeList.
find_mutables(self) -> ASTNodeListFinds nodes marked as mut: true within the AST and returns them as an ASTNodeList.
find_account_typed_nodes(self, ident: str) -> ASTNodeListFinds nodes that are Account-typed based on their access_path and parent identifier and returns them as an ASTNodeList.
find_member_accesses(self, ident: str) -> ASTNodeListFinds nodes that represent member accesses matching the specified identifier within the AST and returns them as an ASTNodeList.
first(self)Returns the first node in the list or calls exit_on_none if the list is empty.
to_result(self)Converts each node in the list to its dictionary representation and returns the list of these representations, in a format suitable for serialization and further processing as a finding result location.
exit_on_none(self)Raises a StopIteration exception if the list is empty. Allows wrapping a for loop iteration within try/except, and continue to the next iteration when the return value of the previous function is None.
exit_on_value(self)Raises a StopIteration exception if the list contains any nodes. Allows wrapping a for loop iteration within try/except, and continue to the next iteration when the return value of the previous function has results.