Forum Discussion
BlurredVision_1
Nimbostratus
Jan 30, 2008CCN Scrubber not matching card numbers...
All,
I am working on an iRule demo to show people how darn powerful these things are. The CCN Scrubber is an ideal candidate. Only thing is I can't get it working.
As I am putting together a demo that others will be able to also run, I am using an online page with sample test card number that are valid (as far as the LUHN check is concerned...) located here:
only issue is that the card_indices value is being returned as empty:
Find ALL the possible credit card numbers in one pass
set card_indices [regexp -all -inline -indices {(?:3[4-7]\d{13})|(?:4\d{15})|(?:5[1-5]\d{14})|(?:6011\d{12})} [HTTP::payload]]
log local0. "card indices are \"$card_indices\""
returns the following in the logs:
Rule CC_scrub : card indices are ""
Any ideas why the regex is not matching a thing?
Cheers.
Blurred.
- hoolio
Cirrostratus
Hi,when RULE_INIT { This regex defines what strings are considired a credit card. Wrap the regex in curly braces. set ::cc_regex {(?:3[4-7]\d{1,3})|(?:4\d{1,5})|(?:5[1-5]\d{1,4})|(?:6011\d{1,2})} Replace the matched strings with this string. It can be blank to remove the string altogether. set ::replacement_text "xxxxxxxxxxxxxxxx" As an example, this is a way to limit which requests to check the responses from. set ::uris_to_check_response [list \ .aspx \ .asp \ .html \ ] Log debug to /var/log/ltm? 1=yes, 0=no. set ::cc_replace_debug 1 } when HTTP_REQUEST { Don't check responses by default set check_response 0 Check if response if {[matchclass [string tolower [HTTP::path]] ends_with $::uris_to_check_response]}{ set check_response 1 } } when HTTP_RESPONSE { Disable the stream filter by default STREAM::disable Check the response if the response we want to check. You can check all text responses, and/or based on the request type if {[HTTP::header value Content-Type] contains "text" and $check_response}{ Don't apply the stream profile against 4+Mb response sizes or TMM will restart (reference: SOL6741 / CR70146) You can remove this check if your version has a fix for this issue. if {[HTTP::header exists Content-Length] and [HTTP::header value Content-Length] < 4194304}{ Wildcard match set stream_expression {@$::cc_regex@$::replacement_text@} Set the find/replace strings STREAM::expression $stream_expression if {$::debug}{ log local0. "Current stream expression: $stream_expression" } Enable the stream filter for this response STREAM::enable } } } STREAM_MATCHED is triggered when the stream filter's find string is found when STREAM_MATCHED { Log the string which matched the stream profile if {$::debug}{ log local0. "Matched: [STREAM::match]" } }
- BlurredVision_1
Nimbostratus
The rule is still not working for me, but I found the first culprit: compression - hoolio
Cirrostratus
You can apply the response logic if the Content-Type header contains the string text: - BlurredVision_1
Nimbostratus
I am running v9.4.2. I think the issue to get this working (optimisations aside for the moment, this is just to show it working as a Proof of Concept) is going to be Content-Type evaluation so we are only validating text content...when HTTP_RESPONSE { if { [HTTP::header "Content-Type"] starts_with "text/" } {
- BlurredVision_1
Nimbostratus
Sorted: the Content-Type check was what it needed.set card_indices [regexp -all -inline -indices {(?:3[00-05]\d{11})|(?:3[6|8]\d{11})|(?:3[4|7]\d{13})|(?:4\d{12})|(?:4\d{15})|(?:5[1-5]\d{14})|(?:6011\d{12})} [HTTP::payload]]
- BlurredVision_1
Nimbostratus
lets try that again. This works now:set card_indices [regexp -all -inline -indices {(?:30[0-5]\d{11})|(?:3[6|8]\d{12})|(?:3[4|7]\d{13})|(?:4\d{12})|(?:4\d{15})|(?:5[1-5]\d{14})|(?:6011\d{12})} [HTTP::payload]]
- hoolio
Cirrostratus
No problem. At some point I'll try testing the stream version and post a working version as an alternative.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects