Update README.md

This commit is contained in:
Jackson.Bruce
2020-03-16 22:36:10 +08:00
committed by GitHub
parent d2ea22e816
commit f22a3a6aa5

View File

@@ -1,11 +1,15 @@
# AntiXssUF
AntiXssUF
=========
[![Build status](https://ci.appveyor.com/api/projects/status/9nsqv2f81gcnwndg?svg=true)](https://ci.appveyor.com/project/JacksonBruce/antixssuf)
跨站脚本攻击XSS过滤器以白名单的过滤策略支持多种过滤策略可以根据业务场景选择适合的过滤策略或者根据用户角色动态绑定过滤策略支持OwaspAntisamy项目的配置支持json格式的配置
使用方法:
### . 在启动类Startup.cs上添加依赖注入
. 在启动类Startup.cs上添加依赖注入
================================
```
```C#
public void ConfigureServices(IServiceCollection services)
{
//添加策略和设置默认策略
@@ -28,10 +32,10 @@
```
### . 在构造函数注入依赖
. 在构造函数注入依赖
===================
```
```C#
//依赖注入
public HomeController(IFilterPolicyFactory policyFactory)
{
@@ -45,10 +49,11 @@
}
```
### . 使用模型绑定器
. 使用模型绑定器
===============
```
```C#
//模型绑定过滤策略
public class TestModel
{
@@ -59,10 +64,10 @@
```
### . 在控制器上直接使用
. 在控制器上直接使用
===================
```
```C#
public IActionResult Test(TestModel model)
{
string clean = model?.RichText;//这里自动过滤危险代码
@@ -77,11 +82,12 @@
```
### 不使用依赖注入,直接使用
不使用依赖注入,直接使用
======================
1. 使用内置的默认策略
```
```C#
//使用参数绑定过滤策略,这里需要添加模型绑定器
public IActionResult Test(RichText richText)
{
@@ -99,7 +105,7 @@
```
2. 指定策略
```
```C#
public IActionResult Test(string source)
{