コード例 #1
0
        public CoverletConsoleUtil(
            IProcessUtil processUtil,
            ILogger logger,
            [Import(typeof(ICoverletConsoleDotnetToolsGlobalExecutor))]
            ICoverletConsoleExecutor globalExecutor,
            [Import(typeof(ICoverletConsoleCustomPathExecutor))]
            ICoverletConsoleExecutor customPathExecutor,
            [Import(typeof(ICoverletConsoleDotnetToolsLocalExecutor))]
            ICoverletConsoleExecutor localExecutor,
            IFCCCoverletConsoleExecutor fccExecutor
            )
        {
            this.processUtil = processUtil;
            this.logger      = logger;

            executors = new List <ICoverletConsoleExecutor>
            {
                localExecutor,
                customPathExecutor,
                globalExecutor,
                fccExecutor
            };

            this.fccExecutor = fccExecutor;
        }
コード例 #2
0
 public FCCEngine(
     ICoverletUtil coverletUtil,
     IOpenCoverUtil openCoverUtil,
     ICoberturaUtil coberturaUtil,
     IMsTestPlatformUtil msTestPlatformUtil,
     IReportGeneratorUtil reportGeneratorUtil,
     IProcessUtil processUtil,
     IAppOptionsProvider appOptionsProvider,
     ILogger logger,
     IAppDataFolder appDataFolder,
     [Import(typeof(SVsServiceProvider))]
     IServiceProvider serviceProvider
     )
 {
     this.coverletUtil        = coverletUtil;
     this.openCoverUtil       = openCoverUtil;
     this.coberturaUtil       = coberturaUtil;
     this.msTestPlatformUtil  = msTestPlatformUtil;
     this.reportGeneratorUtil = reportGeneratorUtil;
     this.processUtil         = processUtil;
     this.appOptionsProvider  = appOptionsProvider;
     this.logger          = logger;
     this.appDataFolder   = appDataFolder;
     this.serviceProvider = serviceProvider;
     colorThemeService    = serviceProvider.GetService(typeof(SVsColorThemeService));
 }
