mirror of
https://codeberg.org/mclemens/esm2markdown.git
synced 2024-11-03 07:07:37 -05:00
several bugixes
This commit is contained in:
parent
49e79abf49
commit
035d2dc53f
@ -39,11 +39,16 @@ def line(level,key,value):
|
|||||||
lvl = level3
|
lvl = level3
|
||||||
else:
|
else:
|
||||||
lvl = ""
|
lvl = ""
|
||||||
if value:
|
if key:
|
||||||
valout = " " + value
|
if value == "N/A":
|
||||||
output = lvl + style + key + style + valout + "\n"
|
output = lvl + style + key + style + "\n"
|
||||||
|
elif value:
|
||||||
|
output = lvl + style + key + style + " " + value + "\n"
|
||||||
|
else:
|
||||||
|
output = ""
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
def main(xmlfile,outfile):
|
def main(xmlfile,outfile):
|
||||||
|
|
||||||
file = open(outfile,"w")
|
file = open(outfile,"w")
|
||||||
@ -73,18 +78,16 @@ def main(xmlfile,outfile):
|
|||||||
# Print rule parameters
|
# Print rule parameters
|
||||||
file.write("### Parameters\n")
|
file.write("### Parameters\n")
|
||||||
for param in cdata.getiterator('param'):
|
for param in cdata.getiterator('param'):
|
||||||
if (param.get('name')):
|
file.write(line(1,param.get('name'),"N/A"))
|
||||||
file.write(line(1,param.get('name'),""))
|
|
||||||
file.write(line(2,"Description:",param.get('description')))
|
file.write(line(2,"Description:",param.get('description')))
|
||||||
file.write(line(2,"Default Value:",param.get('defaultvalue')))
|
file.write(line(2,"Default Value:",param.get('defaultvalue')))
|
||||||
# Print trigger information (Sequence, Timeout, Time Unit, Threshold)
|
# Print trigger information (Sequence, Timeout, Time Unit, Threshold)
|
||||||
file.write("### Trigger\n")
|
file.write("### Trigger\n")
|
||||||
for trigger in cdata.getiterator('trigger'):
|
for trigger in cdata.getiterator('trigger'):
|
||||||
if (trigger.get('name')):
|
file.write(line(1,trigger.get('name'),"N/A"))
|
||||||
file.write(line(1,trigger.get('name'),""))
|
file.write(line(2,"Timeout:",trigger.get('timeout')))
|
||||||
file.write(line(2,"Timeout:",trigger.get('timeout') + " " + trigger.get('timeUnit')))
|
file.write(line(2,"Time Units:",trigger.get('timeUnit')))
|
||||||
file.write(line(2,"Threshold:",trigger.get('threshold')))
|
file.write(line(2,"Threshold:",trigger.get('threshold')))
|
||||||
if (trigger.get('ordered')):
|
|
||||||
file.write(line(2,"Sequence:",trigger.get('ordered')))
|
file.write(line(2,"Sequence:",trigger.get('ordered')))
|
||||||
file.write("### Rules\n")
|
file.write("### Rules\n")
|
||||||
# Parse CDATA element and print correlation rule match blocks
|
# Parse CDATA element and print correlation rule match blocks
|
||||||
@ -95,26 +98,19 @@ def main(xmlfile,outfile):
|
|||||||
file.write("#### " + r.get('name') + "\n")
|
file.write("#### " + r.get('name') + "\n")
|
||||||
for e in r.iter():
|
for e in r.iter():
|
||||||
if str(e.tag) == 'activate':
|
if str(e.tag) == 'activate':
|
||||||
if (e.get('type')):
|
|
||||||
file.write(line(1,"Activate:",e.get('type')))
|
file.write(line(1,"Activate:",e.get('type')))
|
||||||
if str(e.tag) == 'action':
|
if str(e.tag) == 'action':
|
||||||
file.write(line(1,"Action",""))
|
file.write(line(1,"Action","N/A"))
|
||||||
if (e.get('type')):
|
|
||||||
file.write(line(2,"Type:",e.get('type')))
|
file.write(line(2,"Type:",e.get('type')))
|
||||||
if (e.get('trigger')):
|
|
||||||
file.write(line(2,"Trigger:",e.get('trigger')))
|
file.write(line(2,"Trigger:",e.get('trigger')))
|
||||||
if str(e.tag) == 'match':
|
if str(e.tag) == 'match':
|
||||||
file.write(line(1,"Match",""))
|
file.write(line(1,"Match","N/A"))
|
||||||
if (e.get('count')):
|
|
||||||
file.write(line(2,"Count:",e.get('count')))
|
file.write(line(2,"Count:",e.get('count')))
|
||||||
if (e.get('matchType')):
|
|
||||||
file.write(line(2,"Match Type:",e.get('matchType')))
|
file.write(line(2,"Match Type:",e.get('matchType')))
|
||||||
if str(e.tag) == 'matchFilter':
|
if str(e.tag) == 'matchFilter':
|
||||||
file.write(line(1,"Match Filter",""))
|
file.write(line(1,"Match Filter","N/A"))
|
||||||
if (e.get('type')):
|
|
||||||
file.write(line(2,"Logical Element Type:",e.get('type')))
|
file.write(line(2,"Logical Element Type:",e.get('type')))
|
||||||
if str(e.tag) == 'singleFilterComponent':
|
if str(e.tag) == 'singleFilterComponent':
|
||||||
if (e.get('type')):
|
|
||||||
t = e.get('type')
|
t = e.get('type')
|
||||||
if str(e.tag) == 'filterData':
|
if str(e.tag) == 'filterData':
|
||||||
if (e.get('name') == "operator"):
|
if (e.get('name') == "operator"):
|
||||||
@ -122,8 +118,10 @@ def main(xmlfile,outfile):
|
|||||||
if (e.get('name') == "value"):
|
if (e.get('name') == "value"):
|
||||||
v = e.get('value')
|
v = e.get('value')
|
||||||
if o and v and t:
|
if o and v and t:
|
||||||
file.write(line(2,"Filter Component",""))
|
file.write(line(2,"Filter Component","N/A"))
|
||||||
file.write(line(3,"Condition:","'" + t + "' " + o + " '" + v + "'"))
|
file.write(line(3,"Condition:","'" + t + "' " + o + " '" + v + "'"))
|
||||||
|
v = ""
|
||||||
|
o = ""
|
||||||
file.write("******\n")
|
file.write("******\n")
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user