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