コード例 #3
0
        /// <summary>
        /// Constructor for AuditEvent
        /// The constructor runs the rule prerequisites
        /// </summary>
        protected AuditEventGeneratorBase(IProcessUtil processUtil)
        {
            _processUtil = processUtil;

            foreach (string rule in AuditRulesPrerequisites)
            {
                string command = $"sudo auditctl {rule}";

                try
                {
                    _processUtil.ExecuteBashShellCommand(command);
                }
                catch (CommandExecutionFailedException ex)
                {
                    if (ex.Error == AuditctlRuleAlreadyDefinedText)
                    {
                        SimpleLogger.Debug("rule already defined: " + command);
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            //establish checkpoint
            ExecuteAusearchWithFallback();
        }
コード例 #4
0
        /// <inheritdoc />
        public FirewallConfigurationSnapshotGenerator(IProcessUtil processUtil)
        {
            _processUtil = processUtil;
            string content = _processUtil.ExecuteBashShellCommand(IpTablesExistCommand);

            _isIptablesExist = !(string.IsNullOrEmpty(content));
        }
コード例 #5
0
        /// <summary>
        /// Execute powershell commands
        /// </summary>
        /// <param name="processUtil">process utility instnace</param>
        /// <param name="cmd">Command to execute</param>
        /// <param name="errorHandler">Error handler to be called in case of an error while executing the command</param>
        /// <param name="acceptableExitCodes">Exit codes that considerd as OK</param>
        /// <returns>Command output</returns>
        public static string ExecutePowershellCommand(this IProcessUtil processUtil, string cmd, ErrorHandler errorHandler = null, IEnumerable <int> acceptableExitCodes = null)
        {
            CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;

            string args = $"-Command \"[System.Threading.Thread]::CurrentThread.CurrentCulture = [cultureinfo]::GetCultureInfo('{currentCulture}');{cmd}\"";

            return(processUtil.ExecuteProcess(@"PowerShell", args, errorHandler, acceptableExitCodes));
        }
コード例 #6
0
        /// <inheritdoc />
        public ProcessCreationEventGenerator(IProcessUtil processUtil) : base(processUtil)
        {
            executableHash = new Dictionary <string, string>();
            string searchResultsString             = processUtil.ExecuteBashShellCommand(searchIntegrityRuleCommand);
            IEnumerable <string>     searchResults = searchResultsString.Split("----", StringSplitOptions.RemoveEmptyEntries);
            IEnumerable <AuditEvent> auditEvents   = searchResults.Select(AuditEvent.ParseFromAusearchLine);

            foreach (AuditEvent auditEvent in auditEvents)
            {
                updateExecutablesDictonary(auditEvent);
            }
        }
コード例 #7
0
 public OpenCoverUtil(
     IMsTestPlatformUtil msTestPlatformUtil,
     IProcessUtil processUtil,
     ILogger logger,
     IToolFolder toolFolder,
     IToolZipProvider toolZipProvider)
 {
     this.msTestPlatformUtil = msTestPlatformUtil;
     this.processUtil        = processUtil;
     this.logger             = logger;
     this.toolFolder         = toolFolder;
     this.toolZipProvider    = toolZipProvider;
 }
コード例 #8
0
 public ReportGeneratorUtil(
     IAssemblyUtil assemblyUtil,
     IProcessUtil processUtil,
     ILogger logger,
     IToolFolder toolFolder,
     IToolZipProvider toolZipProvider
     )
 {
     this.assemblyUtil    = assemblyUtil;
     this.processUtil     = processUtil;
     this.logger          = logger;
     this.toolFolder      = toolFolder;
     this.toolZipProvider = toolZipProvider;
 }
        /// <inheritdoc />
        public ETWEventGeneratorBase(IProcessUtil processUtil, IWmiUtils wmiUtils)
        {
            _wmiUtils = wmiUtils;

            foreach (ETWEventType etwEvent in ETWEvents)
            {
                _lastRetrievedEventTimeStamps[etwEvent] = ManagementDateTimeConverter.ToDmtfDateTime(DateTime.Now);
            }

            foreach (string command in PrerequisiteCommands)
            {
                processUtil.ExecuteWindowsCommand(command);
            }
        }
コード例 #10
0
 public CoverletDataCollectorUtil(
     IFileUtil fileUtil,
     IRunSettingsCoverletConfigurationFactory runSettingsCoverletConfigurationFactory,
     ILogger logger,
     IProcessUtil processUtil,
     IDataCollectorSettingsBuilderFactory dataCollectorSettingsBuilderFactory,
     ICoverletDataCollectorGeneratedCobertura coverletDataCollectorGeneratedCobertura,
     IProcessResponseProcessor processResponseProcessor,
     IToolZipProvider toolZipProvider,
     IToolFolder toolFolder
     )
 {
     this.fileUtil = fileUtil;
     this.runSettingsCoverletConfigurationFactory = runSettingsCoverletConfigurationFactory;
     this.logger      = logger;
     this.processUtil = processUtil;
     this.dataCollectorSettingsBuilderFactory     = dataCollectorSettingsBuilderFactory;
     this.coverletDataCollectorGeneratedCobertura = coverletDataCollectorGeneratedCobertura;
     this.processResponseProcessor = processResponseProcessor;
     this.toolZipProvider          = toolZipProvider;
     this.toolFolder = toolFolder;
 }
 /// <summary>
 /// Ctor - creates a new event generator
 /// </summary>
 public LocalUsersSnapshotGenerator(IProcessUtil processUtil)
 {
     _processUtil = processUtil;
 }
コード例 #12
0
 /// <summary>
 /// Ctor - creates a new event generator
 /// </summary>
 public LoginEventGenerator(IWmiUtils wmiUtils, IProcessUtil processUtil) : base(processUtil, wmiUtils)
 {
 }
コード例 #13
0
 /// <summary>
 /// Ctor - creates a new event generator
 /// </summary>
 public ProcessTerminateEventGenerator(IProcessUtil processUtil, IWmiUtils wmiUtils) : base(processUtil, wmiUtils)
 {
 }
 /// <summary>
 /// Ctor - creates a new event generator
 /// </summary>
 public BaselineEventGenerator(IProcessUtil processUtil)
 {
     _processUtil = processUtil;
 }
コード例 #15
0
 /// <inheritdoc />
 public OutboundConnEventGenerator(IProcessUtil processUtil) : base(processUtil)
 {
 }
コード例 #16
0
        /// <summary>
        /// Execute shell (bin/bash) commands
        /// </summary>
        /// <param name="processUtil">process utility instnace</param>
        /// <param name="cmd">Command to execute</param>
        /// <param name="errorHandler">Error handler to be called in case of an error while executing the command</param>
        /// <param name="acceptableExitCodes">Exit codes that considerd as OK</param>
        /// <returns>Command output</returns>
        public static string ExecuteWindowsCommand(this IProcessUtil processUtil, string cmd, ErrorHandler errorHandler = null, IEnumerable <int> acceptableExitCodes = null)
        {
            string args = $"/C \"{cmd}\"";

            return(processUtil.ExecuteProcess(@"C:\Windows\System32\cmd.exe", args, errorHandler, acceptableExitCodes));
        }
コード例 #17
0
 /// <inheritdoc />
 public UserLoginEventGenerator(IProcessUtil processUtil) : base(processUtil)
 {
 }
 /// <summary>
 /// Ctor - creates a new event generator
 /// </summary>
 public ConnectionEventGenerator(IProcessUtil processUtil, IWmiUtils wmiUtils) : base(processUtil, wmiUtils)
 {
 }
コード例 #19
0
 /// <inheritdoc />
 protected ConnectionsEventGeneratorBase(IProcessUtil processUtil) : base(processUtil)
 {
 }
コード例 #20
0
 /// <summary>
 /// Ctor - creates a new event generator
 /// </summary>
 public ListeningPortsEventGenerator(IProcessUtil processUtil)
 {
     _processUtil = processUtil;
 }
 /// <summary>
 /// Ctor - creates a new event generator
 /// </summary>
 public LocalusersEventGenerator(IWmiUtils wmiUtils, IProcessUtil processUtil)
 {
     _wmiUtils    = wmiUtils;
     _processUtil = processUtil;
 }
コード例 #22
0
        /// <summary>
        /// Execute shell (bin/bash) commands
        /// </summary>
        /// <param name="processUtil">process utility instnace</param>
        /// <param name="cmd">Command to execute</param>
        /// <param name="errorHandler">Error handler to be called in case of an error while executing the command</param>
        /// <param name="acceptableExitCodes">Exit codes that considerd as OK</param>
        /// <returns>Command output</returns>
        public static string ExecuteBashShellCommand(this IProcessUtil processUtil, string cmd, ErrorHandler errorHandler = null, IEnumerable <int> acceptableExitCodes = null)
        {
            string args = $"-c \"{cmd}\"";

            return(processUtil.ExecuteProcess("/bin/bash", args, errorHandler, acceptableExitCodes));
        }
コード例 #23
0
 /// <summary>
 /// Ctor - creates a new event generator
 /// </summary>
 public NetstatEventGenerator(IProcessUtil processUtil)
 {
     _processUtil = processUtil;
 }
コード例 #24
0
 /// <inheritdoc />
 public override AuditEventGeneratorBase CreateInstance(IProcessUtil processUtil)
 {
     return(new ProcessCreationEventGenerator(processUtil));
 }
コード例 #25
0
 /// <summary>
 /// Delegate for creating a new instance of derived type.
 /// derived type must be initialized with the given process util
 /// </summary>
 /// <param name="processUtil"></param>
 /// <returns></returns>
 public abstract AuditEventGeneratorBase CreateInstance(IProcessUtil processUtil);
コード例 #26
0
 private WmiUtils(IProcessUtil processUtils)
 {
     _processUtils = processUtils;
 }
コード例 #27
0
 /// <inheritdoc />
 public ProcessCreationEventGenerator(IProcessUtil processUtil) : base(processUtil)
 {
 }
 /// <inheritdoc />
 public override AuditEventGeneratorBase CreateInstance(IProcessUtil processUtil)
 {
     SetupAusearchReturnValue(ProcessEvent);
     return(new ProcessCreationEventGenerator(processUtil));
 }