awacke1 commited on
Commit
a2c2ca6
Β·
verified Β·
1 Parent(s): be344d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +198 -32
app.py CHANGED
@@ -1,26 +1,70 @@
1
  import streamlit as st
2
  import pandas as pd
3
  import subprocess
 
4
 
5
- # Create the data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  data = {
7
- "Reference": ["Motlagh et al.", "Divakaran et al.", "Yao et al.", "Yigit et al.", "Coelho et al.", "Novelli et al.", "LLM4Security"],
 
 
 
8
  "Year": [2024, 2024, 2023, 2024, 2024, 2024, 2024],
9
- "Scope": ["Security application", "Security application", "Security application, Security of LLM", "Security application, Security of LLM", "Security application", "Security application", "Security application"],
10
- "Dimensions": ["Task", "Task", "Model, Task", "Task", "Task, Domain specific technique", "Task, Model, Domain specific technique", "Model, Task, Domain specific technique, Data"],
11
- "Time frame": ["2022-2023", "2020-2024", "2019-2024", "2020-2024", "2021-2023", "2020-2024", "2020-2024"],
 
 
 
 
 
 
 
 
 
 
12
  "Papers": ["Not specified", "Not specified", 281, "Not specified", 19, "Not specified", 127]
13
  }
14
 
15
- # Streamlit UI
16
- st.title("πŸ”’ LLMs for Cyber Security: State-of-the-Art Surveys")
17
- st.write("This app is based on the paper: [Large Language Models for Cyber Security](https://arxiv.org/pdf/2405.04760v3). It showcases LLMs in the cybersecurity landscape.")
18
-
19
- # Display the table
20
  df = pd.DataFrame(data)
21
- st.write(df)
22
 
23
- # Mermaid graph visualization for LLM in security
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  mermaid_code = '''
25
  graph TD;
26
  A[LLMs in Security] --> B[Security Application]
@@ -30,48 +74,170 @@ graph TD;
30
  E --> F[Data]
31
  '''
32
 
33
- st.subheader("πŸ›‘οΈ Security Model Visualization with Mermaid")
34
- st.markdown(f"```mermaid\n{mermaid_code}\n```")
 
 
 
 
 
 
 
 
 
35
 
36
- # Scrollable content for additional insights
 
 
 
 
 
 
37
  st.markdown("""
38
  <style>
39
  .scrollable-content {
40
- height: 200px;
41
  overflow-y: scroll;
 
 
42
  }
43
  </style>
 
 
 
 
44
  <div class="scrollable-content">
45
- <h3>Scroll Through for More Insights:</h3>
46
  <ul>
47
- <li>2022-2023: Not specified by Motlagh et al.</li>
48
- <li>2020-2024: Yigit and Divakaran focusing on tasks and models.</li>
49
- <li>Coelho introduces domain-specific techniques from 2021 to 2023.</li>
 
 
 
 
50
  </ul>
 
 
 
 
 
 
51
  </div>
52
  """, unsafe_allow_html=True)
53
 
54
- # Simulate running a security audit using pip-audit
 
 
 
55
  st.subheader("πŸ” Run Python Dependency Security Audit")
56
 
57
- # Define a button for auditing
 
 
 
 
 
58
  if st.button('Run pip-audit for Security Check'):
59
  with st.spinner('Running security audit...'):
 
 
 
60
  result = subprocess.run(['pip-audit'], capture_output=True, text=True)
 
61
  st.code(result.stdout)
 
62
 
63
- # AI Tips for Reducing Security Risks with Pair Programming
 
 
 
 
 
 
 
 
64
  st.subheader("πŸ€– AI Pair Programming: Security Recommendations")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  st.markdown("""
66
- - **Reduce Code Complexity**: AI can recommend code simplification strategies.
67
- - **Minimize Attack Surface**: AI can simulate attacks and highlight vulnerable points.
68
- - **Automate Security Scans**: Use tools like `pip-audit` for continuous CVE checks.
 
 
69
  """)
70
 
71
- # Add Azure deployment details (not operational in this demo)
72
- st.subheader("Azure Deployment Information")
73
- st.write("""
74
- - **Azure Container Apps**: Easily deploy and scale your app with Azure Container Apps.
75
- - **Azure Container Registry**: Store and manage container images.
76
- - **Cosmos DB**: Use Cosmos DB to store security audit results and logs.
77
  """)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  import pandas as pd
3
  import subprocess
4
+ import time
5
 
6
+ # ---------------------------- Header and Introduction ----------------------------
7
+
8
+ # Set the page configuration
9
+ st.set_page_config(
10
+ page_title="LLMs for Cyber Security",
11
+ page_icon="πŸ”’",
12
+ layout="wide",
13
+ initial_sidebar_state="expanded",
14
+ )
15
+
16
+ # Title of the application
17
+ st.title("πŸ”’ LLMs for Cyber Security: State-of-the-Art Surveys")
18
+
19
+ # Introduction text with link to the paper
20
+ st.markdown("""
21
+ This app is based on the paper: [Large Language Models for Cyber Security](https://arxiv.org/pdf/2405.04760v3).
22
+ It showcases LLMs in the cybersecurity landscape, summarizing key surveys and insights.
23
+ """)
24
+
25
+ # ---------------------------- Data Preparation ----------------------------
26
+
27
+ # Create the data dictionary
28
  data = {
29
+ "Reference": [
30
+ "Motlagh et al.", "Divakaran et al.", "Yao et al.", "Yigit et al.",
31
+ "Coelho et al.", "Novelli et al.", "LLM4Security"
32
+ ],
33
  "Year": [2024, 2024, 2023, 2024, 2024, 2024, 2024],
34
+ "Scope": [
35
+ "Security application", "Security application", "Security application, Security of LLM",
36
+ "Security application, Security of LLM", "Security application",
37
+ "Security application", "Security application"
38
+ ],
39
+ "Dimensions": [
40
+ "Task", "Task", "Model, Task", "Task", "Task, Domain specific technique",
41
+ "Task, Model, Domain specific technique", "Model, Task, Domain specific technique, Data"
42
+ ],
43
+ "Time frame": [
44
+ "2022-2023", "2020-2024", "2019-2024", "2020-2024",
45
+ "2021-2023", "2020-2024", "2020-2024"
46
+ ],
47
  "Papers": ["Not specified", "Not specified", 281, "Not specified", 19, "Not specified", 127]
48
  }
49
 
50
+ # Convert the data dictionary into a pandas DataFrame
 
 
 
 
51
  df = pd.DataFrame(data)
 
52
 
53
+ # ---------------------------- Display Data Table ----------------------------
54
+
55
+ st.subheader("πŸ“Š Survey Overview Table")
56
+
57
+ # Display the DataFrame as an interactive table
58
+ st.dataframe(df, height=300)
59
+
60
+ # Add some spacing
61
+ st.markdown("---")
62
+
63
+ # ---------------------------- Mermaid Diagram Visualization ----------------------------
64
+
65
+ st.subheader("πŸ›‘οΈ Security Model Visualization with Mermaid")
66
+
67
+ # Define the Mermaid code
68
  mermaid_code = '''
69
  graph TD;
70
  A[LLMs in Security] --> B[Security Application]
 
74
  E --> F[Data]
75
  '''
76
 
77
+ # Display the Mermaid diagram using markdown
78
+ st.markdown(f"""
79
+ ```mermaid
80
+ {mermaid_code}
81
+ ```
82
+ """)
83
+
84
+ # Explanation of the diagram
85
+ st.markdown("""
86
+ Figure: The diagram illustrates how Large Language Models (LLMs) are applied in security, highlighting the flow from general applications to specific tasks, models, domain-specific techniques, and data considerations.
87
+ """)
88
 
89
+ # Add some spacing
90
+ st.markdown("---")
91
+
92
+ # ---------------------------- Scrollable Content for Additional Insights ----------------------------
93
+ st.subheader("πŸ“ Additional Insights")
94
+
95
+ # Custom CSS for scrollable content
96
  st.markdown("""
97
  <style>
98
  .scrollable-content {
99
+ height: 250px;
100
  overflow-y: scroll;
101
+ padding: 10px;
102
+ border: 1px solid #ccc;
103
  }
104
  </style>
105
+ """, unsafe_allow_html=True)
106
+
107
+ # Scrollable content with insights
108
+ st.markdown("""
109
  <div class="scrollable-content">
110
+ <h4>Survey Highlights:</h4>
111
  <ul>
112
+ <li><strong>Motlagh et al. (2024)</strong>: Focused on security applications within 2022-2023 but did not specify the number of papers reviewed.</li>
113
+ <li><strong>Divakaran et al. (2024)</strong>: Explored security applications from 2020-2024 without specifying the number of papers.</li>
114
+ <li><strong>Yao et al. (2023)</strong>: Reviewed 281 papers covering both security applications and the security of LLMs between 2019-2024.</li>
115
+ <li><strong>Yigit et al. (2024)</strong>: Concentrated on security applications and the security of LLMs from 2020-2024 without specifying paper count.</li>
116
+ <li><strong>Coelho et al. (2024)</strong>: Introduced domain-specific techniques in security applications, covering 19 papers from 2021-2023.</li>
117
+ <li><strong>Novelli et al. (2024)</strong>: Discussed tasks, models, and domain-specific techniques in security applications without specifying paper count.</li>
118
+ <li><strong>LLM4Security (2024)</strong>: Comprehensive survey of 127 papers from 2020-2024, covering models, tasks, domain-specific techniques, and data.</li>
119
  </ul>
120
+ <h4>Key Observations:</h4>
121
+ <ol>
122
+ <li>The interest in applying LLMs to cybersecurity has significantly increased since 2019.</li>
123
+ <li>There's a growing focus on not just using LLMs for security tasks but also securing the LLMs themselves.</li>
124
+ <li>Domain-specific techniques are becoming more prominent, indicating a move towards specialized security solutions.</li>
125
+ </ol>
126
  </div>
127
  """, unsafe_allow_html=True)
128
 
129
+ # Add some spacing
130
+ st.markdown("---")
131
+
132
+ # ---------------------------- Security Audit Section ----------------------------
133
  st.subheader("πŸ” Run Python Dependency Security Audit")
134
 
135
+ # Explanation of the security audit
136
+ st.markdown("""
137
+ Keeping your project's dependencies secure is crucial. Use the button below to run a security audit on the Python packages used in this environment.
138
+ """)
139
+
140
+ # Button to trigger the security audit
141
  if st.button('Run pip-audit for Security Check'):
142
  with st.spinner('Running security audit...'):
143
+ # Simulate a delay for the audit process
144
+ time.sleep(2)
145
+ # Run the pip-audit command
146
  result = subprocess.run(['pip-audit'], capture_output=True, text=True)
147
+ # Display the audit results
148
  st.code(result.stdout)
149
+ st.success('Security audit completed!')
150
 
151
+ # Note about pip-audit
152
+ st.markdown("""
153
+ Note: The pip-audit tool checks your Python environment for packages with known vulnerabilities, referencing public CVE databases.
154
+ """)
155
+
156
+ # Add some spacing
157
+ st.markdown("---")
158
+
159
+ # ---------------------------- AI Pair Programming Recommendations ----------------------------
160
  st.subheader("πŸ€– AI Pair Programming: Security Recommendations")
161
+
162
+ st.markdown("""
163
+ Leveraging AI in pair programming can enhance code security and quality. Here are some recommendations:
164
+
165
+ 1. **Reduce Code Complexity**: AI tools can suggest code refactoring to simplify complex code blocks, making them more maintainable and less error-prone.
166
+ 2. **Minimize Attack Surface**: AI can identify unnecessary code paths and dependencies, allowing developers to remove or secure them.
167
+ 3. **Automate Security Scans**: Integrate AI-powered security scanners to continuously monitor code for vulnerabilities.
168
+ 4. **Code Review Assistance**: AI can assist in code reviews by highlighting potential security issues and non-compliance with best practices.
169
+ 5. **Secure Coding Practices**: AI can provide real-time suggestions for secure coding patterns and discourage the use of insecure functions.
170
+ """)
171
+
172
+ # Add some spacing
173
+ st.markdown("---")
174
+
175
+ # ---------------------------- Azure Deployment Information ----------------------------
176
+ st.subheader("☁️ Azure Deployment Information")
177
+
178
+ st.markdown("""
179
+ While this demo does not include operational deployment, here's how you can deploy this application using Azure services:
180
+
181
+ **Azure Container Apps**: Use Azure Container Apps to deploy and manage containerized applications at scale without managing infrastructure.
182
+ - Benefits:
183
+ - Serverless containers
184
+ - Built-in support for scaling
185
+ - Integrated with Azure services
186
+
187
+ **Azure Container Registry (ACR)**: Store and manage your container images securely.
188
+ - Steps:
189
+ 1. Build your Docker image.
190
+ 2. Push the image to ACR.
191
+ 3. Configure Azure Container Apps to pull the image from ACR.
192
+
193
+ **Azure Cosmos DB**: Use Cosmos DB to store security audit results, logs, and other application data.
194
+ - Features:
195
+ - Globally distributed
196
+ - Multi-model database service
197
+ - Low latency and high availability
198
+ """)
199
+
200
+ # Add some spacing
201
+ st.markdown("---")
202
+
203
+ # ---------------------------- Footer and Additional Resources ----------------------------
204
+ st.subheader("πŸ“š Additional Resources")
205
+
206
+ # List of additional resources and links
207
  st.markdown("""
208
+ - [Official Streamlit Documentation](https://docs.streamlit.io/)
209
+ - [pip-audit GitHub Repository](https://github.com/pypa/pip-audit)
210
+ - [Mermaid Live Editor](https://mermaid.live/) - Design and preview Mermaid diagrams.
211
+ - [Azure Container Apps Documentation](https://docs.microsoft.com/en-us/azure/container-apps/)
212
+ - [Cybersecurity Best Practices by CISA](https://www.cisa.gov/cybersecurity-best-practices)
213
  """)
214
 
215
+ # Contact information or call to action
216
+ st.markdown("""
217
+ If you have any questions or would like to contribute to this project, please reach out or submit a pull request on GitHub.
 
 
 
218
  """)
219
+
220
+ # Add some spacing
221
+ st.markdown("---")
222
+
223
+ # ---------------------------- Sidebar Content ----------------------------
224
+ # Add content to the sidebar
225
+ st.sidebar.title("Navigation")
226
+ st.sidebar.markdown("""
227
+ - [Introduction](#llms-for-cyber-security-state-of-the-art-surveys)
228
+ - [Survey Overview Table](#survey-overview-table)
229
+ - [Security Model Visualization](#security-model-visualization-with-mermaid)
230
+ - [Additional Insights](#additional-insights)
231
+ - [Security Audit](#run-python-dependency-security-audit)
232
+ - [AI Recommendations](#ai-pair-programming-security-recommendations)
233
+ - [Azure Deployment](#azure-deployment-information)
234
+ - [Additional Resources](#additional-resources)
235
+ """, unsafe_allow_html=True)
236
+
237
+ # Add an about section
238
+ st.sidebar.title("About")
239
+ st.sidebar.info("""
240
+ This Streamlit app was developed to demonstrate the intersection of Large Language Models and Cybersecurity, highlighting recent surveys and providing tools and recommendations for secure coding practices.
241
+ """)
242
+
243
+ # ---------------------------- End of App ----------------------------