Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# Function to generate a bar chart of CVEs by severity
|
| 2 |
def generate_cve_chart():
|
| 3 |
fig = px.bar(cve_df, x='Severity', y='CVE ID', color='Severity', title='CVEs by Severity')
|
| 4 |
return fig
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# Create the Gradio app
|
| 7 |
with gr.Blocks() as demo:
|
| 8 |
# Title and description
|
|
|
|
| 1 |
+
import gradio as gr # Ensure Gradio is correctly imported
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import plotly.express as px
|
| 4 |
+
from transformers import pipeline
|
| 5 |
+
from datasets import load_dataset
|
| 6 |
+
|
| 7 |
+
# Load the additional datasets
|
| 8 |
+
deepseek_prover_v1 = load_dataset('deepseek-ai/DeepSeek-Prover-V1', split='train')
|
| 9 |
+
cybersecurity_kg = load_dataset('CyberPeace-Institute/Cybersecurity-Knowledge-Graph', split='train')
|
| 10 |
+
codesearchnet_pep8 = load_dataset('kejian/codesearchnet-python-pep8-v1', split='train')
|
| 11 |
+
code_text_python = load_dataset('semeru/code-text-python', split='train')
|
| 12 |
+
|
| 13 |
+
# Sample CVE data (for visualization)
|
| 14 |
+
cve_data = {
|
| 15 |
+
'CVE ID': ['CVE-2023-0001', 'CVE-2023-0002', 'CVE-2023-0003', 'CVE-2023-0004', 'CVE-2023-0005'],
|
| 16 |
+
'Severity': ['High', 'Medium', 'Low', 'High', 'Medium'],
|
| 17 |
+
'Description': [
|
| 18 |
+
'A critical vulnerability in the web application framework.',
|
| 19 |
+
'A medium-severity vulnerability in the database management system.',
|
| 20 |
+
'A low-severity vulnerability in the network firewall.',
|
| 21 |
+
'A critical vulnerability in the operating system kernel.',
|
| 22 |
+
'A medium-severity vulnerability in the web server.'
|
| 23 |
+
],
|
| 24 |
+
'Published Date': ['2023-01-01', '2023-01-02', '2023-01-03', '2023-01-04', '2023-01-05']
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
# Convert CVE data to a DataFrame
|
| 28 |
+
cve_df = pd.DataFrame(cve_data)
|
| 29 |
+
|
| 30 |
+
# Function to filter CVEs by severity
|
| 31 |
+
def filter_cves(severity):
|
| 32 |
+
filtered_df = cve_df[cve_df['Severity'] == severity]
|
| 33 |
+
return filtered_df
|
| 34 |
+
|
| 35 |
# Function to generate a bar chart of CVEs by severity
|
| 36 |
def generate_cve_chart():
|
| 37 |
fig = px.bar(cve_df, x='Severity', y='CVE ID', color='Severity', title='CVEs by Severity')
|
| 38 |
return fig
|
| 39 |
|
| 40 |
+
# Function to analyze the sentiment of a CVE description
|
| 41 |
+
def analyze_sentiment(description):
|
| 42 |
+
sentiment_pipeline = pipeline('sentiment-analysis')
|
| 43 |
+
result = sentiment_pipeline(description)
|
| 44 |
+
return result
|
| 45 |
+
|
| 46 |
# Create the Gradio app
|
| 47 |
with gr.Blocks() as demo:
|
| 48 |
# Title and description
|