Example #1
0
        public static void CrawlAuditTrails(IOutputFactory outFactory, CancellationToken token)
        {
            var crawlInvoker = new AuditTrailCrawler(outFactory);

            IAuditTrailCrawler crawler = new DBCrawler();

            if (crawler.IsDisabled)
            {
                return;
            }

            var supressions = CxAnalytix.Configuration.Config.GetConfig <CxAuditTrailSupressions>(CxAuditTrailSupressions.SECTION_NAME);

            foreach (var field in typeof(CxAuditTrailTableNameConsts).GetFields())
            {
                if (token.IsCancellationRequested)
                {
                    break;
                }

                if (GetPropertyValue <CxAuditTrailSupressions, bool>(field.Name, supressions))
                {
                    _log.Debug($"{field.Name} logging has been suppressed via configuration.");
                    continue;
                }

                crawlInvoker.InvokeCrawlMethod(field.Name, crawler, token);
            }
        }
Example #2
0
 public NotesController(UserManager <User> userManager, IOutputFactory outputFactory, INotesManager notesMng, NotesViewModelValidator notesValidator)
 {
     _userManager    = userManager;
     _outputFactory  = outputFactory;
     _notesMng       = notesMng;
     _notesValidator = notesValidator;
 }
Example #3
0
        /// <summary>
        /// The main logic for invoking a transformation.  It does not return until a sweep
        /// for new scans is performed across all projects.
        /// </summary>
        /// <param name="concurrentThreads">The number of concurrent scan transformation threads.</param>
        /// <param name="previousStatePath">A folder path where files will be created to store any state
        /// data required to resume operations across program runs.</param>
        /// <param name="ctx"></param>
        /// <param name="outFactory">The factory implementation for making IOutput instances
        /// used for outputting various record types.</param>
        /// <param name="records">The names of the supported record types that will be used by
        /// the IOutputFactory to create the correct output implementation instance.</param>
        /// <param name="token">A cancellation token that can be used to stop processing of data if
        /// the task needs to be interrupted.</param>
        public static void DoTransform(int concurrentThreads, String previousStatePath, String instanceId,
                                       CxRestContext ctx, IOutputFactory outFactory, RecordNames records, CancellationToken token)
        {
            try
            {
                Transformer xform = new Transformer(ctx, token, previousStatePath)
                {
                    ThreadOpts = new ParallelOptions()
                    {
                        CancellationToken      = token,
                        MaxDegreeOfParallelism = concurrentThreads
                    },
                    ProjectInfoOut           = outFactory.newInstance(records.ProjectInfo),
                    SastScanSummaryOut       = outFactory.newInstance(records.SASTScanSummary),
                    SastScanDetailOut        = outFactory.newInstance(records.SASTScanDetail),
                    PolicyViolationDetailOut = outFactory.newInstance(records.PolicyViolations),
                    ScaScanSummaryOut        = outFactory.newInstance(records.SCAScanSummary),
                    ScaScanDetailOut         = outFactory.newInstance(records.SCAScanDetail),
                    InstanceId = instanceId
                };

                xform.ExecuteSweep();
            }
            catch (Exception ex)
            {
                _log.Error("Unhandled exception caught.", ex);
            }
        }
Example #4
0
 public WorkerController(IPluginManager pluginManager, IOutputFactory outputFactory, IHttpDownloader downloader, ILogger logger)
 {
     this.logger = logger;
     logger.Info("> Worker()");
     this.pluginManager = pluginManager;
     this.outputFactory = outputFactory;
     this.downloader    = downloader;
 }
Example #5
0
 public Application(
     ITextTransformer textTransformer,
     IInputFactory inputFactory,
     IOutputFactory outputFactory)
 {
     this.textTransformer = textTransformer ?? throw new ArgumentNullException(nameof(textTransformer));
     this.inputFactory    = inputFactory ?? throw new ArgumentNullException(nameof(inputFactory));
     this.outputFactory   = outputFactory ?? throw new ArgumentNullException(nameof(outputFactory));
 }
Example #6
0
 public UserController(SignInManager <User> signInManager, UserManager <User> usersManager,
                       IOutputFactory outputFactory, IUserService usersService, UserViewModelValidator userValid)
 {
     _signInManager = signInManager;
     _usersManager  = usersManager;
     _outputFactory = outputFactory;
     _usersService  = usersService;
     _userValid     = userValid;
 }
Example #7
0
 public WorkerController(ServiceManager sm, ILogger logger, IOutputFactory outputFactory, IDownloader downloader)
 {
     this.logger = logger;
     logger.Info("> Worker()");
     serviceManager     = sm;
     this.outputFactory = outputFactory;
     this.downloader    = downloader;
     cancelSource       = new CancellationTokenSource();
     semaphore          = new SemaphoreSlim(2);
 }
Example #8
0
 static Daemon()
 {
     try
     {
         Assembly outAssembly = Assembly.Load(Config.Service.OutputAssembly);
         _log.DebugFormat("outAssembly loaded: {0}", outAssembly.FullName);
         _outFactory = outAssembly.CreateInstance(Config.Service.OutputClass) as IOutputFactory;
         _log.Debug("IOutputFactory instance created.");
     }
     catch (Exception ex)
     {
         _log.Error($"Error loading output factory [{Config.Service.OutputAssembly}].", ex);
     }
 }
