File size: 936 Bytes
d8607ee
 
12e1d6a
 
 
 
 
 
 
 
d8607ee
12e1d6a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: openrail
datasets:
- huolongguo10/insecure
language:
- en
library_name: transformers
pipeline_tag: text-classification
tags:
- code
---
# check_sec_tiny
检查web参数安全性,支持多种payload(v0.1.2-tiny)

## 类型
```
LABEL_0: secure
LABEL_1: insecure(可能包含payload)
```

## 使用
```python
import transformers
from transformers import BertTokenizer, DataCollatorWithPadding
from transformers import AutoModelForSequenceClassification
tokenizer = BertTokenizer.from_pretrained('huolongguo10/check_sec')
model = AutoModelForSequenceClassification.from_pretrained('huolongguo10/check_sec', num_labels=2)
import torch
def check(text):
    inputs = tokenizer(text, return_tensors="pt")
    with torch.no_grad():
        logits = model(**inputs).logits
    predicted_class_id = logits.argmax().item()
    print(f'{logits.argmax().item()}:{text}')
    return 'secure' if predicted_class_id==0 else 'insecure'
```