3using System.Threading.Tasks;
60 if (!State.
Request.Server.TryGetFileName(State.
Request.Header.ResourcePart,
61 false, out
string ResourceFileName))
66 string ManifestFileName = await this.manifestFile.EvaluateAsync(State.
Variables,
string.Empty);
67 string Key = ResourceFileName +
"|C|" + ManifestFileName;
69 if (!State.TryGetCachedObject(Key, out
bool IsMatch))
71 if (!File.Exists(ManifestFileName))
77 if (ResourceFileName.StartsWith(
'/'))
78 ResourceFileName = ResourceFileName[1..];
80 IsMatch = CheckMatch(ManifestFileName, ResourceFileName);
88 private static bool CheckMatch(
string ManifestFileName,
string ContentFileName)
92 if (!File.Exists(ManifestFileName))
97 if (Doc.DocumentElement is
null ||
98 Doc.DocumentElement.LocalName !=
"Module" ||
99 Doc.DocumentElement.NamespaceURI !=
"http://waher.se/Schema/ModuleManifest.xsd")
104 XmlElement Loop = Doc.DocumentElement;
105 string[] Parts = ContentFileName.Split(pathSeparators);
106 int i, c = Parts.Length;
108 for (i =
string.IsNullOrEmpty(Parts[0]) ? 1 : 0; i < c; i++)
110 XmlElement Found =
null;
112 foreach (XmlNode N
in Loop.ChildNodes)
114 if (!(N is XmlElement E))
119 if (E.LocalName ==
"Content" &&
120 E.HasAttribute(
"fileName") &&
121 E.GetAttribute(
"fileName").Equals(Parts[i], StringComparison.CurrentCultureIgnoreCase))
129 if (E.LocalName ==
"Folder" &&
130 E.HasAttribute(
"name") &&
131 E.GetAttribute(
"name").Equals(Parts[i], StringComparison.CurrentCultureIgnoreCase))
154 private static readonly
char[] pathSeparators =
new char[] {
'/',
'\\' };
Helps with common XML-related tasks.
static XmlDocument LoadFromFile(string FileName)
Loads an XML document from a file.
Static class managing the application event log. Applications and services log events on this static ...
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
Checks if the request is encrypted.
override string LocalName
XML Local Name for the XML element defining the action.
IsContent(XmlElement Xml, WafAction Parent, WebApplicationFirewall Document)
Checks if the request is encrypted.
IsContent()
Checks if the request is encrypted.
override async Task< WafResult?> Review(ProcessingState State)
Reviews the processing state, and returns a WAF result, if any.
override WafAction Create(XmlElement Xml, WafAction Parent, WebApplicationFirewall Document)
Creates a WAF action from its XML definition.
Abstract base class for Web Application Firewall comparisons.
Contains the current state of a review process.
Variables Variables
Set of variables.
void AddToCache(string Key, object Value)
Adds a value to the cache.
WebApplicationFirewall Firewall
Reference to the current Web Application Firewall object.
HttpRequest Request
Current HTTP Request
Abstract base class for Web Application Firewall actions.
WebApplicationFirewall Document
Web Application Firewall document.
static readonly TimeSpan fiveMinutes
Five minutes time span.
async Task< WafResult?> ReviewChildren(ProcessingState State)
Reviews the processing state, and returns a WAF result, if any.
Web Application Firewall for HttpServer.
string AppDataFolder
Application data folder, where content files are stored.