Example #9
0
        private static IOutputFactory MakeFactory()
        {
            IOutputFactory retVal = null;

            try
            {
                Assembly outAssembly = Assembly.Load(Config.Service.OutputAssembly);
                appLog.DebugFormat("outAssembly loaded: {0}", outAssembly.FullName);
                retVal = outAssembly.CreateInstance(Config.Service.OutputClass) as IOutputFactory;
                appLog.Debug("IOutputFactory instance created.");
            }
            catch (Exception ex)
            {
                appLog.Error("Error loading output factory.", ex);
            }

            return(retVal);
        }
Example #10
0
        static Output()
        {
            try
            {
                Assembly outAssembly = Assembly.Load(Config.Service.OutputAssembly);
                _log.DebugFormat("outAssembly loaded: {0}", outAssembly.FullName);
                _outFactory = outAssembly.CreateInstance(Config.Service.OutputClass) as IOutputFactory;

                if (_outFactory == null)
                {
                    throw new ProcessFatalException($"Could not load the output factory with the name {Config.Service.OutputClass} in assembly {outAssembly.FullName}");
                }

                _log.Debug("IOutputFactory instance created.");
            }
            catch (Exception ex)
            {
                throw new ProcessFatalException("Error loading output factory.", ex);
            }
        }
Example #11
0
        private void InitOutputMappings(IOutputFactory outFactory)
        {
            var outmap = CxAnalytix.Configuration.Config.GetConfig <CxAuditTrailRecordNameMap>(CxAuditTrailRecordNameMap.SECTION_NAME);

            var fields = typeof(CxAuditTrailTableNameConsts).GetFields();
            Dictionary <String, FieldInfo> fieldLookup = new Dictionary <string, FieldInfo>();

            foreach (var f in fields)
            {
                fieldLookup.Add(f.Name, f);
            }


            foreach (var prop in typeof(CxAuditTrailRecordNameMap).GetProperties())
            {
                if (fieldLookup.ContainsKey(prop.Name))
                {
                    _outMappings.Add(fieldLookup[prop.Name].Name,
                                     outFactory.newInstance(GetPropertyValue <CxAuditTrailRecordNameMap, String>(prop.Name, outmap)));
                }
            }
        }
Example #12
0
        /// <summary>
        /// Initialise this coordinator, specifying a collection of plugins to work with.
        /// </summary>
        /// <param name="plugins">The plugins which control this coordinator.</param>
        public Core(IOutputFactory outputFactory, params ISystemPlugin[] plugins)
        {
            try {
                mConfig = new CoreConfig();

                mPlugins            = new List <ISystemPlugin>(plugins);
                mOrientation        = new Rotation(mRotationLock, mConfig.Pitch, mConfig.Yaw);
                mOrientationDelta   = new Rotation(mRotationLock);
                mPosition           = mConfig.Position;
                mEyePosition        = mConfig.EyePosition;
                mCrashLogFile       = mConfig.CrashLogFile;
                mTickLength         = mConfig.TickLength;
                mDefaultHeight      = mConfig.HeightmapDefault;
                mHeightmap          = new float[mConfig.XRegions * 256, mConfig.YRegions * 256];
                mEnableInputUpdates = mConfig.EnableInputUpdates;

                for (int i = 0; i < mHeightmap.GetLength(0); i++)
                {
                    for (int j = 0; j < mHeightmap.GetLength(1); j++)
                    {
                        mHeightmap[i, j] = mDefaultHeight;
                    }
                }

                foreach (string frame in mConfig.Frames)
                {
                    if (outputFactory != null)
                    {
                        AddFrame(new Frame(frame, outputFactory.Create(frame)));
                    }
                    else
                    {
                        AddFrame(new Frame(frame));
                    }
                }

                foreach (var plugin in mPlugins)
                {
                    plugin.Init(this);
                    plugin.Enabled = mConfig.PluginEnabled(plugin);
                    Logger.Info("Loaded " + plugin.Name + ". " + (plugin.Enabled ? "Enabled" : "Disabled") + ".");
                }

                Thread tickThread = new Thread(TickMethod);

                tickThread.Name = "Tick Thread";
                //tickThread.Priority = ThreadPriority.Highest;
                tickThread.Start();
                mInitialised = true;
                if (InitialisationComplete != null)
                {
                    InitialisationComplete();
                }
            } catch (Exception e) {
                Logger.Warn("Unable to instantiate core. " + e.Message);
                Logger.Debug("Unable to instantiate core.", e);
            } finally {
                if (!mInitialised)
                {
                    Close();
                }
            }
        }
Example #13
0
 public MappingService(IMappingListService listService, IMappingFilterService filterService, IOutputFactory factory)
 {
     _listService   = listService;
     _filterService = filterService;
     _factory       = factory;
 }
Example #14
0
 private AuditTrailCrawler(IOutputFactory outFactory)
 {
     InitSinceDate();
     InitOutputMappings(outFactory);
 }