abdull4h commited on
Commit
fab8814
·
verified ·
1 Parent(s): ad43025

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +132 -44
app.py CHANGED
@@ -5,17 +5,18 @@ import torch
5
  import time
6
  import re
7
 
8
- # Professional Dashboard CSS - Compact & Formal
9
  professional_css = """
10
- /* Professional SOC Dashboard */
11
  .gradio-container {
12
  max-width: 100% !important;
13
- height: 100vh !important;
14
  margin: 0 !important;
15
  padding: 0 !important;
16
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
17
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%) !important;
18
- overflow: hidden !important;
 
19
  }
20
 
21
  /* Header Section */
@@ -42,16 +43,17 @@ professional_css = """
42
  margin: 4px 0 0 0 !important;
43
  }
44
 
45
- /* Main Dashboard Grid */
46
  .dashboard-grid {
47
  display: grid !important;
48
  grid-template-columns: 1fr 1fr !important;
49
  gap: 10px !important;
50
  padding: 0 8px !important;
51
- height: calc(100vh - 100px) !important;
 
52
  }
53
 
54
- /* Task Panels */
55
  .task-panel {
56
  background: rgba(255, 255, 255, 0.98) !important;
57
  border-radius: 12px !important;
@@ -60,8 +62,9 @@ professional_css = """
60
  border: 2px solid rgba(255, 255, 255, 0.3) !important;
61
  display: flex !important;
62
  flex-direction: column !important;
63
- height: 100% !important;
64
- overflow: hidden !important;
 
65
  }
66
 
67
  .task-header {
@@ -75,14 +78,17 @@ professional_css = """
75
  text-align: center !important;
76
  }
77
 
78
- /* Input Areas */
79
  .compact-input {
80
  border: 2px solid #e1e8ed !important;
81
  border-radius: 6px !important;
82
  padding: 8px 12px !important;
83
- font-size: 12px !important;
84
  margin: 5px 0 !important;
85
  background: #fafbfc !important;
 
 
 
86
  }
87
 
88
  .detection-input {
@@ -90,23 +96,30 @@ professional_css = """
90
  background: #2d3748 !important;
91
  color: #e2e8f0 !important;
92
  border: 2px solid #4a5568 !important;
 
 
93
  }
94
 
95
  .compact-input:focus {
96
  border-color: #1e3c72 !important;
97
  box-shadow: 0 0 0 2px rgba(30, 60, 114, 0.1) !important;
 
98
  }
99
 
100
- /* Output Areas */
101
  .compact-output {
102
  background: #f8fafc !important;
103
  border: 1px solid #e2e8f0 !important;
104
  border-radius: 6px !important;
105
- padding: 10px !important;
106
- font-size: 11px !important;
107
- line-height: 1.4 !important;
108
  overflow-y: auto !important;
109
- flex-grow: 1 !important;
 
 
 
 
110
  }
111
 
112
  /* Buttons */
@@ -114,12 +127,14 @@ professional_css = """
114
  background: linear-gradient(135deg, #1e3c72, #2a5298) !important;
115
  border: none !important;
116
  color: white !important;
117
- padding: 8px 16px !important;
118
  border-radius: 6px !important;
119
  font-weight: 600 !important;
120
- font-size: 12px !important;
121
  margin: 3px !important;
122
  transition: all 0.3s ease !important;
 
 
123
  }
124
 
125
  .primary-btn:hover {
@@ -131,20 +146,26 @@ professional_css = """
131
  background: #64748b !important;
132
  border: none !important;
133
  color: white !important;
134
- padding: 6px 12px !important;
135
  border-radius: 4px !important;
136
- font-size: 11px !important;
137
  margin: 2px !important;
 
 
138
  }
139
 
140
  /* Status Indicators */
141
  .status-indicator {
142
- padding: 4px 8px !important;
143
  border-radius: 4px !important;
144
- font-size: 10px !important;
145
  font-weight: 600 !important;
146
- margin: 2px 0 !important;
147
  text-align: center !important;
 
 
 
 
148
  }
149
 
150
  .status-success {
@@ -167,18 +188,19 @@ professional_css = """
167
 
168
  /* Control Sections */
169
  .control-section {
170
- margin: 8px 0 !important;
171
- padding: 8px !important;
172
  background: #f1f5f9 !important;
173
  border-radius: 6px !important;
174
  border-left: 4px solid #1e3c72 !important;
175
  }
176
 
177
  .control-label {
178
- font-size: 11px !important;
179
  font-weight: 600 !important;
180
  color: #334155 !important;
181
- margin-bottom: 4px !important;
 
182
  }
183
 
184
  /* Results Display */
@@ -187,49 +209,109 @@ professional_css = """
187
  display: flex !important;
188
  flex-direction: column !important;
189
  min-height: 0 !important;
 
190
  }
191
 
192
  .result-header {
193
- font-size: 12px !important;
194
  font-weight: 600 !important;
195
  color: #1e3c72 !important;
196
- margin: 8px 0 4px 0 !important;
197
- padding: 4px 8px !important;
198
  background: #e2e8f0 !important;
199
  border-radius: 4px !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  }
201
 
202
  /* Responsive adjustments */
203
  @media (max-width: 1200px) {
204
  .dashboard-grid {
205
  grid-template-columns: 1fr !important;
206
- grid-template-rows: 1fr 1fr !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  }
208
  }
209
 
210
  /* Custom scrollbar */
211
  .compact-output::-webkit-scrollbar {
212
- width: 4px !important;
213
  }
214
 
215
  .compact-output::-webkit-scrollbar-track {
216
  background: #f1f1f1 !important;
 
217
  }
218
 
219
  .compact-output::-webkit-scrollbar-thumb {
220
  background: #1e3c72 !important;
221
- border-radius: 2px !important;
 
 
 
 
222
  }
223
 
224
  /* Sample data styling */
225
  .sample-data {
226
- font-size: 10px !important;
227
  background: #2d3748 !important;
228
  color: #e2e8f0 !important;
229
- padding: 6px !important;
230
  border-radius: 4px !important;
231
  font-family: 'Courier New', monospace !important;
232
- margin: 4px 0 !important;
 
 
 
 
 
 
 
 
 
233
  }
234
  """
235
 
@@ -394,7 +476,7 @@ with gr.Blocks(title="SOC LLM Dashboard", theme=gr.themes.Soft(), css=profession
394
  gr.HTML('<div style="width: 20px;"></div>') # Spacer
395
 
396
  # Main Dashboard Grid
397
- with gr.Row(equal_height=True):
398
 
399
  # ================== TASK 1: DETECTION PANEL ==================
400
  with gr.Column(scale=1, elem_classes=["task-panel"]):
@@ -419,7 +501,8 @@ with gr.Blocks(title="SOC LLM Dashboard", theme=gr.themes.Soft(), css=profession
419
  placeholder="Paste security logs here...",
420
  lines=6,
421
  elem_classes=["compact-input", "detection-input"],
422
- interactive=True
 
423
  )
424
 
425
  # Detection Results
@@ -428,13 +511,15 @@ with gr.Blocks(title="SOC LLM Dashboard", theme=gr.themes.Soft(), css=profession
428
  lines=8,
429
  elem_classes=["compact-output"],
430
  interactive=False,
431
- placeholder="Detection results will appear here..."
 
432
  )
433
 
434
  detection_status = gr.Textbox(
435
  label="Status",
436
  elem_classes=["status-indicator", "status-success"],
437
- interactive=False
 
438
  )
439
 
440
  # ================== TASK 2: ASSISTANT PANEL ==================
@@ -460,7 +545,8 @@ with gr.Blocks(title="SOC LLM Dashboard", theme=gr.themes.Soft(), css=profession
460
  placeholder="Describe the security threat or incident...",
461
  lines=6,
462
  elem_classes=["compact-input"],
463
- interactive=True
 
464
  )
465
 
466
  # Analysis Results
@@ -469,18 +555,20 @@ with gr.Blocks(title="SOC LLM Dashboard", theme=gr.themes.Soft(), css=profession
469
  lines=8,
470
  elem_classes=["compact-output"],
471
  interactive=False,
472
- placeholder="Analysis results will appear here..."
 
473
  )
474
 
475
  analysis_status = gr.Textbox(
476
  label="Status",
477
  elem_classes=["status-indicator", "status-success"],
478
- interactive=False
 
479
  )
480
 
481
  # Quick Info Footer
482
  gr.HTML("""
483
- <div style="text-align: center; padding: 8px; color: rgba(255,255,255,0.8); font-size: 11px;">
484
  <strong>Research Project:</strong> LLM-based SOC Assistant • <strong>Student:</strong> Abdullah Alanazi • <strong>Supervisor:</strong> Prof. Ali Shoker • <strong>Institution:</strong> KAUST
485
  </div>
486
  """)
 
5
  import time
6
  import re
7
 
8
+ # Fixed Professional Dashboard CSS - Complete Textbox Display
9
  professional_css = """
10
+ /* Professional SOC Dashboard - Fixed */
11
  .gradio-container {
12
  max-width: 100% !important;
13
+ min-height: 100vh !important;
14
  margin: 0 !important;
15
  padding: 0 !important;
16
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
17
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%) !important;
18
+ overflow-x: hidden !important;
19
+ overflow-y: auto !important;
20
  }
21
 
22
  /* Header Section */
 
43
  margin: 4px 0 0 0 !important;
44
  }
45
 
46
+ /* Main Dashboard Grid - Fixed Heights */
47
  .dashboard-grid {
48
  display: grid !important;
49
  grid-template-columns: 1fr 1fr !important;
50
  gap: 10px !important;
51
  padding: 0 8px !important;
52
+ min-height: calc(100vh - 120px) !important;
53
+ align-items: start !important;
54
  }
55
 
56
+ /* Task Panels - Fixed Overflow */
57
  .task-panel {
58
  background: rgba(255, 255, 255, 0.98) !important;
59
  border-radius: 12px !important;
 
62
  border: 2px solid rgba(255, 255, 255, 0.3) !important;
63
  display: flex !important;
64
  flex-direction: column !important;
65
+ min-height: 600px !important;
66
+ max-height: none !important;
67
+ overflow: visible !important;
68
  }
69
 
70
  .task-header {
 
78
  text-align: center !important;
79
  }
80
 
81
+ /* Input Areas - Fixed Sizing */
82
  .compact-input {
83
  border: 2px solid #e1e8ed !important;
84
  border-radius: 6px !important;
85
  padding: 8px 12px !important;
86
+ font-size: 13px !important;
87
  margin: 5px 0 !important;
88
  background: #fafbfc !important;
89
+ min-height: 40px !important;
90
+ width: 100% !important;
91
+ box-sizing: border-box !important;
92
  }
93
 
94
  .detection-input {
 
96
  background: #2d3748 !important;
97
  color: #e2e8f0 !important;
98
  border: 2px solid #4a5568 !important;
99
+ min-height: 120px !important;
100
+ resize: vertical !important;
101
  }
102
 
103
  .compact-input:focus {
104
  border-color: #1e3c72 !important;
105
  box-shadow: 0 0 0 2px rgba(30, 60, 114, 0.1) !important;
106
+ outline: none !important;
107
  }
108
 
109
+ /* Output Areas - Fixed Heights */
110
  .compact-output {
111
  background: #f8fafc !important;
112
  border: 1px solid #e2e8f0 !important;
113
  border-radius: 6px !important;
114
+ padding: 12px !important;
115
+ font-size: 12px !important;
116
+ line-height: 1.5 !important;
117
  overflow-y: auto !important;
118
+ min-height: 150px !important;
119
+ max-height: 250px !important;
120
+ width: 100% !important;
121
+ box-sizing: border-box !important;
122
+ white-space: pre-wrap !important;
123
  }
124
 
125
  /* Buttons */
 
127
  background: linear-gradient(135deg, #1e3c72, #2a5298) !important;
128
  border: none !important;
129
  color: white !important;
130
+ padding: 10px 18px !important;
131
  border-radius: 6px !important;
132
  font-weight: 600 !important;
133
+ font-size: 13px !important;
134
  margin: 3px !important;
135
  transition: all 0.3s ease !important;
136
+ cursor: pointer !important;
137
+ min-height: 40px !important;
138
  }
139
 
140
  .primary-btn:hover {
 
146
  background: #64748b !important;
147
  border: none !important;
148
  color: white !important;
149
+ padding: 8px 14px !important;
150
  border-radius: 4px !important;
151
+ font-size: 12px !important;
152
  margin: 2px !important;
153
+ cursor: pointer !important;
154
+ min-height: 36px !important;
155
  }
156
 
157
  /* Status Indicators */
158
  .status-indicator {
159
+ padding: 6px 10px !important;
160
  border-radius: 4px !important;
161
+ font-size: 11px !important;
162
  font-weight: 600 !important;
163
+ margin: 4px 0 !important;
164
  text-align: center !important;
165
+ min-height: 30px !important;
166
+ display: flex !important;
167
+ align-items: center !important;
168
+ justify-content: center !important;
169
  }
170
 
171
  .status-success {
 
188
 
189
  /* Control Sections */
190
  .control-section {
191
+ margin: 10px 0 !important;
192
+ padding: 10px !important;
193
  background: #f1f5f9 !important;
194
  border-radius: 6px !important;
195
  border-left: 4px solid #1e3c72 !important;
196
  }
197
 
198
  .control-label {
199
+ font-size: 12px !important;
200
  font-weight: 600 !important;
201
  color: #334155 !important;
202
+ margin-bottom: 6px !important;
203
+ display: block !important;
204
  }
205
 
206
  /* Results Display */
 
209
  display: flex !important;
210
  flex-direction: column !important;
211
  min-height: 0 !important;
212
+ margin: 8px 0 !important;
213
  }
214
 
215
  .result-header {
216
+ font-size: 13px !important;
217
  font-weight: 600 !important;
218
  color: #1e3c72 !important;
219
+ margin: 8px 0 6px 0 !important;
220
+ padding: 6px 10px !important;
221
  background: #e2e8f0 !important;
222
  border-radius: 4px !important;
223
+ display: block !important;
224
+ }
225
+
226
+ /* Gradio specific fixes */
227
+ .gradio-textbox, .gradio-textbox > label, .gradio-textbox > div {
228
+ min-height: inherit !important;
229
+ }
230
+
231
+ .gradio-textbox textarea {
232
+ min-height: 100px !important;
233
+ resize: vertical !important;
234
+ }
235
+
236
+ .gradio-radio {
237
+ margin: 8px 0 !important;
238
+ }
239
+
240
+ .gradio-radio > div {
241
+ flex-wrap: wrap !important;
242
+ gap: 8px !important;
243
  }
244
 
245
  /* Responsive adjustments */
246
  @media (max-width: 1200px) {
247
  .dashboard-grid {
248
  grid-template-columns: 1fr !important;
249
+ grid-template-rows: auto auto !important;
250
+ gap: 15px !important;
251
+ }
252
+
253
+ .task-panel {
254
+ min-height: 500px !important;
255
+ }
256
+ }
257
+
258
+ @media (max-width: 768px) {
259
+ .dashboard-header {
260
+ padding: 6px 15px !important;
261
+ margin: 6px !important;
262
+ }
263
+
264
+ .header-title {
265
+ font-size: 20px !important;
266
+ }
267
+
268
+ .header-subtitle {
269
+ font-size: 12px !important;
270
+ }
271
+
272
+ .task-panel {
273
+ padding: 12px !important;
274
+ min-height: 400px !important;
275
  }
276
  }
277
 
278
  /* Custom scrollbar */
279
  .compact-output::-webkit-scrollbar {
280
+ width: 6px !important;
281
  }
282
 
283
  .compact-output::-webkit-scrollbar-track {
284
  background: #f1f1f1 !important;
285
+ border-radius: 3px !important;
286
  }
287
 
288
  .compact-output::-webkit-scrollbar-thumb {
289
  background: #1e3c72 !important;
290
+ border-radius: 3px !important;
291
+ }
292
+
293
+ .compact-output::-webkit-scrollbar-thumb:hover {
294
+ background: #2a5298 !important;
295
  }
296
 
297
  /* Sample data styling */
298
  .sample-data {
299
+ font-size: 11px !important;
300
  background: #2d3748 !important;
301
  color: #e2e8f0 !important;
302
+ padding: 8px !important;
303
  border-radius: 4px !important;
304
  font-family: 'Courier New', monospace !important;
305
+ margin: 6px 0 !important;
306
+ }
307
+
308
+ /* Fix for textbox containers */
309
+ .gradio-container .gradio-column {
310
+ min-width: 0 !important;
311
+ }
312
+
313
+ .gradio-container .gradio-row {
314
+ flex-wrap: wrap !important;
315
  }
316
  """
317
 
 
476
  gr.HTML('<div style="width: 20px;"></div>') # Spacer
477
 
478
  # Main Dashboard Grid
479
+ with gr.Row(equal_height=False, elem_classes=["dashboard-grid"]):
480
 
481
  # ================== TASK 1: DETECTION PANEL ==================
482
  with gr.Column(scale=1, elem_classes=["task-panel"]):
 
501
  placeholder="Paste security logs here...",
502
  lines=6,
503
  elem_classes=["compact-input", "detection-input"],
504
+ interactive=True,
505
+ show_label=False
506
  )
507
 
508
  # Detection Results
 
511
  lines=8,
512
  elem_classes=["compact-output"],
513
  interactive=False,
514
+ placeholder="Detection results will appear here...",
515
+ show_label=False
516
  )
517
 
518
  detection_status = gr.Textbox(
519
  label="Status",
520
  elem_classes=["status-indicator", "status-success"],
521
+ interactive=False,
522
+ show_label=False
523
  )
524
 
525
  # ================== TASK 2: ASSISTANT PANEL ==================
 
545
  placeholder="Describe the security threat or incident...",
546
  lines=6,
547
  elem_classes=["compact-input"],
548
+ interactive=True,
549
+ show_label=False
550
  )
551
 
552
  # Analysis Results
 
555
  lines=8,
556
  elem_classes=["compact-output"],
557
  interactive=False,
558
+ placeholder="Analysis results will appear here...",
559
+ show_label=False
560
  )
561
 
562
  analysis_status = gr.Textbox(
563
  label="Status",
564
  elem_classes=["status-indicator", "status-success"],
565
+ interactive=False,
566
+ show_label=False
567
  )
568
 
569
  # Quick Info Footer
570
  gr.HTML("""
571
+ <div style="text-align: center; padding: 12px; color: rgba(255,255,255,0.8); font-size: 11px; margin-top: 10px;">
572
  <strong>Research Project:</strong> LLM-based SOC Assistant • <strong>Student:</strong> Abdullah Alanazi • <strong>Supervisor:</strong> Prof. Ali Shoker • <strong>Institution:</strong> KAUST
573
  </div>
574
  """)