示例#1
0
        /// <summary>
        /// Locks the form and Waits until the export thread is done, then unlocks the form
        /// </summary>
        /// <param name="t">The thread to wait for</param>
        private void MonitorExportThread(Thread t, AthenaPluginInterfaces.AthenaExportPlugin Plugin = null)
        {
            //Make sure the thread hasn't already finished
            if (t.IsAlive)
            {
                ///Lock the form
                IndicatorDetailsPanel.BeginInvoke((Action) delegate { LockForm(true, true, "Exporting..."); });

                //Wait for the thread to finish
                while (t.IsAlive)
                {
                    Thread.Sleep(1000);               ///Wait one second before checking again
                }
                //If we were passed a plugin object, then check for errors
                if (Plugin != null)
                {
                    if (!Plugin.ExportSuccessful())
                    {
                        MessageBox.Show("Error saving the file. The export plugin reported the following:\r\n" + String.Join("\r\n- ", Plugin.ReportErrors()));
                    }
                }

                //Unlock the form
                IndicatorDetailsPanel.BeginInvoke((Action) delegate { LockForm(false); });
            }
        }
示例#2
0
        private void LoadExportPlugins()
        {
            ExportPlugins = new List <AthenaPluginInterfaces.AthenaExportPlugin>();
            Type pluginType = typeof(AthenaPluginInterfaces.AthenaExportPlugin);
            ICollection <Type> pluginTypes = new List <Type>();

            //Built In
            pluginTypes.Add(typeof(Stix1ExportPlugin.Stix1ExportPlugin));
            pluginTypes.Add(typeof(MISPJsonExportPlugin.MISPJsonExportPlugin));
            pluginTypes.Add(typeof(SnortRulesExportPlugin.SnortRulesExportPlugin));
            pluginTypes.Add(typeof(YaraRulesExportPlugin.YaraRulesExportPlugin));

            //Dynamic
            // Here we will load external DLL files which impliment the plugin interface
            // For now, we are omitting this while we determine the best way to securely allow external assembly files
            // without allowing any DLL to be executed with arbitrary code under the privilage of this application

            //Add the plugins to the menu and add event handlers
            foreach (Type type in pluginTypes)
            {
                AthenaPluginInterfaces.AthenaExportPlugin plugin = (AthenaPluginInterfaces.AthenaExportPlugin)Activator.CreateInstance(type);
                ExportPlugins.Add(plugin);
                exportToolStripMenuItem.DropDownItems.Add(plugin.DisplayName, null, exportplugin_MenuClick_EventHandler);
            }
        }