35 lines
1.0 KiB
Python
Executable File
35 lines
1.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import os
|
|
import sys
|
|
import json
|
|
import requests
|
|
import configparser
|
|
|
|
###############################################
|
|
# Look for oss.cnf file in current working directory
|
|
CONFIG_FILE = "./oss.cnf"
|
|
if not os.path.isfile(CONFIG_FILE):
|
|
logging.error(f"The config file {CONFIG_FILE} doesn't exist")
|
|
sys.exit(1)
|
|
config = configparser.RawConfigParser()
|
|
config.read(CONFIG_FILE)
|
|
NTSKP_TENANT = config.get('netskope', 'NTSKP_TENANT')
|
|
NTSKP_TOKEN = config.get('netskope', 'NTSKP_TOKEN')
|
|
NTSKP_PERIOD = config.get('netskope', 'NTSKP_PERIOD')
|
|
|
|
###############################################
|
|
|
|
ssl_session = requests.Session()
|
|
uri = f"{NTSKP_TENANT}/api/v1/report?token={NTSKP_TOKEN}&timeperiod={NTSKP_PERIOD}&type=connection&groupby=application&query=app-cci-app-tag+eq+'Pending_GRC_Review'"
|
|
try:
|
|
r = ssl_session.get(uri)
|
|
r.raise_for_status()
|
|
except Exception as e:
|
|
logging.error(f'Error: {str(e)}')
|
|
sys.exit(1)
|
|
json = r.json()
|
|
if 'data' in json:
|
|
for item in json['data']:
|
|
print(f"{item['app']}", end=', ')
|
|
print()
|