<cffunction
name="MakeStructSecure"
access="public"
returntype="any"
output="false"
hint="Does a very cursory job of cleaning up a struct by blacking out secure information.">
<cfargument
name="Struct"
type="struct"
required="true"
hint="The struct we are going to clean."
/>
<cfargument
name="Depth"
type="numeric"
required="false"
default="1"
hint="The depth of the current search - this will stop the function from looping infinitely."
/>
<cfset var LOCAL = StructNew() />
<cfif (ARGUMENTS.Depth GTE 5)>
<cfreturn />
</cfif>
<cfsavecontent variable="LOCAL.SecureKeys">
CreditCard
CCNumber
CCNum
ExpirationDate
Expry
ExpDate
CCExp
</cfsavecontent>
<cfloop
item="LOCAL.Key"
collection="#ARGUMENTS.Struct#">
<cfif (
FindNoCase( LOCAL.Key, LOCAL.SecureKeys ) AND
IsSimpleValue( ARGUMENTS.Struct[ LOCAL.Key ] )
)>
<cfset ARGUMENTS.Struct[ LOCAL.Key ] = RepeatString(
"*",
Len( ARGUMENTS.Struct[ LOCAL.Key ] )
) />
<cfelseif IsStruct( ARGUMENTS.Struct[ LOCAL.Key ] )>
<cfset MakeStructSecure(
Struct = ARGUMENTS.Struct[ LOCAL.Key ],
Depth = (ARGUMENTS.Depth + 1)
) />
</cfif>
</cfloop>
<cfif (ARGUMENTS.Depth EQ 1)>
<cfreturn ARGUMENTS.Struct />
<cfelse>
<cfreturn />
</cfif>
</cffunction>