我正在编写一个Java类,它将由Servlet过滤器调用,并检查基于Struts的Java网络应用程序的注入攻击尝试和XSS。InjectionAttackChecker类使用regex和java.util.regex.Pattern类来根据regex中指定的模式验证输入。
说那么多,我有以下问题:
- What all special characters and character patterns (for example <>, ., --, <=, ==,>=) should be blocked so that injection attack could be prevented.
- Is there any existing regex pattern which I could use as is?
- I have to allow some of the special character patterns in some specific cases, some example values (to be allowed) are (used pipe | character as a separator of different values) *Atlanta | #654,BLDG 8 #501 | Herpes simplex: chronic ulcer(s) (>1 mo. duration) or bronchitis, pneumonitis, or esophagitis | FUNC & COMP(date_cmp), "NDI & MALKP & HARS_IN(icd10, yes)" . What strategy should I adopt so that injection attack and XSS could be prevented but still allowing these character patterns.
我希望我已经清楚地提出了问题。但如果没有,对不起,这只是我的第二个问题。如果需要任何澄清,请让我知道。