【发布时间】:2026-01-01 06:20:05
【问题描述】:
我有一个使用 XSLT 编写的网站。
想法是,数据将存储在 XML 文件中,网站将使用 xsl 模板将此 XML 转换为 HTML。决定使用这种技术的开发人员已经离开了我们公司,没有人知道为什么以及如何做到这一点。
问题是有一天这个站点开始使用 100% CPU 并且服务器被挂了。
获取转储文件显示其中一个线程执行此操作:
Thread 26
Current frame: (MethodDesc 0x7a4b7f68 +0x4f System.Text.RegularExpressions.RegexInterpreter.Go())
ChildEBP RetAddr Caller,Callee
11f3ecb4 7a5c20b1 (MethodDesc 0x7a45eab4 +0x91 System.Text.RegularExpressions.RegexRunner.Scan(System.Text.RegularExpressions.Regex, System.String, Int32, Int32, Int32, Int32, Boolean))
11f3eccc 7a5c1e97 (MethodDesc 0x7a45e99c +0x87 System.Text.RegularExpressions.Regex.Run(Boolean, Int32, System.String, Int32, Int32, Int32)), calling (MethodDesc 0x7a45eab4 +0 System.Text.RegularExpressions.RegexRunner.Scan(System.Text.RegularExpressions.Regex, System.String, Int32, Int32, Int32, Int32, Boolean))
11f3ed04 7a5c1dfd (MethodDesc 0x7a45e858 +0x2d System.Text.RegularExpressions.Regex.Match(System.String)), calling (MethodDesc 0x7a45e99c +0 System.Text.RegularExpressions.Regex.Run(Boolean, Int32, System.String, Int32, Int32, Int32))
11f3ed24 7a5c510c (MethodDesc 0x7a45e840 +0x2c System.Text.RegularExpressions.Regex.Match(System.String, System.String)), calling (MethodDesc 0x7a45e858 +0 System.Text.RegularExpressions.Regex.Match(System.String))
11f3ed38 667c1868 (MethodDesc 0x65fac47c +0x70 System.Web.UI.WebControls.RegularExpressionValidator.EvaluateIsValid()), calling (MethodDesc 0x7a45e840 +0 System.Text.RegularExpressions.Regex.Match(System.String, System.String))
11f3ed60 667acd0d (MethodDesc 0x65f60d84 +0x49 System.Web.UI.WebControls.BaseValidator.Validate())
11f3ed70 6669798e (MethodDesc 0x65f5b434 +0x8e System.Web.UI.Page.Validate()), calling 0289948e
11f3ed88 66903dbf (MethodDesc 0x65f5aeb4 System.Web.UI.Page.RaisePostBackEvent(System.Collections.Specialized.NameValueCollection))
11f3ed9c 660abb2e (MethodDesc 0x65f5b2c8 +0x61e System.Web.UI.Page.ProcessRequestMain(Boolean, Boolean)), calling (MethodDesc 0x65f5aeb4 +0 System.Web.UI.Page.RaisePostBackEvent(System.Collections.Specialized.NameValueCollection))
11f3eef0 660ab3b4 (MethodDesc 0x65f5b26c +0x84 System.Web.UI.Page.ProcessRequest(Boolean, Boolean)), calling (MethodDesc 0x65f5b2c8 +0 System.Web.UI.Page.ProcessRequestMain(Boolean, Boolean))
11f3ef14 0f32271d (MethodDesc 0xf136b58 +0x3d System.Threading.Thread.get_CurrentUICulture()), calling mscorwks!CorExitProcess+0x1bb1c
11f3ef28 660ab2e1 (MethodDesc 0x65f5b260 +0x51 System.Web.UI.Page.ProcessRequest()), calling (MethodDesc 0x65f5b26c +0 System.Web.UI.Page.ProcessRequest(Boolean, Boolean))
11f3ef64 660ab276 (MethodDesc 0x65f5b23c +0x16 System.Web.UI.Page.ProcessRequestWithNoAssert(System.Web.HttpContext)), calling (MethodDesc 0x65f5b260 +0 System.Web.UI.Page.ProcessRequest())
11f3ef70 660ab252 (MethodDesc 0x65f5b228 +0x32 System.Web.UI.Page.ProcessRequest(System.Web.HttpContext)), calling (MethodDesc 0x65f5b23c +0 System.Web.UI.Page.ProcessRequestWithNoAssert(System.Web.HttpContext))
11f3ef84 0fc19105 (MethodDesc 0x120a1888 +0x5 ASP.website_default_aspx.ProcessRequest(System.Web.HttpContext)), calling (MethodDesc 0x65f5b228 +0 System.Web.UI.Page.ProcessRequest(System.Web.HttpContext))
11f3ef88 030d4904 (MethodDesc 0x11f82ce0 +0x34 Xplode.Web.ApplicationRuntime.XplodePageHandler.ProcessRequest(System.Web.HttpContext)), calling 0289efda
11f3ef98 660b1726 (MethodDesc 0x65f6c088 +0xb6 System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()), calling 0289efda
11f3ef9c 0fc19016 (MethodDesc 0x2cd9658 +0x56 FiftyOne.Foundation.Mobile.Detection.DetectorModule.SetPagePreIntClientTargets(System.Object, System.EventArgs)), calling mscorwks+0x9362
11f3efcc 6608445c (MethodDesc 0x65f67c8c +0x4c System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)), calling 0289d86a
11f3f008 6608fcd3 (MethodDesc 0x65fcb1ac +0x133 System.Web.HttpApplication+ApplicationStepManager.ResumeSteps(System.Exception)), calling (MethodDesc 0x65f67c8c +0 System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef))
11f3f05c 660839dc (MethodDesc 0x65f67bac +0x7c System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext, System.AsyncCallback, System.Object))
11f3f070 66086f4c (MethodDesc 0x65f6373c +0x17c System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest)), calling 0289d7ca
11f3f09c 026e2c2c 026e2c2c, calling 0285a248
11f3f0ac 66086bf3 (MethodDesc 0x65fbb8a0 +0x63 System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest)), calling (MethodDesc 0x65f6373c +0 System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest))
11f3f0bc 66085d8c (MethodDesc 0x65f643bc +0x11c System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr, Int32)), calling (MethodDesc 0x65fbb8a0 +0 System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest))
11f3f0d4 66085d01 (MethodDesc 0x65f643bc +0x91 System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr, Int32)), calling webengine!GetEcb
11f3f11c 79f23fcb mscorwks!InstallCustomModule+0x15733, calling mscorwks+0xcd0d
...
如您所见,页面 /website/default.aspx - 这是接受参数 url 并重定向到此 url 的页面。所以我需要知道是哪个页面制作的。
然而,在这个网站上,只有少数带有正则表达式的电子邮件表单。
\w+(([-+.'’])*(\w+))*@\w+(([-.])*(\w+))*\.\w+([-.]\w+)*
其中一个表单位于页脚“注册时事通讯”中,但当我删除此表单时,没有任何变化。 然后我使用日志来查看发送给验证器的内容,我看到了很多来自机器人的垃圾邮件。
这里有一些代码显示页面是如何呈现的:
<dandaraui:HomesForSale SaveParametersInSession="false"
StyleSheet="~/assets/xslt/developments/development-homes-for-sale.xslt"
runat="server" ID="homesForSaleControl">
</dandaraui:HomesForSale>
HomesForSale.Render:
protected override void Render(HtmlTextWriter writer)
{
if (PersistedDevelopment.Current == null)
return;
XPathDocument xpathDocument = PersistedDevelopment.Current.XPathDocument;
XslCachedTransform xslCachedTransform = new XslCachedTransform(this.m_sStylesheet);
HttpRequest request = HttpContext.Current.Request;
for (int index = 0; index < request.QueryString.Keys.Count; ++index)
this.m_pXsltArgumentList.AddParam(request.QueryString.Keys[index], string.Empty, (object) request.QueryString[index]);
string str = xslCachedTransform.Transform(xpathDocument, this.m_pXsltArgumentList).Replace("&#163;", "£");
writer.Write(str);
}
【问题讨论】:
-
您有任何理由相信 XSLT 负责吗?也许您的服务器只是被垃圾邮件的流量超载了?该堆栈跟踪显示正在发生某种验证(但我不知道该堆栈跟踪是否也与 CPU 问题有关)。我可以肯定地说的一件事是您通常不应该将请求的查询字符串键直接传递到您的 XSLT。这听起来像是一个安全隐患。
-
@JLRishe 这个网站很老了,我只是支持它。我真的认为使用 xslt 对站点不利,但 xls - 只是页面生成器,所有请求仍然通过标准的 asp 页面。我怀疑 xsl 执行起来非常繁重,但为什么 dump 说它是验证器问题?下面有答案,我试试替换正则表达式,然后说结果。
标签: html asp.net regex xml xslt