3using System.Reflection;
4using System.Threading.Tasks;
18 private static readonly Dictionary<string, IWafAction> actionTypes = GetActionTypes();
20 private readonly
string id;
43 if (!
string.IsNullOrEmpty(this.
id))
44 Document.RegisterAction(
this);
55 public string Id => this.id;
71 private static Dictionary<string, IWafAction> GetActionTypes()
73 Dictionary<string, IWafAction> Result =
new Dictionary<string, IWafAction>();
83 if (Result.ContainsKey(Action.LocalName))
84 Log.
Error(
"Duplicate WAF action definition: " + Action.LocalName);
86 Result[Action.LocalName] = Action;
102 throw new ArgumentNullException(nameof(Xml));
105 throw new Exception(
"Invalid WAF namespace.");
107 if (!actionTypes.TryGetValue(Xml.LocalName, out
IWafAction Action))
108 throw new Exception(
"Unrecognized WAF action: " + Xml.LocalName);
110 return Action.Create(Xml, Parent,
Document);
131 protected static readonly TimeSpan
fiveMinutes = TimeSpan.FromMinutes(5);
Helps with common XML-related tasks.
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Static class managing the application event log. Applications and services log events on this static ...
static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an error event.
Static class that dynamically manages types and interfaces available in the runtime environment.
static Type[] GetTypesImplementingInterface(string InterfaceFullName)
Gets all types implementing a given interface.
static ConstructorInfo GetDefaultConstructor(Type Type)
Gets the default constructor of a type, if one exists.
Contains the current state of a review process.
Abstract base class for Web Application Firewall actions.
abstract string LocalName
XML Local Name for the XML element defining the action.
static WafAction Parse(XmlElement Xml, WafAction Parent, WebApplicationFirewall Document)
Parses an XML Element defining a WAF action.
WebApplicationFirewall Document
Web Application Firewall document.
abstract Task< WafResult?> Review(ProcessingState State)
Reviews the processing state, and returns a WAF result, if any.
WafAction(XmlElement Xml, WafAction Parent, WebApplicationFirewall Document)
Abstract base class for Web Application Firewall actions.
virtual void Prepare()
Prepares the node for processing.
WafAction()
Abstract base class for Web Application Firewall actions.
string Id
ID of action in document, if any.
abstract WafAction Create(XmlElement Xml, WafAction Parent, WebApplicationFirewall Document)
Creates a WAF action from its XML definition.
static readonly TimeSpan fiveMinutes
Five minutes time span.
Web Application Firewall for HttpServer.
const string Namespace
http://waher.se/Schema/WAF.xsd
interface for Web Application Firewall actions.