def exports_to_file(options): ws = utils.get_workspace(options=options) ts = str(utils.gen_ts()) output = options.get('OUTPUT', '') url = options.get('REMOTE_API') + "/api/exports/csv/" headers = send.osmedeus_headers headers['Authorization'] = options.get('JWT') body = { "workspace": ws, 'filename': options.get('WORKSPACE') + f'/{output}_{ts}', } r = send.send_post(url, body, headers=headers, is_json=True) if r and r.json().get('message'): return r.json().get('message') return False
def parsing_config(args): # create default osmedeus client path osmedeus_home = str(Path.home().joinpath('.osmedeus')) utils.make_directory(osmedeus_home) # parsing remote server here remote = args.remote if args.remote else None credentials = args.auth if args.auth else None # reading old config file or create new one if args.config_path: config_path = args.config_path else: config_path = str(Path.home().joinpath('.osmedeus/client.conf')) remote, credentials = _config_file_handle(config_path, remote, credentials) # remote, credentials = _handle_remote(remote, credentials, configs) # folder name to store all the results workspace = args.workspace if args.workspace else None # Target stuff target = args.target if args.target else None target_list = args.targetlist if args.targetlist else False target = _verify_target(target, target_list) # get direct input as single or a file direct_input = args.input if args.input else None direct_input_list = args.inputlist if args.inputlist else None direct_input = _verify_target(direct_input, direct_input_list) # parsing speed config if args.slow and args.slow.lower() == 'all': speed = "quick|-;;slow|*" # all slow elif args.slow: # quick all but some slow speed = "quick|*;;slow|{0}".format(args.slow.strip()) else: speed = "quick|*;;slow|-" # all quick # parsing modules modules = args.modules if args.modules else None report = args.report if args.report else None # turn on default try: slack = False if args.noslack else True monitor = False if args.nomonitor else True localhost = args.localhost if args.localhost else False # catch config different from private version except: slack = True if args.slack else False monitor = False localhost = True if modules: if direct_input_list: mode = 'direct_list' else: mode = 'direct' elif report: mode = 'report' else: mode = 'general' # modules = _handle_speed(raw_modules, speed, mode) debug = str(args.debug) forced = str(args.forced) # select one if mode == 'general': real_target = utils.set_value(direct_input, target) else: real_target = utils.set_value(target, direct_input) options = { 'start_ts': utils.gen_ts(), 'raw_target': real_target, 'target_list': target_list, 'mode': mode, 'slack': slack, 'speed': speed, 'workspace': workspace, 'modules': modules, 'forced': forced, 'debug': debug, 'remote_api': remote.strip('/'), 'credentials': credentials, 'localhost': localhost, 'report': report, 'monitor': monitor, } # clean None options before send submit request options = _clean_None(options) return options