| 1 |
# |
| 2 |
# To enable url_check service in c-icap, copy this file in c-icap |
| 3 |
# configuration directory and add the following line at the end of |
| 4 |
# c-icap.conf file: |
| 5 |
# Include srv_content_filtering.conf |
| 6 |
# |
| 7 |
|
| 8 |
# Module: srv_content_filtering |
| 9 |
# Example: |
| 10 |
# Service url_check_module srv_url_check.so |
| 11 |
# |
| 12 |
# Description: |
| 13 |
# This is an score based content filtering icap service |
| 14 |
# This module add the following log formating codes for use with |
| 15 |
# the LogFormat configuration parameter: |
| 16 |
# %{srv_content_filtering:action}Sa Print the service decision |
| 17 |
# %{srv_content_filtering:scores}Sa Print the list of scores of |
| 18 |
# the matching filters applied |
| 19 |
# %{srv_content_filtering:action_filter}Sa Print the matching filter |
| 20 |
# caused the final decision |
| 21 |
# Example: |
| 22 |
# LogFormat mySrvContentFiltering "%tl, %>a %im %is %huo [Scores: %{srv_content_filtering:scores}Sa] [ActionFilter: %{srv_content_filtering:action_filter}Sa] [Action: %{srv_content_filtering:action}Sa]" |
| 23 |
# |
| 24 |
# The following additional formatting codes can be used with the |
| 25 |
# service template "BLOCK": |
| 26 |
# %CFA The service decision |
| 27 |
# %CFF The matching filter caused the decision |
| 28 |
# %CFC The final score, which caused the service decision |
| 29 |
# %CFR The reason of the decision: [>|<|=]ConfiguredScore |
| 30 |
# %CFS The list of scores of the matching filters applied |
| 31 |
# |
| 32 |
|
| 33 |
Service srv_cfg_filter srv_content_filtering.so |
| 34 |
|
| 35 |
# TAG: srv_content_filtering.MaxBodyData |
| 36 |
# Format: srv_content_filtering.MaxBodyData size[K|M|G] |
| 37 |
# Description: |
| 38 |
# Set the maximum size of body data to process |
| 39 |
# Example: |
| 40 |
# srv_content_filtering.MaxBodyData 2M |
| 41 |
|
| 42 |
# TAG: srv_content_filtering.Match |
| 43 |
# Format: |
| 44 |
# srv_content_filtering.Match filter-name type regex [score=TheScore] [info{Tag}=TagValue] |
| 45 |
# srv_content_filtering.Match filter-name type file:PathToFileName |
| 46 |
# Description: |
| 47 |
# filter-name |
| 48 |
# A name for the matching filter. The same name can be used |
| 49 |
# more than once to define filters with more than one matching rules. |
| 50 |
# type |
| 51 |
# It can be one of the following: |
| 52 |
# body: apply the regex expression to body data |
| 53 |
# url: apply the regex expression to the http request url |
| 54 |
# header{HeaderName}: apply the regex expression to the HTTP |
| 55 |
# response header "HeaderName". |
| 56 |
# request_header{HeaderName}: apply the regex expression to the |
| 57 |
# HTTP request header "HeaderName". |
| 58 |
# regex |
| 59 |
# It has the form /regex_definition/flags. |
| 60 |
# The "flags" is one or more letters, its of them express a flag. |
| 61 |
# Common flags: |
| 62 |
# g This flag forces the score multiplied by the number of regex |
| 63 |
# expression matches. For example if the expression matches 5 |
| 64 |
# times and the devined score value is 10 then the final score |
| 65 |
# will be 50. |
| 66 |
# i Do caseless matching |
| 67 |
# m Match-any-character operators don't match a newline |
| 68 |
# and ^$ operators does not match newlines within data |
| 69 |
# If the module compiled using the pcre library the following flags |
| 70 |
# can be used: |
| 71 |
# s (PCRE_DOTALL) matches anything including NL |
| 72 |
# x (PCRE_EXTENDED) Ignore whitespace and # comments |
| 73 |
# A (PCRE_ANCHORED) Force pattern anchoring |
| 74 |
# D (PCRE_DOLLAR_ENDONLY) $ not to match newline at end |
| 75 |
# U (PCRE_UNGREEDY) Invert greediness of quantifiers |
| 76 |
# X (PCRE_EXTRA) PCRE extra features |
| 77 |
# u (PCRE_UTF8) Run in UTF-8 mode |
| 78 |
# TheScore |
| 79 |
# A decimal number which express a score value for the HTTP object |
| 80 |
# matches the regular expression. |
| 81 |
# Tag,TagValue |
| 82 |
# Information tag for this matching rule. This is currently used |
| 83 |
# by "replace" action to provide a regex replacement for matching |
| 84 |
# text. |
| 85 |
# PathToFileName |
| 86 |
# If a parameter in the form file:PathToFileName exist as argument |
| 87 |
# then the module load rules from the file 'PathToFileName'. |
| 88 |
# The rules in this file stored in the form: |
| 89 |
# score=TheScore [info{Tag}=TagValue] regex |
| 90 |
# one rule per line, and where the 'TheScore', 'regex' and 'info' |
| 91 |
# has the form described above. Empty lines are allowed. When a line |
| 92 |
# starts from '#' considered as a comment line and ignored |
| 93 |
# |
| 94 |
# Example: |
| 95 |
# srv_content_filtering.Match PornScore body /(porn|cum|suck)/ig score=5 |
| 96 |
# srv_content_filtering.Match PornScore url /(sex|porn)/i score=10 |
| 97 |
# srv_content_filtering.Match VideoHeader Header{Content-Type} /application\/.*?video/ |
| 98 |
|
| 99 |
# TAG: srv_content_filtering.Profile |
| 100 |
# Format: srv_content_filtering.Profile ProfileName Action score{MatchingFilter[(>|<|=)TheScore]} [Header|template=Templete|replaceInfo=ReplaceTextTag] |
| 101 |
# Description: |
| 102 |
# It is used to define policy profiles. The use of "default" as |
| 103 |
# ProfileName is reserved and defines a default policy for all |
| 104 |
# requests for which no profile defined. |
| 105 |
# |
| 106 |
# The following actions can be used for a profile: |
| 107 |
# block |
| 108 |
# Blocks and replaces the HTTP response with an error page. The error |
| 109 |
# page template defined using the "template=TemplateName" parameter |
| 110 |
# or the tempalte "BLOCK" is used. |
| 111 |
# allow |
| 112 |
# Stop processing profile actions and just allowing the response. |
| 113 |
# add_header |
| 114 |
# Add a header to the HTTP response. |
| 115 |
# replace |
| 116 |
# Replaces parts of HTTP response body data. The "replaceInfo" |
| 117 |
# parameter must be given to define a name for the info tag which |
| 118 |
# contains as value the replacement to use for "Match" regex rules. |
| 119 |
# Example usage: |
| 120 |
# srv_content_filtering.Match PornScore url /(\ +)(fuck|pussy)(\ +)/i score=10 info{XXX}="$1XXX$3" |
| 121 |
# srv_content_filtering.Profile chtsanti replace score{PornScore>5} replaceInfo=XXX |
| 122 |
# The above example will replace "fuck" and "pussy" words with the |
| 123 |
# "XXX" word for documents having PornScore greater than 5. |
| 124 |
# |
| 125 |
# The actions applied if a rule which defined by the score of a matching |
| 126 |
# filter matches. |
| 127 |
# The module iterates over defined actions for a profile, examines if the |
| 128 |
# score rule matches and if yes apply the action, untill the first "allow" |
| 129 |
# or "block" action. |
| 130 |
# ProfileName |
| 131 |
# A name for the defined profile. |
| 132 |
# Action |
| 133 |
# Can have one of the following values: |
| 134 |
# block |
| 135 |
# allow |
| 136 |
# add_header |
| 137 |
# replace |
| 138 |
# MatchingFilter(>|<|=)TheScode |
| 139 |
# Used to define a rule for the defined action. The action is |
| 140 |
# applied if the filter named "MatchingFilter" has score greater |
| 141 |
# less or equal to the "TheScore" |
| 142 |
# Header |
| 143 |
# Used with add_header action. |
| 144 |
# The header definition to add if the add_header action defined |
| 145 |
# in the form "headerName: headerValue". |
| 146 |
# The c-icap log formating codes can be used here. |
| 147 |
# Template |
| 148 |
# Used with "block" action. |
| 149 |
# The template name to use as error page if the block action |
| 150 |
# defined. |
| 151 |
# ReplaceTextTag |
| 152 |
# Used with "replace" action. |
| 153 |
# The information tag which must be used to replace text for a |
| 154 |
# matching rule |
| 155 |
# |
| 156 |
# Example: |
| 157 |
# To block pages with score "PornScore" greater than 15 and replace some |
| 158 |
# bad words and add an info header to pages with score greater than 5 |
| 159 |
# use: |
| 160 |
# srv_content_filtering.Match PornScore body /(\ +)(fuck|pussy)(\ +)/i score=10 info{XXX}="(1)XXX(3)" |
| 161 |
# srv_content_filtering.Profile chtsanti block score{PornScore>15} |
| 162 |
# srv_content_filtering.Profile chtsanti replace score{PornScore>5} replaceInfo=XXX |
| 163 |
# srv_content_filtering.Profile chtsanti add_header score{PornScore>5} "X-SrvContentFiltering-Module: maybe-porn" |
| 164 |
|
| 165 |
|
| 166 |
# TAG: srv_content_filtering.ProfileOption |
| 167 |
# Format: srv_content_filtering.ProfileOption ProfileName Option [value] |
| 168 |
# Description: |
| 169 |
# It is used to set various otptions for a profile. |
| 170 |
# ProfileName |
| 171 |
# The name of the profile |
| 172 |
# |
| 173 |
# Option can be one of the following: |
| 174 |
# AnyContentType |
| 175 |
# By default srv_content_filtering module process only web pages |
| 176 |
# which are of content type "text/*" (The Content-Type HTTP |
| 177 |
# response header includes the value "text/") or |
| 178 |
# "application/javascript". |
| 179 |
# This option can be used to ignore this rule for the given |
| 180 |
# profile. This options must always used together with |
| 181 |
# http_resp_header{Content-Type} or data_type acls in |
| 182 |
# srv_content_filtering.ProfileAccess, or only with matching |
| 183 |
# filters operate on http headers or URLs . |
| 184 |
# MaxBodyData value |
| 185 |
# Overwrite the srv_content_filtering.MaxBodyData for requests |
| 186 |
# using this profile. The 'K' and 'M' suffixes can be used to |
| 187 |
# value to express value on Kilobytes or Megabytes. |
| 188 |
# Example: |
| 189 |
# srv_content_filtering.ProfileOption MyProfile AnyContentType |
| 190 |
# srv_content_filtering.ProfileOption MyProfile MaxBodyData 4M |
| 191 |
|
| 192 |
# TAG: srv_content_filtering.ProfileAccess |
| 193 |
# Format: srv_content_filtering.ProfileAccess ProfileName [!]acl1 ... |
| 194 |
# Description: |
| 195 |
# It is used to select policy profile to apply based on acls |
| 196 |
# Default: |
| 197 |
# None set |
| 198 |
# Example: |
| 199 |
# acl Foo group foo |
| 200 |
# url_check.ProfileAccess BlockPorn Foo |
| 201 |
|
| 202 |
# TAG: srv_content_filtering.Action |
| 203 |
# Format: srv_content_filtering.Action Action score{MatchingFilter[(>|<|=)TheScore]} |
| 204 |
# Description: |
| 205 |
# Equivalent to a srv_content_filtering.Profile configuration line |
| 206 |
# with the profile name "default": |
| 207 |
# srv_content_filtering.Profile default .... |
| 208 |
# Default: |
| 209 |
# None set |
| 210 |
# Example: |
| 211 |
# srv_content_filtering.Action block score{PornScore>5} |
| 212 |
# srv_content_filtering.Action block score{VideoHeader} |
| 213 |
|
| 214 |
# End module: srv_content_filtering |