使用ColdFusion MX7时,如果我们遇到异常,我们会向开发团队发送一封电子邮件,其中包含各种数据范围的转储,包括表单结构。
这对于调试非常有效,除非在用户登录时出现错误。我们最终将密码打印出来。
因此,问题是,有没有一种方法可以修改CFDUMP文件,使其从form对象中过滤出密码值?
当然,我们可以将它放在发送电子邮件的相同代码中,但是最好将它放在CFDUMP文件中,这样我们就不必担心它会出现在其他地方。
我已经找到了CFDUMP文件,它似乎是二进制的,所以我猜我们不能这样做。
发布于 2009-07-30 13:22:59
您可以将dump.cfm文件复制到dumporiginal.cfm,然后创建一个调用dumporiginal.cfm的新dump.cfm。
<!---
So that it won't execute twice if you
have a closing slash (<cfdump ... />)
--->
<cfif thisTag.executionMode neq "start">
<cfexit method="exitTag" />
</cfif>
<!---
defaults for optional attributes, taken from the docs
http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_d-e_08.html
--->
<cfparam name="attributes.expand" default="yes" />
<cfparam name="attributes.format" default="html" />
<cfparam name="attributes.hide" default="all" />
<cfparam name="attributes.keys" default="9999" />
<cfparam name="attributes.label" default="" />
<cfparam name="attributes.metainfo" default="yes" />
<cfparam name="attributes.output" default="browser" />
<cfparam name="attributes.show" default="all" />
<cfparam name="attributes.showUDFs" default="yes" />
<cfparam name="attributes.top" default="9999" />
<!--- Hide the password, but store its value to put it back at the end --->
<cfif isStruct(attributes.var) and structKeyExists(attributes.var, 'password')>
<cfset originalPassword = attributes.var.password />
<cfset attributes.var.password = "{hidden by customized cfdump}"/>
</cfif>
<!---
Call the original cfdump.
Which attributes you pass depends on CF version.
--->
<cfswitch expression="#listFirst(server.coldfusion.productVersion)#">
<cfcase value="6">
<cfdumporiginal
var = "#attributes.var#"
expand = "#attributes.expand#"
hide = "#attributes.hide#"
label = "#attributes.label#"
>
</cfcase>
<cfcase value="7">
<cfdumporiginal
var = "#attributes.var#"
expand = "#attributes.expand#"
hide = "#attributes.hide#"
label = "#attributes.label#"
top = "#attributes.top#"
>
</cfcase>
<cfdefaultcase>
<cfdumporiginal
var = "#attributes.var#"
expand = "#attributes.expand#"
format = "#attributes.format#"
hide = "#attributes.hide#"
keys = "#attributes.keys#"
label = "#attributes.label#"
metainfo = "#attributes.metainfo#"
output = "#attributes.output#"
show = "#attributes.show#"
showUDFs = "#attributes.showUDFs#"
top = "#attributes.top#"
>
</cfdefaultcase>
</cfswitch>
<!--- Restore the password, in case it's read after cfdump call --->
<cfif isDefined("originalPassword")>
<cfset attributes.var.password = originalPassword />
</cfif>发布于 2009-07-30 11:47:41
不,我不认为有办法改变<cfdump>的行为。显然,我不能确定。这样的黑客攻击存在是可以想象的,尽管它不一定值得推荐。
为什么不用一个简单的:
<cftry>
<cfset DoSomethingThatFails()>
<cfcatch>
<cfif StructKeyExists(FORM, "Password")>
<cfset FORM.Password = "***">
</cfif>
<cfdump var="#FORM#">
</cfcatch>
</cftry>发布于 2009-07-30 16:13:57
早在CF5时代,CFDUMP就作为一个定制标记(CF_DUMP)诞生了。您可以随时获取该自定义标记的代码,并根据需要对其进行修改,然后使用该代码而不是内置标记。
https://stackoverflow.com/questions/1206031
复制相似问题