static void Main(string[] args) { IConfiguration Configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) #if DEBUG .AddJsonFile($"appsettings.Development.json", false) #else .AddJsonFile("appsettings.json", false) #endif .Build(); var serviceCollection = new ServiceCollection(); var connection = Configuration.GetConnectionString("DefaultConnection"); serviceCollection.AddDbContext <ApplicationDbContext> (options => options.UseSqlServer(connection)); serviceCollection.AddTransient(options => Options.Create( VeracodeFileHelper.GetConfiguration(Configuration.GetValue <string>("VeracodeFileLocation")))); serviceCollection.Configure <EventGridConfiguration>(options => Configuration.GetSection("ServiceBusConfiguration").Bind(options)); serviceCollection.AddScoped <IVeracodeRepository, VeracodeRepository>(); serviceCollection.AddScoped <IMessageService, MessageService>(); serviceCollection.AddScoped <IGenericRepository <App>, GenericRepository <App> >(); serviceCollection.AddScoped <IGenericRepository <Build>, GenericRepository <Build> >(); serviceCollection.AddScoped <IGenericRepository <Flaw>, GenericRepository <Flaw> >(); serviceCollection.AddScoped <IMappingService, MappingService>(); serviceCollection.AddAutoMapper(typeof(Program)); _appIds = Configuration.GetValue <string[]>("Apps"); _serviceProvider = serviceCollection.BuildServiceProvider(); Parser.Default.ParseArguments <RunOptions>(args) .MapResult(( RunOptions options) => Run(options), errs => HandleParseError(errs)); }
static void Main(string[] args) { IConfiguration Configuration = new ConfigurationBuilder() .SetBasePath(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)) #if DEBUG .AddJsonFile($"appsettings.Development.json", false) #else .AddJsonFile("appsettings.json", false) #endif .Build(); var serviceCollection = new ServiceCollection(); var profileName = Configuration.GetValue <string>("VeracodeProfileName"); var veracodeCredFilePath = Configuration.GetValue <string>("VeracodeFileLocation"); var useEnvironmentVariables = Configuration.GetValue <bool>("UseEnvironmentVariables"); if (useEnvironmentVariables || String.IsNullOrWhiteSpace(veracodeCredFilePath)) { serviceCollection.AddTransient(options => Microsoft.Extensions.Options.Options.Create( VeracodeEnvHelper.GetConfiguration())); } else { serviceCollection.AddTransient(options => Microsoft.Extensions.Options.Options.Create( VeracodeFileHelper.GetConfiguration(veracodeCredFilePath, profileName))); } serviceCollection.AddScoped <IVeracodeRepository, VeracodeRepository>(); serviceCollection.AddScoped <IVeracodeService, VeracodeService>(); serviceCollection.AddScoped <IDscLogic, DscLogic>(); serviceCollection.AddLogging(loggingBuilder => { loggingBuilder.AddNLog("nlog.config"); }); _serviceProvider = serviceCollection.BuildServiceProvider(); _logger = _serviceProvider.GetService <ILogger <Program> >(); _dscLogic = _serviceProvider.GetService <IDscLogic>(); Parser.Default.ParseArguments < TestOptions, ScanOptions, ConfigureOptions, EvaluateOptions, MitigationOptions, DeleteOptions>(args) .MapResult( (TestOptions options) => Test(options), (ScanOptions options) => Scan(options), (ConfigureOptions options) => Configure(options), (EvaluateOptions options) => Evaluate(options), (MitigationOptions options) => MitigationTemplates(options), (DeleteOptions options) => Delete(options), errs => HandleParseError(errs)); }
public void Setup() { IConfiguration Configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) #if DEBUG .AddJsonFile($"appsettings.Development.json", false) #else .AddJsonFile("appsettings.json", false) #endif .Build(); var profileName = Configuration.GetValue <string>("VeracodeProfileName"); var options = Options.Create( VeracodeFileHelper.GetConfiguration( Configuration.GetValue <string>("VeracodeFileLocation"), profileName)); _veracodeRepository = new VeracodeRepository(options); _veracodeService = new VeracodeService(new Mock <ILogger <VeracodeService> >().Object, _veracodeRepository); _dscLogic = new DscLogic(new Mock <ILogger <DscLogic> >().Object, _veracodeService, _veracodeRepository); }
static void Main(string[] args) { IConfiguration Configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) #if DEBUG .AddJsonFile($"appsettings.Development.json", false) #else .AddJsonFile("appsettings.json", false) #endif .Build(); var jam = Configuration.GetSection("FlawFilterConfiguration"); var serviceCollection = new ServiceCollection(); serviceCollection.Configure <EndpointConfiguration>(options => Configuration.GetSection("Endpoint").Bind(options)); serviceCollection.Configure <FlawFilterConfiguration>(options => Configuration.GetSection("FlawFilterConfiguration").Bind(options)); serviceCollection.AddTransient(options => Options.Create( VeracodeFileHelper.GetConfiguration( Configuration.GetValue <string>("VeracodeFileLocation")))); serviceCollection.Configure <ExcelConfiguration>(options => Configuration.GetSection("ExcelConfiguration").Bind(options)); serviceCollection.AddScoped <IVeracodeRepository, VeracodeRepository>(); serviceCollection.AddTransient <IGenericReadOnlyRepository <AutoResponse>, GenericReadOnlyRepository <AutoResponse> >(); serviceCollection.AddTransient <IGenericReadOnlyRepository <Template>, GenericReadOnlyRepository <Template> >(); serviceCollection.AddTransient <IGenericReadOnlyRepository <CategoryRename>, GenericReadOnlyRepository <CategoryRename> >(); serviceCollection.AddScoped <ITemplateWriter, TemplateWriter>(); serviceCollection.AddScoped <IOutputWriter, ExcelWriter>(); serviceCollection.AddScoped <IResponseMapper, ResponseMapper>(); serviceCollection.AddScoped <IZippingService, ZippingService>(); serviceCollection.AddScoped <IReportGenerator, ReportGenerator>(); _serviceProvider = serviceCollection.BuildServiceProvider(); Parser.Default.ParseArguments <RunOptions>(args) .MapResult(( RunOptions options) => Run(options), errs => HandleParseError(errs)); }