Ejemplo n.º 1
0
        /// <summary>
        /// Print a status message about all available plugins.
        /// </summary>
        public static void PrintAvailablePlugins()
        {
            ISet <IArtifactProcessor> allArtifactProcessors = ArtifactProcessorLoader.LoadAllArtifactProcessors();

            foreach (IArtifactProcessor artifactProcessor in allArtifactProcessors)
            {
                ISet <Type> allPlugins = LoadSupportedPlugins(artifactProcessor);
                string      pluginInfo = GetPluginInfoMessage(artifactProcessor.ArtifactType, allPlugins);
                Log.Info(pluginInfo);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Unpacks the target logset and sets the root log directory. Contains logic to copy files locally if target is on a remote server.
        /// </summary>
        public static void ExtractLogFiles(LogsharkRequest request)
        {
            // Purge temp directory of any data left over from aborted runs.
            PurgeTempDirectory();

            var availableArtifactProcessors = ArtifactProcessorLoader.LoadAllArtifactProcessors();
            var extractionWhitelist         = BuildExtractionWhitelist(availableArtifactProcessors);
            var extractor = new LogsetExtractor(request, extractionWhitelist);

            extractor.Process();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Print a status message about all available plugins.
        /// </summary>
        public static void PrintAvailablePlugins()
        {
            var artifactProcessorLoader = new ArtifactProcessorLoader();
            var allArtifactProcessors   = artifactProcessorLoader.LoadAllArtifactProcessors();

            foreach (var artifactProcessor in allArtifactProcessors)
            {
                var allPlugins = LoadSupportedPlugins(artifactProcessor);
                var pluginInfo = BuildPluginInfoMessage(artifactProcessor.ArtifactType, allPlugins);
                Log.Info(pluginInfo);
            }
        }
Ejemplo n.º 4
0
        protected ISet <Regex> BuildExtractionWhitelist()
        {
            var artifactProcessorLoader = new ArtifactProcessorLoader();
            ISet <IArtifactProcessor> availableArtifactProcessors = artifactProcessorLoader.LoadAllArtifactProcessors();

            ISet <Regex> supportedFilePatterns = new HashSet <Regex>();

            foreach (var processor in availableArtifactProcessors)
            {
                supportedFilePatterns.UnionWith(processor.SupportedFilePatterns);
            }

            return(supportedFilePatterns);
        }
Ejemplo n.º 5
0
        public static IArtifactProcessor GetCompatibleArtifactProcessor(LogsharkRequest request)
        {
            Log.Info("Loading Logshark artifact processors..");
            ISet <IArtifactProcessor> availableProcessors = ArtifactProcessorLoader.LoadAllArtifactProcessors();

            if (availableProcessors.Count == 0)
            {
                Log.Warn("No artifact processors found!");
            }
            else
            {
                string loadedProcessorString = String.Join(", ", availableProcessors.Select(processor => processor.GetType().Name).AsEnumerable());
                Log.InfoFormat("Loaded {0} artifact {1}: {2}", availableProcessors.Count, "processor".Pluralize(availableProcessors.Count), loadedProcessorString);
            }

            IList <IArtifactProcessor> compatibleProcessors = new List <IArtifactProcessor>();

            foreach (IArtifactProcessor processor in availableProcessors)
            {
                if (processor.CanProcess(request))
                {
                    Log.Info("Found matching artifact processor: " + processor.GetType().Name);
                    compatibleProcessors.Add(processor);
                }
            }

            if (compatibleProcessors.Count == 0)
            {
                throw new InvalidLogsetException("No compatible artifact processor found for payload! Is this a valid logset?");
            }

            if (compatibleProcessors.Count > 1)
            {
                throw new ArtifactProcessorInitializationException(String.Format("Multiple artifact processors match payload: {0}", String.Join(", ", compatibleProcessors)));
            }

            return(compatibleProcessors.First());
        }