naxsi
naxsi copied to clipboard
Python3 support
nxapi codes are modified for python3 support.
Sorry for the late review, has this been tested?
Actually not tested fully.
Koray YILMAZ,Msc System Administrator Physics Engineer
Giovanni [email protected], 18 Ara 2019 Çar, 19:02 tarihinde şunu yazdı:
@wargio requested changes on this pull request.
I think this should be merged in a py3 only branch of naxsi
In nxapi/nxapi/nxparse.py https://github.com/nbs-system/naxsi/pull/483#discussion_r359427106:
pprint.pprint(items)
bulk(self.es, items, index=self.cfg["elastic"]["index"], doc_type="events", raise_on_error=True) self.total_commits += count logging.debug("Written "+str(self.total_commits)+" events")
print "Written "+str(self.total_commits)+" events"
print("Written "+str(self.total_commits)+" events")
since this mixes the code with py2 stuff and py3, i would suggest for the prints to use the "".format() method available in the string object.
This should then be changed to
print("Written {} events".format(self.total_commits))
In nxapi/nxapi/nxtransform.py https://github.com/nbs-system/naxsi/pull/483#discussion_r359427651:
@@ -106,11 +107,11 @@ def check_score(self, tpl_success=None, tpl_warnings=None, tpl_deny=None): res = self.check_rule(k, scheck[k]) if res['check'] is True: if debug is True:
print "[SUCCESS] OK, on "+k+" vs "+str(res['curr'])+", check :"+str(scheck[k][0])+" - "+str(scheck[k][1])
print("[SUCCESS] OK, on "+k+" vs "+str(res['curr'])+", check :"+str(scheck[k][0])+" - "+str(scheck[k][1]))
format here
In nxapi/nxapi/nxtransform.py https://github.com/nbs-system/naxsi/pull/483#discussion_r359427707:
success.append({'key' : k, 'criteria' : scheck[k], 'curr' : res['curr']})
else: if debug is True:
print "[SUCCESS] KO, on "+k+" vs "+str(res['curr'])+", check :"+str(scheck[k][0])+" - "+str(scheck[k][1])
print("[SUCCESS] KO, on "+k+" vs "+str(res['curr'])+", check :"+str(scheck[k][0])+" - "+str(scheck[k][1]))
format here
In nxapi/nxapi/nxtransform.py https://github.com/nbs-system/naxsi/pull/483#discussion_r359427755:
@@ -120,11 +121,11 @@ def check_score(self, tpl_success=None, tpl_warnings=None, tpl_deny=None): res = self.check_rule(k, fcheck[k]) if res['check'] is True: if debug is True:
print "[WARNINGS] TRIGGERED, on "+k+" vs "+str(res['curr'])+", check :"+str(fcheck[k][0])+" - "+str(fcheck[k][1])
print("[WARNINGS] TRIGGERED, on "+k+" vs "+str(res['curr'])+", check :"+str(fcheck[k][0])+" - "+str(fcheck[k][1]))
format here
In nxapi/nxapi/nxtransform.py https://github.com/nbs-system/naxsi/pull/483#discussion_r359427805:
warning.append({'key' : k, 'criteria' : fcheck[k], 'curr' : res['curr']})
else: if debug is True:
print "[WARNINGS] NOT TRIGGERED, on "+k+" vs "+str(res['curr'])+", check :"+str(fcheck[k][0])+" - "+str(fcheck[k][1])
print("[WARNINGS] NOT TRIGGERED, on "+k+" vs "+str(res['curr'])+", check :"+str(fcheck[k][0])+" - "+str(fcheck[k][1]))
format here
In nxapi/nxapi/nxtransform.py https://github.com/nbs-system/naxsi/pull/483#discussion_r359427952:
@@ -177,7 +178,7 @@ def init(self, es, cfg): self.core_msg = {} # by default, es queries will return 1000 results max self.es_max_size = self.cfg.get("elastic").get("max_size", 1000)
print "# size :"+str(self.es_max_size)
print("# size :"+str(self.es_max_size))
format here
In nxapi/nxapi/nxtransform.py https://github.com/nbs-system/naxsi/pull/483#discussion_r359428093:
@@ -261,9 +262,9 @@ def fancy_display(self, full_wl, scores, template=None):
pprint.pprint(scores)
for x in scores['success']:
print "# success : "+self.grn.format(str(x['key'])+" is "+str(x['curr']))
print("# success : "+self.grn.format(str(x['key'])+" is "+str(x['curr'])))
format here
In nxapi/nxapi/nxtransform.py https://github.com/nbs-system/naxsi/pull/483#discussion_r359428129:
for x in scores['warnings']:
print "# warnings : "+self.grn.format(str(x['key'])+" is "+str(x['curr']))
print("# warnings : "+self.grn.format(str(x['key'])+" is "+str(x['curr'])))
format here
In nxapi/nxapi/nxtransform.py https://github.com/nbs-system/naxsi/pull/483#discussion_r359428265:
pprint.pprint(esq)
x = self.search(esq) total_events = int(str(x["hits"]["total"]))
print str(self.grn.format(total_events)) + " items to be tagged ..."
print(str(self.grn.format(total_events)) + " items to be tagged ...")
format here
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nbs-system/naxsi/pull/483?email_source=notifications&email_token=ABQEWL4NSZKTWSAFVRB34E3QZJCSVA5CNFSM4JPQ65IKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCPU2D7I#pullrequestreview-334078461, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQEWL4M7FJYQ6IBYG3RIVDQZJCSVANCNFSM4JPQ65IA .