-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds implementatio to all nodes that we're considering
- Loading branch information
1 parent
f7deacf
commit 68659a7
Showing
5 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,24 @@ | ||
from ast.nodes import * | ||
|
||
|
||
class IfThenElseNode(ChildfulNode): | ||
def __init__(self, kind, test, body, alternate=None): | ||
ChildfulNode.__init__(self, kind, body) | ||
self.test = test # An expression | ||
self.body = body # A list of Nodes | ||
self.alternate = alternate # A IfThenElse node or None | ||
|
||
|
||
# A SwitchNode's child are its CaseNodes | ||
class SwitchNode(ChildfulNode): | ||
def __init__(self, kind, test, body): | ||
ChildfulNode.__init__(self, kind, body) | ||
self.test = test | ||
|
||
|
||
class CaseNode(ChildfulNode): | ||
def __init__(self, kind, test, body): | ||
ChildfulNode.__init__(self, kind, body) | ||
self.test = test | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,67 @@ | ||
from ast.nodes import * | ||
|
||
|
||
class ExpressionNode(Node): | ||
def __init__(self, kind): | ||
Node.__init__(self, kind) | ||
|
||
|
||
class AttributionNode(ExpressionNode): | ||
def __init__(self, kind, left_expr, right_expr): | ||
ExpressionNode.__init__(self, kind) | ||
self.left_expr = left_expr | ||
self.right_expr = right_expr | ||
|
||
|
||
class UnaryExpression(ExpressionNode): | ||
def __init__(self, kind, type, expr): | ||
ExpressionNode.__init__(self, kind) | ||
self.type = type # The Unary operator, like '!' and '++' | ||
self.expr = expr # Every Unary expression has an expression associated with it | ||
|
||
|
||
class BinaryExpression(ExpressionNode): | ||
def __init__(self, kind, type, left_expr, right_expr): | ||
ExpressionNode.__init__(self, kind) | ||
self.type = type # The operator, like '+' or '*' | ||
self.left_expr = left_expr # Every binary expression has a left expr and a.. | ||
self.right_expr = right_expr # right expression! | ||
|
||
|
||
class TernaryExpression(ExpressionNode): | ||
def __init__(self, kind, test, true_expr, false_expr): | ||
ExpressionNode.__init__(self, kind) | ||
self.test = test | ||
self.true_expr = true_expr | ||
self.false_expr = false_expr | ||
|
||
|
||
# FIXME assumption - an indexation is a variable | ||
# so $a[1] is a variable node | ||
class VariableNode(ExpressionNode): | ||
def __init__(self, kind, name): | ||
ExpressionNode.__init__(self, kind) | ||
self.name = name | ||
|
||
|
||
# FIXME assumption - we're not handling indexation calls | ||
# so $a[1]("ha"); isn't handled | ||
class FunctionCallNode(ExpressionNode): | ||
def __init__(self, kind, name, arguments): | ||
ExpressionNode.__init__(self, kind) | ||
self.name = name | ||
self.arguments = arguments # arguments is a list of VariableNodes | ||
|
||
|
||
# Stuff like $_GET and $_POST | ||
class EntryPointNode(VariableNode): | ||
def __init__(self, kind, name): | ||
VariableNode.__init__(self, kind, name) | ||
self.tainted = True | ||
self.visited = True | ||
|
||
|
||
class ConstantNode(ExpressionNode): | ||
def __init__(self, kind, value): | ||
ExpressionNode.__init__(self, kind) | ||
self.value = value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
from ast.nodes import * | ||
|
||
|
||
# FIXME assumption, we're ignoring type hinting | ||
class FunctionDefinitionNode(ChildfulNode): | ||
def __init__(self, kind, name, arguments, children): | ||
ChildfulNode.__init__(self, kind, children) | ||
self.name = name | ||
self.arguments = arguments # arguments is a list of VariableNodes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters