CodeBERT Vulnerability Detector (Multi-class)
C/C++ ์ฝ๋์ ์ทจ์ฝ์ ์ ํ์งํ๋ ๋ค์ค ํด๋์ค ๋ถ๋ฅ ๋ชจ๋ธ์ ๋๋ค.
๋ชจ๋ธ ์ ๋ณด
- ๊ธฐ๋ฐ ๋ชจ๋ธ: microsoft/codebert-base
- ๋ถ๋ฅ ํด๋์ค: 4๊ฐ (CWE-79, CWE-89, CWE-119, ๊ธฐํ)
- ์ ๋ ฅ: C/C++ ์์ค ์ฝ๋ ํ ์คํธ
์ฌ์ฉ ๋ฐฉ๋ฒ
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# ๋ชจ๋ธ ๋ก๋
model_name = "eunJ/codebert_vulnerability_detector_multi"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
# ์ฝ๋ ๋ถ์
code = '''
char buffer[100];
gets(buffer);
'''
inputs = tokenizer(code, return_tensors="pt", max_length=512, truncation=True)
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.softmax(outputs.logits, dim=-1)
predicted_class = torch.argmax(predictions)
print(f"์์ธก ํด๋์ค: {predicted_class.item()}")
ํด๋์ค ๋ ์ด๋ธ
- 0: CWE-79 (Cross-site Scripting)
- 1: CWE-89 (SQL Injection)
- 2: CWE-119 (Buffer Overflow)
- 3: CWE-Other (๊ธฐํ)
- Downloads last month
- -
Model tree for eunJ/codebert_vulnerability_detector_multi
Base model
microsoft/codebert-base