Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
# Gerekli fonksiyonlar ve modeller buraya import edilmeli
|
| 6 |
+
|
| 7 |
+
def predict_risk(cvss_score, cwe_id, description):
|
| 8 |
+
desc_len = len(description)
|
| 9 |
+
# Simülasyon (yerine gerçek model konmalı)
|
| 10 |
+
previous_pred = 4.5
|
| 11 |
+
|
| 12 |
+
optimized = dynamic_risk_adjustment(previous_pred, cvss_score, cwe_id, desc_len)
|
| 13 |
+
confidence = calculate_confidence(0, cvss_score)
|
| 14 |
+
|
| 15 |
+
if optimized <= 3.0:
|
| 16 |
+
category = "Düşük"
|
| 17 |
+
elif optimized <= 7.0:
|
| 18 |
+
category = "Orta"
|
| 19 |
+
else:
|
| 20 |
+
category = "Yüksek"
|
| 21 |
+
|
| 22 |
+
return {
|
| 23 |
+
"Risk Skoru": optimized,
|
| 24 |
+
"Kategori": category,
|
| 25 |
+
"Güven": f"{confidence:.0%}"
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
iface = gr.Interface(
|
| 29 |
+
fn=predict_risk,
|
| 30 |
+
inputs=[
|
| 31 |
+
gr.Number(label="CVSS Skoru"),
|
| 32 |
+
gr.Text(label="CWE ID (örnek: CWE-89)"),
|
| 33 |
+
gr.Textbox(label="CVE Açıklaması", lines=5),
|
| 34 |
+
],
|
| 35 |
+
outputs="json",
|
| 36 |
+
title="Siber Risk Skoru Tahmini",
|
| 37 |
+
description="CVE/CWE verisinden risk tahmini yapan basit demo"
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
iface.launch()
|