Skip to content

Commit 311c12d

Browse files
committed
Create build_map_rule_cleaner.py
Build map rule cleaner
1 parent 0fe9719 commit 311c12d

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

sailpoint/build_map_rule_cleaner.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python3
2+
__author__ = "Munir Njiru"
3+
__email__ = "munir@alien-within.com"
4+
__status__ = "Production"
5+
'''
6+
This script takes a minified bean shell script from the Sailpoint API and
7+
parses it into a neat java file to allow editing later.
8+
'''
9+
import argparse
10+
import random
11+
import string
12+
global clean_shell,output_file, bmr_string, bmr_file
13+
parser = argparse.ArgumentParser()
14+
parser.add_argument('-f', '--file', help='Load a text file with the beanshell code')
15+
parser.add_argument('-s', '--string', help='Paste a string the beanshell code')
16+
args = parser.parse_args()
17+
def from_string(bmr_string):
18+
clean_shell = bmr_string.replace('\"','"').replace('\\n', '\n').replace('\\t', '\t')
19+
file_name= ''.join(random.choice(string.ascii_letters) for i in range(10))+".bsh"
20+
output_file = open(str(file_name), "a")
21+
output_file.write(clean_shell)
22+
output_file.close()
23+
print("output written to: "+str(file_name))
24+
25+
if args.file is not None:
26+
bmr_file = args.file
27+
beanshell_dirty = open(bmr_file)
28+
bmr_string = beanshell_dirty.read().replace('\"','"')
29+
beanshell_dirty.close()
30+
from_string(str(bmr_string))
31+
elif args.string is not None:
32+
bmr_string = args.string
33+
from_string(bmr_string)

0 commit comments

Comments
 (0)