public string post_rest_Uri(string op) { settingClass settings = get_settings(); string path = settings.CxUrl + op; return(path); }
public secure() { _configuration = Configuration.configuration(); _cipherService = new CipherService(); _os = RuntimeInformation.OSDescription; _settings = get_settings(); }
public static settingClass get_settings() { settingClass _settings = new settingClass(); _configuration.GetSection("CxRest").Bind(_settings); return(_settings); }
public CxSoapSDK(resultClass token) { using (secure secure = new secure()) { _settings = secure.get_settings(); } _token = token; _debug = token.debug; }
public secure(resultClass token) { _configuration = Configuration.configuration(); _cipherService = new CipherService(); _os = RuntimeInformation.OSDescription; _token = token; _settings = get_settings(); _debug = token.debug; }
public secure(resultClass token) { _configuration = Configuration.configuration(); _cipherService = new CipherService(); _os = RuntimeInformation.OSDescription; _token = token; _settings = get_settings(); _debug = token.debug; if (_debug) { Console.WriteLine("exe path: {0}", System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)); } }
public settingClass get_settings() { settingClass _settings = new settingClass(); _configuration.GetSection("CxRest").Bind(_settings); _settings.CxAPIResolver = _settings.CxUrl + _settings.CxAPIResolver; _settings.CxSDKWebService = _settings.CxUrl + _settings.CxSDKWebService; if (_token != null && _token.debug) { _settings.debug = "true"; } return(_settings); }
public void _setresultClass() { secure secure = new secure(); settingClass settings = secure.get_settings(); grant_type = settings.grant_type; scope = settings.scope; client_id = settings.client_id; client_secret = settings.client_secret; CxUrl = settings.CxUrl; timestamp = DateTime.UtcNow; os_path = secure._os.Contains("Windows") ? "\\" : "/"; CxAPIResolver = CxUrl + settings.CxAPIResolver; CxSDKWebService = CxUrl + settings.CxSDKWebService; use_proxy = settings.use_proxy; proxy_use_default = settings.proxy_use_default; proxy_url = settings.proxy_url; }
public resultClass() { secure secure = new secure(); settingClass settings = secure.get_settings(); grant_type = settings.grant_type; scope = settings.scope; client_id = settings.client_id; client_secret = settings.client_secret; CxUrl = settings.CxUrl; file_name = settings.CxDefaultFileName; file_path = settings.CxFilePath; timestamp = DateTime.UtcNow; start_time = null; end_time = null; api_action = api_action.help; os_path = secure._os.Contains("Windows") ? "\\" : "/"; debug = false; CxAPIResolver = CxUrl + settings.CxAPIResolver; CxSDKWebService = CxUrl + settings.CxSDKWebService; }
public settingClass get_settings() { settingClass _settings = new settingClass(); _configuration.GetSection("CxRest").Bind(_settings); _settings.CxAPIResolver = _settings.CxUrl + _settings.CxAPIResolver; _settings.CxSDKWebService = _settings.CxUrl + _settings.CxSDKWebService; if (_token != null && _token.debug) { _settings.debug = "true"; } if (_debug) { foreach (PropertyInfo propertyInfo in _settings.GetType().GetProperties()) { Console.WriteLine("{0}:{1}", propertyInfo.Name, propertyInfo.GetValue(_settings, null)); } } return(_settings); }
public bool set_encrypted_file(encryptClass encrypt) { string folder = _os.Contains("Windows") ? "\\" : "/"; try { settingClass settings = get_settings(); string Json_string = Newtonsoft.Json.JsonConvert.SerializeObject(encrypt); string encrypted = _cipherService.Encrypt(Json_string); if (_debug) { Console.WriteLine("Setting file: {0} : {1}", settings.CxDataFilePath, settings.CxDataFileName); } string path = Path.Combine(settings.CxDataFilePath, settings.CxDataFileName); File.WriteAllText(path, encrypted); return(true); } catch (Exception ex) { Console.Error.Write(ex.ToString()); return(false); } }
public static void debug_configuration(settingClass _settings, resultClass _token) { string _os = RuntimeInformation.OSDescription; string folder = _os.Contains("Windows") ? "\\" : "/"; Console.WriteLine("-----------------------------------------------------------------------"); Console.WriteLine("Setting file: {0}", _settings.CxDataFilePath + folder + _settings.CxDataFileName); Console.WriteLine("Executable Path: {0}", System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)); Console.WriteLine("Configuration Settings:"); foreach (PropertyInfo propertyInfo in _settings.GetType().GetProperties()) { Console.WriteLine("{0}:{1}", propertyInfo.Name, propertyInfo.GetValue(_settings, null)); } Console.WriteLine("-----------------------------------------------------------------------"); Console.WriteLine("Command Line Settings:"); foreach (PropertyInfo propertyInfo in _token.GetType().GetProperties()) { Console.WriteLine("{0}:{1}", propertyInfo.Name, propertyInfo.GetValue(_token, null)); } Console.WriteLine("-----------------------------------------------------------------------"); Console.WriteLine(""); }
public static resultClass mono_command_args(string[] args) { resultClass token = new resultClass(); List <string> extra; var p = new OptionSet() { { "a|appsettings=", "Optional, point to alternate appsettings directory", v => token.appsettings = v }, { "t|get_token", "Fetch the bearer token from the CxSAST service", v => token.api_action = api_action.getToken }, { "c|store_credentials", "Store username and credential in an encrypted file", v => token.api_action = api_action.storeCredentials }, { "s|scan_results", "Get scan results, filtered by time and project", v => token.api_action = api_action.scanResults }, { "rn|report_name=", "Select desired report", v => token.report_name = v }, { "pn|project_name=", "Filter with project name, Will return project if any portion of the project name is a match", v => token.project_name = v }, { "tn|team_name=", "Filter with team name, Will return a team if any portion of the team name is a match", v => token.team_name = v }, { "ps|preset_name=", "Filter with preset name, Will return a preset if any portion of the team name is a match", v => token.preset = v }, { "pi|pipe", "Do not write to file but pipe output to stdout. Useful when using other API's", v => token.pipe = true }, { "path|file_path=", "Override file path in configuration", v => token.file_path = v }, { "file|file_name=", "Override file name in configuration", v => token.file_name = v }, { "sf|severity_filter=", "Filter results by Severity", v => token.severity_filter = v }, { "sr|save_result=", "Enable saving of results as XML", v => token.save_result = v }, { "srp|save_result_path=", "Override save result path in configuration", v => token.save_result_path = v }, { "u|user_name=", "The username to use to retreive the token (REST) or session (SOAP)", v => token.user_name = v }, { "p|password="******"The password needed to retreive the token (REST) or session (SOAP)", v => token.credential = v }, { "st|start_time=", "Last scan start time", v => token.start_time = DateTime.Parse(v) }, { "et|end_time=", "Last scan end time", v => token.end_time = DateTime.Parse(v) }, //add proxy stuff { "up|use_proxy", "Use web proxy", v => token.use_proxy = true }, { "ud|proxy_use_default", "Use default credentials", v => token.proxy_use_default = true }, { "pu|proxy_user_name=", "Proxy User Name", v => token.proxy_username = v }, { "pp|proxy_password="******"Proxy Password", v => token.proxy_password = v }, { "pd|proxy_domain=", "Proxy Domain", v => token.proxy_domain = v }, //proxy { "v|verbose=", "Change degrees of debugging info", v => token.verbosity = Convert.ToInt32(v) }, { "mt|max_threads=", "Change the max number of report requests to CxManager", v => token.max_threads = Convert.ToInt32(v) }, { "ms|max_scans=", "Change the max number of report requests to CxManager", v => token.max_scans = Convert.ToInt32(v) }, { "ff|filename_filter=", "Firter results so only filename matches are reported", v => token.filename_filter = v }, { "d|debug", "Output debugging info ", v => token.debug = true }, { "T|test", "Wait at end of program ", v => token.test = true }, { "?|h|help", "show your options", v => token.api_action = api_action.help }, }; try { extra = p.Parse(args); Configuration.configuration(args, token.appsettings); token._setresultClass(); settingClass _settings = get_settings(); if (_settings.use_proxy || token.use_proxy) { token.use_proxy = true; token.proxy_use_default = token.proxy_use_default ? true : _settings.proxy_use_default; token.proxy_url = String.IsNullOrEmpty(token.proxy_url) ? _settings.proxy_url : token.proxy_url; Console.WriteLine("Using proxy {0}", token.proxy_url); } token.save_result_filename = String.IsNullOrEmpty(token.save_result_filename) ? _settings.CxResultFileName : token.save_result_filename; token.save_result_path = String.IsNullOrEmpty(token.save_result_path) ? _settings.CxResultFilePath : token.save_result_path; _settings.CxFilePath = string.IsNullOrEmpty(_settings.CxDefaultFilePath) ? _settings.CxFilePath : _settings.CxDefaultFilePath; token.file_name = String.IsNullOrEmpty(token.file_name) ? _settings.CxDefaultFileName : token.file_name; token.file_path = String.IsNullOrEmpty(token.file_path) ? _settings.CxFilePath : token.file_path; token.end_time = (token.end_time == null) ? DateTime.Today : token.end_time; token.start_time = (token.start_time == null) ? DateTime.Today.AddMonths(-1) : token.start_time; if (token.debug && token.verbosity > 0) { debug_configuration(_settings, token); } } // if (String.IsNullOrEmpty(token.file_name) ? _configuration catch (OptionException e) { Console.Write("CxApi_Core: "); Console.WriteLine(e.Message); Console.WriteLine("Try CxApi --help' for more information."); token.status = -1; } if (token.api_action == api_action.help) { ShowHelp(p); } return(token); }