Nettoie list_firewall.py, plus un oublie dans list_exempt
* output est une liste d'unicodes, mieux vaut .join() sur un unicode
This commit is contained in:
parent
a5ddd73ce5
commit
94ee83b86a
2 changed files with 38 additions and 27 deletions
|
@ -12,12 +12,12 @@ def make_output(ldap):
|
||||||
machines_avec_exemption = ldap.search(u"exempt=*")
|
machines_avec_exemption = ldap.search(u"exempt=*")
|
||||||
output = []
|
output = []
|
||||||
|
|
||||||
for m in machines_avec_exemption:
|
for machine in machines_avec_exemption:
|
||||||
# texte pour la machine
|
# texte pour la machine
|
||||||
txt = u''
|
txt = u''
|
||||||
txt += u'Propriétaire : %s\n' % m.proprio()
|
txt += u'Propriétaire : %s\n' % machine.proprio()
|
||||||
txt += u'Machine : %s\n' % m['host'][0]
|
txt += u'Machine : %s\n' % machine['host'][0]
|
||||||
txt += u'destination : %s\n' % ', '.join([unicode(i) for i in m['exempt']])
|
txt += u'destination : %s\n' % ', '.join([unicode(i) for i in machine['exempt']])
|
||||||
|
|
||||||
output.append(txt.strip())
|
output.append(txt.strip())
|
||||||
return output
|
return output
|
||||||
|
@ -26,4 +26,4 @@ if __name__ == '__main__':
|
||||||
LDAP = shortcuts.lc_ldap_readonly()
|
LDAP = shortcuts.lc_ldap_readonly()
|
||||||
OUTPUT = make_output(LDAP)
|
OUTPUT = make_output(LDAP)
|
||||||
|
|
||||||
print '\n- - - - - - = = = = = = # # # # # # # # = = = = = = - - - - - -\n'.join(OUTPUT).encode(out_encoding)
|
print u'\n- - - - - - = = = = = = # # # # # # # # = = = = = = - - - - - -\n'.join(OUTPUT).encode(out_encoding)
|
||||||
|
|
|
@ -1,32 +1,43 @@
|
||||||
#!/bin/bash /usr/scripts/python.sh
|
#!/bin/bash /usr/scripts/python.sh
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# list_firewall.py --- Liste les machines disposant de droits
|
||||||
|
# particuliers en ce qui concerne leurs ports accessibles.
|
||||||
|
"""Liste les machines dont certains ports sont whielistés par
|
||||||
|
le parefeu"""
|
||||||
|
|
||||||
from lc_ldap import shortcuts
|
from lc_ldap import shortcuts
|
||||||
|
from config.encoding import out_encoding
|
||||||
|
|
||||||
ldap = shortcuts.lc_ldap_readonly()
|
def make_output(ldap):
|
||||||
|
"""Génère un texte à afficher"""
|
||||||
|
machines_speciales = ldap.search(u"(|(portTCPin=*)(portTCPout=*)(portUDPin=*)(portUDPout=*))")
|
||||||
|
|
||||||
machines = ldap.search(u"(|(portTCPin=*)(portTCPout=*)(portUDPin=*)(portUDPout=*))")
|
output = []
|
||||||
|
|
||||||
txts = []
|
for machine in machines_speciales:
|
||||||
|
|
||||||
for m in machines :
|
|
||||||
# On se fiche des machines crans
|
# On se fiche des machines crans
|
||||||
if m['objectClass'][0] not in ["machineFixe","machineWifi"]:
|
if machine['objectClass'][0] not in ["machineFixe", "machineWifi"]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# texte pour la machine
|
# texte pour la machine
|
||||||
txt = u''
|
txt = u''
|
||||||
txt += u'Propriétaire : %s\n' % str(m.proprio()).decode('utf8')
|
txt += u'Propriétaire : %s\n' % machine.proprio()
|
||||||
txt += u'Machine : %s\n' % m['host'][0]
|
txt += u'Machine : %s\n' % machine['host'][0]
|
||||||
if m['portTCPin']:
|
if machine['portTCPin']:
|
||||||
txt += u'ports TCP in : %s\n' % ' '.join([unicode(port) for port in m['portTCPin']])
|
txt += u'ports TCP in : %s\n' % ' '.join([unicode(port) for port in machine['portTCPin']])
|
||||||
if m['portTCPout']:
|
if machine['portTCPout']:
|
||||||
txt += u'ports TCP out : %s\n' % ' '.join([unicode(port) for port in m['portTCPout']])
|
txt += u'ports TCP out : %s\n' % ' '.join([unicode(port) for port in machine['portTCPout']])
|
||||||
if m['portUDPin']:
|
if machine['portUDPin']:
|
||||||
txt += u'ports UDP in : %s\n' % ' '.join([unicode(port) for port in m['portUDPin']])
|
txt += u'ports UDP in : %s\n' % ' '.join([unicode(port) for port in machine['portUDPin']])
|
||||||
if m['portUDPout']:
|
if machine['portUDPout']:
|
||||||
txt += u'ports UDP out : %s\n' % ' '.join([unicode(port) for port in m['portTCPout']])
|
txt += u'ports UDP out : %s\n' % ' '.join([unicode(port) for port in machine['portTCPout']])
|
||||||
|
|
||||||
txts.append(txt.strip())
|
output.append(txt.strip())
|
||||||
|
return output
|
||||||
|
|
||||||
print '\n- - - - - - = = = = = = # # # # # # # # = = = = = = - - - - - -\n'.join(txts)
|
if __name__ == '__main__':
|
||||||
|
LDAP = shortcuts.lc_ldap_readonly()
|
||||||
|
OUTPUT = make_output(LDAP)
|
||||||
|
|
||||||
|
print u'\n- - - - - - = = = = = = # # # # # # # # = = = = = = - - - - - -\n'.join(OUTPUT).encode(out_encoding)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue