Skip to content

Instantly share code, notes, and snippets.


andrwgldmn/gromozdko Secret

Created Mar 10, 2019
What would you like to do?
with open('log.txt') as input_file, open('allows.txt', 'w') as output_file:
output_file.writelines(i for i in input_file if 'avc: denied' in i)
with open('allows.txt') as input_file, open('allows.te', 'w') as output_file:
text =
for scontext in re.findall('scontext=u:r:(.+?):s0', text):
scontext_wr = 'allow {}'.format(scontext)
for tcontext in re.findall('tcontext=u:r:(.+?):s0', text):
tcontext_wr = ' {}:'.format(tcontext)
for tcls in re.findall('tclass=(.+?):s0', text):
tcls_w = '{} '.format(tcls)
for braces in re.findall('denied (.+?) for', text):
braces_wr = '{}; \n'.format(braces)
output = (scontext_wr + tcontext_wr + tcls_w + braces_wr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment