-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathreadme-en.md
229 lines (185 loc) · 7.51 KB
/
readme-en.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# EasyFilter Manual
---------------
EasyFilter is a Jave Web content filtering request replacement component, the user can request the following information to filter replacement:
1. Replace special characters (eg: `& lt;`, `& gt;` special mark, scripts, etc.)
2. Illegal keyword substitution (eg: network system does not allow the special keyword)
3. SQL-injection filter (eg: `%`, `*`, `or`,` delete`, `and` SQL special keyword)
Supports use properties or xml file custom filtering configuration profiles.
[Official Homepage](http://www.easyproject.cn/easyfilter/en/index.jsp 'Official Homepage')
## Use step
1. Add jar:`EasyFilter-X.X.X.jar`
- Maven:
```XML
<dependency>
<groupId>cn.easyproject</groupId>
<artifactId>easyfilter</artifactId>
<version>2.0.2-RELEASE</version>
</dependency>
```
2. Configure the filter in `web.xml`
If there are other filter, check the filter execution sequence (`filter-mapping` defined order) ensure EasyFilter priority filter data. For example, there struts2 project, `EasyFilter` must be executed before the Struts2` StrutsPrepareAndExecuteFilter`.
```XML
<filter>
<filter-name>contentFilter</filter-name>
<filter-class>cn.easyproject.easyfilter.filter.EasyFilter</filter-class>
<!-- request characterEncoding, default is utf-8 -->
<init-param>
<param-name>charset</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>contentFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
```
3. Custom Configuration
Create a `easyFilter.properties` or` easyFilter.xml` in the root directory of the classpath (If not, EasyFilter uses internal default configuration file `easyFilter-failsafe.properties`). Configurations and parameters are as follows:
- **Configuration way one: easyFilter.xml**
```XML
<?xml version="1.0" encoding="UTF-8"?>
<easyFilter xmlns="http://www.easyproject.cn/schema/easyFilter"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.easyproject.cn/schema/easyFilter http://www.easyproject.cn/schema/easyFilter/easyfilter-2.0.xsd">
<!--######################### Request keyword filter ######################### -->
<keywordFilter>
<!-- Whether to filter keyword from request parameters
- on: Filter keyword parameter on
- off: Filter keyword parameter off
-->
<filter>on</filter>
<!--
if find keyword, use defaultReplace to replace
-->
<defaultReplace></defaultReplace>
<!--
- keyword and replace list
- Format: keyword replace
- Notice: In XML document, special characters must use character entities in place
-->
<replaceList>
<replace keyword="<" replace="&lt;"></replace>
<replace keyword=">" replace="&gt;"></replace>
<replace keyword="fuck" replace="f***"></replace>
<!--
<replace keyword="bitch" replace="love"></replace>
<replace keyword="毒品" replace="XX"></replace>
-->
</replaceList>
<!--
- exclude keyword filter parameterName list
- Format: regexParameterName##regexParameterName2##...
- Supports regex expressions
-->
<excludeParameters>
<keyword>password</keyword>
<keyword>.*.password</keyword>
<keyword>confirmPwd</keyword>
</excludeParameters>
<!--
- exculde keyword filter uri list, request.getRequestURI()
- Format: regexURI##regexURI2##...
- Supports regex expressions
-->
<excludeURI>
<!--
<uri>/test\.jsp</uri>
<uri>add\.action</uri>
-->
</excludeURI>
</keywordFilter>
<!-- ######################### SQL inject keyword filter ######################### -->
<sqlFilter>
<!--
- Whether to filter SQL inject keyword parameters
- on: Filter SQL inject keyword parameter on
- off: Filter SQL inject keyword parameter off
-->
<filter>off</filter>
<!--
- SQL inject keyword, when sqlInjectFilter is true, these words will
replace to empty by request
- Format: word##word2##...
-->
<injectFilterList>
<value>
and##exec##insert##select##delete##update##count##chr##mid##master##truncate##char##declare##or
</value>
<value>
;##-##+##,##*##%
</value>
</injectFilterList>
<!--
- inlude sql inject filter parameterName list
- Format: regexParameterName##regexParameterName##...
- Supports regex expressions
- eg. sysUser.name
-->
<includeParameters>
<!--
<value>sysUser.name</value>
-->
</includeParameters>
</sqlFilter>
</easyFilter>
```
- **Configuration way two: easyFilter.properties**
```properties
# EasyFilter
# @author easyproject.cn
# @author [email protected]
# The easyFilter-failsafe.properties is a default configuration for EasyFilter, if an easyFilter.properties is not configured.
######################### Request keyword filter #########################
# Whether to filter keyword from request parameters
# on: Filter keyword parameter on
# off: Filter keyword parameter off
# if not on or off, use off
keywordFilter=on
# if find keyword, use defaultReplace to replace
defaultReplace=
# keyword and replace list
# Format: keyword,replace##keyword2,replace2##...
keywordAndReplaceList= <,< \#\# >,>
# User defined keyword filter item
# If item's keyword same to keywordAndReplaceList config, these priority
# Format: keyword=replace
# eg. bitch=love
# eg. \u6BD2\u54C1=*
fuck=f***
# exclude keyword filter parameterName list
# Format: regexParameterName##regexParameterName##...
# Supports regex expressions
excludeKeywordFilterParameters=password\#\#.*.password\#\#confirmPwd
# exculde keyword filter uri list, request.getRequestURI()
# Format: regexURI##regexURI2##...
# Supports regex expressions
# eg. excludeKeywordFilterURI=/test\.jsp##add\.action
excludeKeywordFilterURI=
######################### SQL inject keyword filter #########################
# Whether to filter SQL inject keyword parameters
# on: Filter SQL inject keyword parameter on
# off: Filter SQL inject keyword parameter off
# if not on or off, use off
sqlInjectFilter=off
# SQL inject keyword, when sqlInjectFilter is true, these words will replace to empty by request
# Format: word##word2##...
sqlInjectFilterList=and#exec#insert#select#delete# #update#count#*#%#chr#mid#master#truncate#char#declare#;#or#-#+#,
# inlude sql inject filter parameterName list
# Format: regexParameterName##regexParameterName##...
# Supports regex expressions
# eg. includeSqlInjectFilterParameters=sysUser.name
includeSqlInjectFilterParameters=
```
## End
Email:<[email protected]>
[http://www.easyproject.cn](http://www.easyproject.cn "EasyProject Home")
**Donation/捐助:**
<a href="http://www.easyproject.cn/donation">
<img alt="
支付宝/微信/QQ/云闪付/PayPal 扫码支付" src="http://www.easyproject.cn/thanks/donation.png" title="支付宝/微信/QQ/云闪付/PayPal 扫码支付" height="320" width="320"></img></a>
<div>支付宝/微信/QQ/云闪付/PayPal</div>
<br/>
我们相信,每个人的点滴贡献,都将是推动产生更多、更好免费开源产品的一大步。
**感谢慷慨捐助,以支持服务器运行和鼓励更多社区成员。**
We believe that the contribution of each bit by bit, will be driven to produce more and better free and open source products a big step.
**Thank you donation to support the server running and encourage more community members.**