import libxml2
from sfatables.globals import *
-class Xmlrule:
+class XMLRule:
rule_number = None
chain = None
xmldoc = None
+ terminal = 0
arguments = {'match':None,'target':None}
processors = {'match':None,'target':None}
context = {'match':None,'target':None}
def load_xml_extension (self, type, chain, rule_number):
- filename = sfatables_config+"/"+chain+"/"+"sfatables-%d-%s.xml"%(rule_number,type)
+ filename = sfatables_config+"/"+chain+"/"+"sfatables-%d-%s"%(rule_number,type)
self.xmldoc = libxml2.parseFile(filename)
p = self.xmldoc.xpathNewContext()
processor = p.xpathEval('//processor/@filename')
- self.processor[type] = processor[0].content
+ context = p.xpathEval('//attributes/attribute[@terminal="yes"]')
+ if (context != []):
+ self.terminal = 1
+
+ self.processors[type] = processor[0].content
self.arguments[type] = p.xpathEval('//rule')
p.xpathFreeContext()
- return
def wrap_rspec (self, type, rspec):
argument = self.arguments[type]
p = rspec.xmldoc.xpathNewContext()
root_node = p.xpathEval('/RSpec')
- if (!root_node or !len(root_node)):
+ if (not root_node or not root_node):
raise Exception('An evil aggregate manager sent me a malformed RSpec. Please see the stack trace to identify it.')
root_node.addChild(arguments[type])