Skip to content

Commit 3797fc5

Browse files
committed
Sailpoint
Sailpoint IAM script to convert a bean shell into a proper JSON array consumable by Sailpoint API.
1 parent 6b1aa51 commit 3797fc5

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

.DS_Store

0 Bytes
Binary file not shown.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env python3
2+
__author__ = "Munir Njiru"
3+
__email__ = "munir@alien-within.com"
4+
__status__ = "Production"
5+
'''
6+
This script takes a regular bean shell script and
7+
parses it into a json compatible one liner from a
8+
python dictionary and escapes it to JSON in one liner
9+
format for passing to the API
10+
'''
11+
import argparse
12+
import random
13+
import string
14+
import json
15+
global json_bean, output_file, bmr_string, bmr_file, the_script
16+
parser = argparse.ArgumentParser()
17+
parser.add_argument('-f', '--file', help='Load a text file with the beanshell code')
18+
args = parser.parse_args()
19+
def to_sailpoint_json_bmr(bmr_string):
20+
21+
file_name= ''.join(random.choice(string.ascii_letters) for i in range(10))+".json"
22+
output_file = open(str(file_name), "a")
23+
the_script={
24+
"version": "1.0",
25+
"script": bmr_string
26+
}
27+
json.dump(the_script,output_file)
28+
output_file.close()
29+
print("output written to: "+str(file_name))
30+
31+
if args.file is not None:
32+
bmr_file = args.file
33+
beanshell_clean = open(bmr_file)
34+
bmr_string = beanshell_clean.read()
35+
beanshell_clean.close()
36+
to_sailpoint_json_bmr(bmr_string)

0 commit comments

Comments
 (0)