An XML reader or document is given an XmlUrlResolver, which lets the input load external files and URLs
What it finds
With a resolver, external entities and DTDs in an XML document are fetched: a document can read local files into its content or make the server request internal URLs. Setting XmlResolver to null turns this off. The rule reports assignments of a new XmlUrlResolver or XmlSecureResolver to an XmlResolver property.
From the rule's source, xml_resolver_enabled.rs.
using System.Xml; class Reader{ void Load(string text) { var doc = new XmlDocument(); doc.XmlResolver = new XmlUrlResolver();tx0 reports: an XmlUrlResolver lets the document load external resources doc.LoadXml(text); var safe = new XmlDocument(); safe.XmlResolver = null; }} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/csharp:xml-resolver-enabled" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/csharp:xml-resolver-enabled] reason="..."tx0 explain tx0/csharp:xml-resolver-enabled shows the same in the terminal. Found a false positive? Report it.