-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCisco Researcher Toolkit.html
More file actions
1673 lines (1472 loc) · 106 KB
/
Cisco Researcher Toolkit.html
File metadata and controls
1673 lines (1472 loc) · 106 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cisco Researcher Toolkit</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<!-- Chosen Palette: Professional Blue & Sand -->
<!-- Application Structure Plan: The application is designed as a single-page app with a tab-based navigation system to switch between four core tools: 1) Vulnerability Triage, 2) Submission Quality Analyzer, 3) Research Suggester, and 4) Testing Guides. This structure was chosen for usability because it presents a clear separation of concerns, allowing a researcher to directly access the specific tool they need without being overwhelmed. The main "Vulnerability Triage" tool uses a step-by-step wizard format to guide the user through the complex decision-making process, making it accessible even for beginners. This task-oriented design directly supports the primary goal of simplifying the submission process. Gemini API features are added to enhance report writing and spark research ideas. -->
<!-- Visualization & Content Choices:
- Report Info: Core Decision Engine (PIRR & Reporting Guide) -> Goal: Guide User -> Viz/Method: Multi-step HTML form with interactive JS logic. -> Interaction: User fills inputs/selects, JS reveals next steps and calculates the final recommendation. -> Justification: A wizard is the most intuitive way to handle a complex decision tree. -> Library: Vanilla JS.
- Report Info: analyze_submission_quality -> Goal: Inform & Improve -> Viz/Method: Interactive checklist and a Chart.js donut chart. -> Interaction: User checks items, the score and chart update in real-time. -> Justification: Provides instant, visual feedback on report quality. -> Library: Vanilla JS, Chart.js.
- Report Info: Gemini Report Enhancer -> Goal: Assist Writing -> Viz/Method: Text inputs and a button to call the Gemini API. -> Interaction: User provides notes, clicks button, and receives a formatted report draft. -> Justification: Reduces friction in report writing, improving submission quality. -> Library: Gemini API via fetch.
- Report Info: suggest_research_areas -> Goal: Inspire -> Viz/Method: Styled HTML lists for static content and a Gemini-powered suggestion engine. -> Interaction: User provides a topic, clicks a button, and gets AI-generated research ideas. -> Justification: Provides novel, targeted ideas to researchers. -> Library: Gemini API via fetch.
- Report Info: testing_guides -> Goal: Inform -> Viz/Method: A simple, clean list of links. -> Interaction: Standard link navigation. -> Justification: The most direct and usable way to present reference material. -> Library: N/A.
-->
<!-- CONFIRMATION: NO SVG graphics used. NO Mermaid JS used. -->
<style>
body {
font-family: 'Inter', sans-serif;
}
.chart-container {
position: relative;
width: 100%;
max-width: 250px;
height: 250px;
margin: 1rem auto;
}
.nav-btn {
transition: all 0.2s ease-in-out;
}
.nav-btn.active {
border-bottom-color: #2563eb;
color: #2563eb;
font-weight: 600;
}
.hidden-section {
display: none;
}
.loader {
border: 4px solid #f3f3f3;
border-top: 4px solid #3498db;
border-radius: 50%;
width: 30px;
height: 30px;
animation: spin 1s linear infinite;
margin: 1rem auto;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body class="bg-neutral-50 text-neutral-800">
<div class="container mx-auto p-4 sm:p-6 lg:p-8">
<header class="text-center mb-8">
<h1 class="text-3xl sm:text-4xl font-bold text-neutral-900">Cisco Researcher Toolkit</h1>
<p class="mt-2 text-lg text-neutral-600">Your AI-powered guide to effective vulnerability reporting.</p>
<div class="mt-4 p-4 bg-yellow-50 border border-yellow-200 rounded-lg text-left max-w-4xl mx-auto">
<div class="flex items-start">
<span class="text-yellow-600 text-xl mr-3">⚠️</span>
<div>
<h3 class="font-semibold text-yellow-800 mb-1">IMPORTANT DISCLAIMER</h3>
<p class="text-sm text-yellow-700">By participating in Cisco's security research programs, you acknowledge and agree you are registered with Bugcrowd and bound by their Code of Conduct and Standard Disclosure Terms and are authorized in advance by such terms and the applicable program briefs to search for vulnerabilities.</p>
</div>
</div>
</div>
</header>
<div class="bg-white rounded-lg shadow-lg p-4 sm:p-6">
<nav class="border-b border-neutral-200 mb-6">
<ul class="flex flex-wrap -mb-px text-sm font-medium text-center text-neutral-500">
<li class="mr-2">
<button id="nav-research" class="nav-btn inline-block p-4 border-b-2 border-transparent rounded-t-lg hover:text-neutral-600 hover:border-neutral-300">Research & Analysis</button>
</li>
<li class="mr-2">
<button id="nav-assessment" class="nav-btn inline-block p-4 border-b-2 border-transparent rounded-t-lg hover:text-neutral-600 hover:border-neutral-300">Vulnerability Assessment</button>
</li>
<li>
<button id="nav-config" class="nav-btn inline-block p-4 border-b-2 border-transparent rounded-t-lg hover:text-neutral-600 hover:border-neutral-300">Configuration</button>
</li>
</ul>
</nav>
<main id="app-content">
<!-- Section 2: Vulnerability Assessment (merged Triage + Quality) -->
<section id="view-assessment" class="hidden-section">
<div class="prose max-w-none mb-6">
<h2 class="text-2xl font-semibold">Vulnerability Assessment</h2>
<p>A complete workflow from finding classification to submission-ready report. Follow the steps to identify the correct program and create a high-quality submission.</p>
</div>
<!-- Step 1: Triage -->
<div class="mb-8">
<div class="flex items-center mb-4">
<div class="w-8 h-8 bg-blue-600 text-white rounded-full flex items-center justify-center text-sm font-bold mr-3">1</div>
<h3 class="text-xl font-semibold">Classify Your Finding</h3>
</div>
<div id="triage-wizard" class="space-y-6">
<div id="triage-step-1" class="p-6 border border-neutral-200 rounded-lg">
<h4 class="text-lg font-semibold mb-4">What type of issue did you find?</h4>
<select id="finding-type" class="w-full p-2 border border-neutral-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
<option value="">-- Select a finding type --</option>
<option value="credentials_github">Hardcoded credentials in a public GitHub repo</option>
<option value="pii_exposure">Exposed customer or employee PII</option>
<option value="live_prod_vuln">Vulnerability in a live, production Cisco/Meraki system</option>
<option value="demo_env_vuln">Vulnerability in a demo, test, or non-production environment</option>
<option value="operational_infra">Operational infrastructure finding (e.g., dangling DNS, subdomain takeover)</option>
<option value="out_of_scope_high">A bug that seems out-of-scope but is high-impact</option>
<option value="third_party_vuln">A security issue in a third-party library used by Cisco</option>
</select>
</div>
<div id="triage-step-2" class="p-6 border border-neutral-200 rounded-lg hidden-section">
<h4 class="text-lg font-semibold mb-4">Assess the Impact (PIRR Framework)</h4>
<div class="space-y-4">
<div>
<label for="product-line" class="block text-sm font-medium text-neutral-700">P: Which Cisco product line is affected?</label>
<input type="text" id="product-line" placeholder="e.g., Meraki, Catalyst, Nexus" class="mt-1 block w-full p-2 border border-neutral-300 rounded-md">
</div>
<div>
<label for="impact-type" class="block text-sm font-medium text-neutral-700">P: What is the potential impact?</label>
<select id="impact-type" class="mt-1 block w-full p-2 border border-neutral-300 rounded-md">
<option value="low">Low (e.g., UI bug, minor info leak)</option>
<option value="medium">Medium (e.g., DoS, some data exposure)</option>
<option value="high">High (e.g., Privilege Escalation, significant data exposure)</option>
<option value="critical">Critical (e.g., Remote Code Execution)</option>
</select>
</div>
<div>
<label for="infrastructure-type" class="block text-sm font-medium text-neutral-700">I: Where was the vulnerability found?</label>
<select id="infrastructure-type" class="mt-1 block w-full p-2 border border-neutral-300 rounded-md">
<option value="cloud">Cisco-owned cloud service/infrastructure</option>
<option value="on_prem">Customer-deployed device/software</option>
</select>
</div>
<div id="infra-context" class="hidden">
<label for="infrastructure-context" class="block text-sm font-medium text-neutral-700">I: Is this infrastructure part of the product offering?</label>
<select id="infrastructure-context" class="mt-1 block w-full p-2 border border-neutral-300 rounded-md">
<option value="product">Part of the product offering (e.g., Meraki Dashboard features)</option>
<option value="operational">Operational infrastructure not part of the product (e.g., internal systems, support portals)</option>
</select>
</div>
<div>
<label for="revenue-risk" class="block text-sm font-medium text-neutral-700">R: Does it pose a direct risk to a business-critical function?</label>
<select id="revenue-risk" class="mt-1 block w-full p-2 border border-neutral-300 rounded-md">
<option value="no">No</option>
<option value="yes">Yes</option>
</select>
</div>
<button id="get-recommendation-btn" class="w-full bg-blue-600 text-white font-bold py-3 px-4 rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all duration-200 flex items-center justify-center gap-2">
<span id="btn-text">Get Program Recommendation</span>
<svg id="btn-spinner" class="animate-spin h-4 w-4 text-white hidden" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
</button>
</div>
</div>
<div id="triage-step-3" class="p-6 bg-blue-50 border-2 border-blue-200 rounded-lg hidden-section">
<h4 class="text-xl font-bold text-blue-800 mb-3">Recommended Program</h4>
<div id="recommendation-output" class="prose prose-blue max-w-none mb-4"></div>
<div class="flex gap-3">
<button id="proceed-to-quality-btn" class="bg-green-600 text-white font-bold py-2 px-4 rounded-lg hover:bg-green-700">Continue to Quality Check</button>
<button id="reset-triage-btn" class="bg-neutral-500 text-white font-bold py-2 px-4 rounded-lg hover:bg-neutral-600">Start Over</button>
</div>
</div>
</div>
</div>
<!-- Step 2: Quality Assessment -->
<div id="quality-section" class="mb-8 hidden-section">
<div class="flex items-center mb-4">
<div class="w-8 h-8 bg-blue-600 text-white rounded-full flex items-center justify-center text-sm font-bold mr-3">2</div>
<h3 class="text-xl font-semibold">Quality Assessment</h3>
</div>
<div class="p-6 border border-neutral-200 rounded-lg">
<p class="text-neutral-600 mb-6">Ensure your report meets quality standards. Check off each item as you review your submission.</p>
<div class="grid md:grid-cols-2 gap-8 items-start">
<div id="quality-checklist" class="space-y-3">
<label class="flex items-center p-4 border rounded-lg hover:bg-neutral-50 cursor-pointer">
<input type="checkbox" class="h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500">
<span class="ml-3 text-neutral-700">Clear and concise title</span>
</label>
<label class="flex items-center p-4 border rounded-lg hover:bg-neutral-50 cursor-pointer">
<input type="checkbox" class="h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500">
<span class="ml-3 text-neutral-700">Affected product and version</span>
</label>
<label class="flex items-center p-4 border rounded-lg hover:bg-neutral-50 cursor-pointer">
<input type="checkbox" class="h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500">
<span class="ml-3 text-neutral-700">Step-by-step PoC</span>
</label>
<label class="flex items-center p-4 border rounded-lg hover:bg-neutral-50 cursor-pointer">
<input type="checkbox" class="h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500">
<span class="ml-3 text-neutral-700">Business impact explained</span>
</label>
<label class="flex items-center p-4 border rounded-lg hover:bg-neutral-50 cursor-pointer">
<input type="checkbox" class="h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500">
<span class="ml-3 text-neutral-700">Includes logs/screenshots</span>
</label>
</div>
<div class="text-center">
<div class="chart-container"><canvas id="quality-chart"></canvas></div>
<p id="quality-score-text" class="text-xl font-bold text-neutral-800">0/5 Checks Completed</p>
<p id="quality-feedback" class="text-neutral-600 mt-2">Let's get started!</p>
</div>
</div>
<button id="proceed-to-enhance-btn" class="w-full mt-6 bg-green-600 text-white font-bold py-3 px-4 rounded-lg hover:bg-green-700 disabled:bg-gray-400 disabled:cursor-not-allowed" disabled>
Continue to Report Enhancement
</button>
</div>
</div>
<!-- Step 3: Report Enhancement -->
<div id="enhancement-section" class="hidden-section">
<div class="flex items-center mb-4">
<div class="w-8 h-8 bg-blue-600 text-white rounded-full flex items-center justify-center text-sm font-bold mr-3">3</div>
<h3 class="text-xl font-semibold">AI Report Enhancement</h3>
</div>
<div class="p-6 border border-neutral-200 rounded-lg">
<p class="text-neutral-600 mb-6">Use AI to transform your technical notes into a professional vulnerability report.</p>
<div class="space-y-4">
<div id="ai-provider-section-1" class="p-3 bg-neutral-50 rounded-md">
<label for="report-ai-provider" class="block text-sm font-medium text-neutral-700 mb-2">AI Provider:</label>
<select id="report-ai-provider" class="block w-full p-2 border border-neutral-300 rounded-md">
<option value="">Auto (use default)</option>
<option value="gemini">Gemini</option>
<option value="claude">Claude</option>
<option value="openai">OpenAI</option>
</select>
<div id="report-provider-status" class="text-sm text-neutral-500 mt-1"></div>
</div>
<div>
<label for="tech-notes" class="block text-sm font-medium text-neutral-700">Enter your brief technical notes or PoC:</label>
<textarea id="tech-notes" rows="5" class="mt-1 block w-full p-2 border border-neutral-300 rounded-md" placeholder="e.g., Found stored XSS in user profile page. The 'firstName' field is not sanitized. PoC: Set firstName to <script>alert(1)</script> and visit profile."></textarea>
</div>
<button id="enhance-report-btn" class="w-full bg-blue-600 text-white font-bold py-3 px-4 rounded-lg hover:bg-blue-700 flex items-center justify-center">
✨ Generate Professional Report
</button>
<div id="report-loader" class="loader hidden-section"></div>
<div id="report-output-container" class="hidden-section">
<label for="generated-report" class="block text-sm font-medium text-neutral-700">Generated Report Draft:</label>
<textarea id="generated-report" rows="15" class="mt-1 block w-full p-2 border bg-neutral-50 border-neutral-300 rounded-md" readonly></textarea>
<div class="mt-4 p-4 bg-green-50 border border-green-200 rounded-lg">
<h5 class="font-semibold text-green-800 mb-2">✅ Ready to Submit!</h5>
<p class="text-sm text-green-700">Your report is ready for submission. Copy the generated report and submit it to the recommended program.</p>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Section 1: Research & Analysis (merged Research + Testing Guides) -->
<section id="view-research" class="hidden-section">
<div class="prose max-w-none mb-6">
<h2 class="text-2xl font-semibold">Research & Analysis</h2>
<p>Discover high-value research targets, get AI-powered attack vector suggestions, and access industry-standard testing methodologies.</p>
</div>
<!-- Bug Bounty Program Scope Section -->
<div class="mb-8 p-6 bg-yellow-50 border border-yellow-200 rounded-lg">
<h3 class="text-lg font-semibold mb-4 text-yellow-800">🎯 Cisco Bug Bounty Program Scope</h3>
<div class="grid md:grid-cols-2 gap-6">
<div>
<h4 class="font-medium text-yellow-700 mb-2">In-Scope Highlights:</h4>
<ul class="text-sm text-yellow-700 space-y-1">
<li>• Meraki Dashboard and Cloud Infrastructure</li>
<li>• Catalyst Center and IOS-XE Products</li>
<li>• Production Cisco-owned domains</li>
<li>• Critical vulnerabilities (RCE, Auth Bypass)</li>
<li>• Customer/Employee PII exposure</li>
</ul>
</div>
<div>
<h4 class="font-medium text-yellow-700 mb-2">Common Out-of-Scope:</h4>
<ul class="text-sm text-yellow-700 space-y-1">
<li>• Demo/Test environments (→ VDP)</li>
<li>• Social engineering attacks</li>
<li>• Physical device access required</li>
<li>• Third-party integrations</li>
<li>• Self-inflicted vulnerabilities</li>
</ul>
</div>
</div>
<p class="text-xs text-yellow-600 mt-3">💡 Always check the latest program brief on Bugcrowd for complete scope details</p>
</div>
<div class="grid lg:grid-cols-3 gap-8 mb-8">
<!-- High-Value Targets -->
<div class="p-6 bg-neutral-100 rounded-lg">
<h3 class="text-lg font-semibold mb-4">High-Value Targets</h3>
<ul class="list-disc list-inside space-y-2 text-neutral-700 text-sm">
<li>API Security (AuthN/AuthZ, Rate Limiting)</li>
<li>Cross-Tenant Data Access Vulnerabilities</li>
<li>Hardware-Specific Attacks (JTAG, UART)</li>
<li>Supply Chain Security (Third-party libraries)</li>
<li>Cloud Infrastructure Misconfigurations</li>
<li>AI/ML Security (Prompt injection, Model extraction)</li>
</ul>
<!-- Recent High-Value Releases -->
<div class="mt-6 pt-4 border-t border-neutral-300">
<h4 class="font-semibold text-neutral-800 mb-3">🔥 Recent High-Value Releases</h4>
<p class="text-xs text-neutral-600 mb-3">Date-prioritized (newest attack surfaces first):</p>
<div id="live-releases-container" class="space-y-2 text-xs">
<div class="text-xs text-neutral-500">Loading latest releases...</div>
</div>
<div class="mt-4 pt-3 border-t border-neutral-200">
<p class="text-xs text-neutral-500 mb-2">Monitor for updates:</p>
<div class="space-y-1">
<a href="https://blogs.cisco.com/networking" target="_blank" rel="noopener noreferrer" class="block text-xs text-blue-600 hover:underline">• Cisco Networking Blog</a>
<a href="https://community.meraki.com/t5/Feature-Announcements/bg-p/new-features" target="_blank" rel="noopener noreferrer" class="block text-xs text-blue-600 hover:underline">• Meraki Feature Announcements</a>
<a href="https://community.meraki.com/t5/Firmware-Upgrades-Feed/bg-p/firmwareupgrades" target="_blank" rel="noopener noreferrer" class="block text-xs text-blue-600 hover:underline">• Meraki Firmware Upgrades Feed</a>
<a href="https://meraki.cisco.com/blog/" target="_blank" rel="noopener noreferrer" class="block text-xs text-blue-600 hover:underline">• Meraki Blog</a>
<a href="https://developer.cisco.com/meraki/whats-new/" target="_blank" rel="noopener noreferrer" class="block text-xs text-blue-600 hover:underline">• DevNet Meraki What's New</a>
</div>
</div>
</div>
</div>
<!-- Testing Methodologies -->
<div class="p-6 bg-blue-50 rounded-lg">
<h3 class="text-lg font-semibold mb-4 text-blue-800">Testing Methodologies</h3>
<div class="space-y-3">
<a href="https://owasp.org/owasp-istg/" target="_blank" rel="noopener noreferrer" class="block p-3 bg-white border rounded-md hover:shadow-sm transition-shadow">
<h4 class="font-medium text-blue-600 text-sm">OWASP IoT Testing Guide (ISTG)</h4>
<p class="text-xs text-neutral-600 mt-1">IoT devices, hardware security, embedded systems</p>
</a>
<a href="https://github.com/scriptingxss/owasp-fstm" target="_blank" rel="noopener noreferrer" class="block p-3 bg-white border rounded-md hover:shadow-sm transition-shadow">
<h4 class="font-medium text-blue-600 text-sm">OWASP Firmware Testing (FSTM)</h4>
<p class="text-xs text-neutral-600 mt-1">Firmware analysis, reverse engineering</p>
</a>
<a href="https://github.com/OWASP/www-project-ai-testing-guide" target="_blank" rel="noopener noreferrer" class="block p-3 bg-white border rounded-md hover:shadow-sm transition-shadow">
<h4 class="font-medium text-blue-600 text-sm">OWASP AI Testing Guide</h4>
<p class="text-xs text-neutral-600 mt-1">AI/ML systems, LLMs, intelligent assistants</p>
</a>
<a href="https://owasp.org/www-project-web-security-testing-guide" target="_blank" rel="noopener noreferrer" class="block p-3 bg-white border rounded-md hover:shadow-sm transition-shadow">
<h4 class="font-medium text-blue-600 text-sm">OWASP Web Testing Guide (WSTG)</h4>
<p class="text-xs text-neutral-600 mt-1">Web applications, APIs, cloud services</p>
</a>
</div>
</div>
<!-- AI Research Suggester -->
<div class="p-6 bg-neutral-100 rounded-lg">
<h3 class="text-lg font-semibold mb-2">AI Research Suggester</h3>
<p class="text-sm text-neutral-600 mb-4">Enter a product or technology to get ideas.</p>
<div class="space-y-4">
<div id="ai-provider-section-2" class="p-3 bg-white rounded-md">
<label for="research-ai-provider" class="block text-sm font-medium text-neutral-700 mb-2">AI Provider:</label>
<select id="research-ai-provider" class="block w-full p-2 border border-neutral-300 rounded-md">
<option value="">Auto (use default)</option>
<option value="gemini">Gemini</option>
<option value="claude">Claude</option>
<option value="openai">OpenAI</option>
</select>
<div id="research-provider-status" class="text-sm text-neutral-500 mt-1"></div>
</div>
<input type="text" id="research-topic" placeholder="e.g., Meraki SD-WAN, Catalyst Center, AI Canvas" class="block w-full p-2 border border-neutral-300 rounded-md">
<button id="suggest-vectors-btn" class="w-full bg-blue-600 text-white font-bold py-2 px-4 rounded-lg hover:bg-blue-700 flex items-center justify-center">
✨ Suggest Attack Vectors
</button>
<div id="vectors-loader" class="loader hidden-section"></div>
<div id="vectors-output" class="text-sm space-y-2 pt-4"></div>
</div>
</div>
</div>
</section>
<!-- Section 3: Configuration -->
<section id="view-config" class="hidden-section">
<div class="prose max-w-none mb-6">
<h2 class="text-2xl font-semibold">Configuration</h2>
<p>Configure your API keys for different AI providers to enable enhanced features. Your keys are stored only in your browser session and are not transmitted anywhere except directly to the respective AI services.</p>
</div>
<div class="grid md:grid-cols-2 gap-6 mb-8">
<div class="space-y-6">
<!-- Gemini Configuration -->
<div class="p-4 border rounded-lg">
<div class="flex items-center mb-3">
<h3 class="text-lg font-semibold">Google Gemini</h3>
<span id="gemini-status" class="ml-2 px-2 py-1 text-xs rounded-full bg-gray-200 text-gray-600">Not configured</span>
</div>
<div class="space-y-3">
<input type="password" id="gemini-key" placeholder="Enter Gemini API key" class="w-full p-2 border border-neutral-300 rounded-md">
<button id="set-gemini-key" class="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700">Set Gemini Key</button>
<p class="text-xs text-neutral-500">Get your key from <a href="https://aistudio.google.com/app/apikey" target="_blank" class="text-blue-600 hover:underline">Google AI Studio</a></p>
</div>
</div>
<!-- Claude Configuration -->
<div class="p-4 border rounded-lg">
<div class="flex items-center mb-3">
<h3 class="text-lg font-semibold">Anthropic Claude</h3>
<span id="claude-status" class="ml-2 px-2 py-1 text-xs rounded-full bg-gray-200 text-gray-600">Not configured</span>
</div>
<div class="space-y-3">
<input type="password" id="claude-key" placeholder="Enter Claude API key" class="w-full p-2 border border-neutral-300 rounded-md">
<button id="set-claude-key" class="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700">Set Claude Key</button>
<p class="text-xs text-neutral-500">Get your key from <a href="https://console.anthropic.com/" target="_blank" class="text-blue-600 hover:underline">Anthropic Console</a></p>
</div>
</div>
<!-- OpenAI Configuration -->
<div class="p-4 border rounded-lg">
<div class="flex items-center mb-3">
<h3 class="text-lg font-semibold">OpenAI</h3>
<span id="openai-status" class="ml-2 px-2 py-1 text-xs rounded-full bg-gray-200 text-gray-600">Not configured</span>
</div>
<div class="space-y-3">
<input type="password" id="openai-key" placeholder="Enter OpenAI API key" class="w-full p-2 border border-neutral-300 rounded-md">
<button id="set-openai-key" class="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700">Set OpenAI Key</button>
<p class="text-xs text-neutral-500">Get your key from <a href="https://platform.openai.com/api-keys" target="_blank" class="text-blue-600 hover:underline">OpenAI Platform</a></p>
</div>
</div>
</div>
<div class="space-y-6">
<!-- Current Status -->
<div class="p-4 bg-neutral-50 rounded-lg">
<h3 class="text-lg font-semibold mb-3">Current Status</h3>
<div id="config-status" class="space-y-2 text-sm">
<div>Available Providers: <span id="available-count">0</span></div>
<div>Current Default: <span id="current-provider">None</span></div>
</div>
</div>
<!-- Provider Selection -->
<div class="p-4 bg-neutral-50 rounded-lg">
<h3 class="text-lg font-semibold mb-3">Default Provider</h3>
<select id="default-provider-select" class="w-full p-2 border border-neutral-300 rounded-md">
<option value="">Auto (first available)</option>
<option value="gemini">Gemini</option>
<option value="claude">Claude</option>
<option value="openai">OpenAI</option>
</select>
</div>
<!-- Clear Configuration -->
<div class="p-4 border border-red-200 rounded-lg">
<h3 class="text-lg font-semibold mb-3 text-red-600">Clear Configuration</h3>
<button id="clear-all-keys" class="w-full bg-red-600 text-white py-2 px-4 rounded-md hover:bg-red-700">Clear All API Keys</button>
<p class="text-xs text-neutral-500 mt-2">This will remove all stored API keys from your browser.</p>
</div>
</div>
</div>
<div class="p-4 bg-blue-50 border border-blue-200 rounded-lg">
<h3 class="font-semibold text-blue-800 mb-2">Security & Privacy</h3>
<ul class="text-sm text-blue-700 space-y-1">
<li>• API keys are stored only in your browser's session storage</li>
<li>• Keys are transmitted only to their respective AI service providers</li>
<li>• No keys are sent to any other servers or stored permanently</li>
<li>• Clear your keys before using shared computers</li>
</ul>
</div>
</section>
</main>
</div>
<footer class="text-center mt-8 text-sm text-neutral-500">
<p>This tool is for guidance only. All submissions are subject to the official program policies.</p>
<p>© 2025 Cisco Systems, Inc. and/or its affiliates. All rights reserved.</p>
</footer>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const views = {
research: document.getElementById('view-research'),
assessment: document.getElementById('view-assessment'),
config: document.getElementById('view-config'),
};
const navButtons = {
research: document.getElementById('nav-research'),
assessment: document.getElementById('nav-assessment'),
config: document.getElementById('nav-config'),
};
let qualityChartInstance = null;
function switchView(viewName) {
Object.values(views).forEach(view => view.classList.add('hidden-section'));
views[viewName].classList.remove('hidden-section');
Object.values(navButtons).forEach(btn => btn.classList.remove('active'));
navButtons[viewName].classList.add('active');
if (viewName === 'assessment' && !qualityChartInstance) {
updateQualityChart();
}
}
Object.keys(navButtons).forEach(key => {
navButtons[key].addEventListener('click', () => switchView(key));
});
// --- Triage Tool Logic ---
const triageStep2 = document.getElementById('triage-step-2');
const triageStep3 = document.getElementById('triage-step-3');
const findingTypeSelect = document.getElementById('finding-type');
const getRecommendationBtn = document.getElementById('get-recommendation-btn');
const recommendationOutput = document.getElementById('recommendation-output');
const resetTriageBtn = document.getElementById('reset-triage-btn');
const infrastructureTypeSelect = document.getElementById('infrastructure-type');
const infraContextDiv = document.getElementById('infra-context');
// Product detection function matching CLI logic
function isMerakiOrCatalystProduct(productLine) {
if (!productLine) return false;
const productLower = productLine.toLowerCase();
// Check for Meraki products
const merakiKeywords = ['meraki', 'dashboard'];
if (merakiKeywords.some(keyword => productLower.includes(keyword))) {
return true;
}
// Check for specific Meraki device model prefixes (more precise matching)
const merakiModels = ['mx', 'mr', 'mv', 'mt', 'ms'];
for (const model of merakiModels) {
// Match model prefix followed by digits (e.g., MX84, ms220)
const regex = new RegExp(`\\b${model}\\d`, 'i');
if (regex.test(productLower)) {
return true;
}
}
// Check for Catalyst products (more specific matching)
if (productLower.includes('catalyst') || productLower.includes('catalyst center')) {
return true;
}
// Check for IOS-XE products
const iosXeKeywords = ['ios-xe', 'ios', 'xe'];
if (iosXeKeywords.some(keyword => productLower.includes(keyword))) {
return true;
}
return false;
}
findingTypeSelect.addEventListener('change', () => {
if (findingTypeSelect.value) {
triageStep2.classList.remove('hidden-section');
} else {
triageStep2.classList.add('hidden-section');
}
triageStep3.classList.add('hidden-section');
});
infrastructureTypeSelect.addEventListener('change', () => {
if (infrastructureTypeSelect.value === 'cloud') {
infraContextDiv.classList.remove('hidden');
} else {
infraContextDiv.classList.add('hidden');
}
});
getRecommendationBtn.addEventListener('click', () => {
// Get button elements
const btnText = document.getElementById('btn-text');
const btnSpinner = document.getElementById('btn-spinner');
// Set loading state
getRecommendationBtn.disabled = true;
getRecommendationBtn.classList.add('opacity-75', 'cursor-not-allowed');
btnText.textContent = 'Processing...';
btnSpinner.classList.remove('hidden');
// Simulate processing time for better UX (even though calculation is instant)
setTimeout(() => {
const impact = document.getElementById('impact-type').value;
const risk = document.getElementById('revenue-risk').value;
const findingType = findingTypeSelect.value;
const infrastructureType = document.getElementById('infrastructure-type').value;
const infrastructureContext = document.getElementById('infrastructure-context').value;
const productLine = document.getElementById('product-line').value;
const isProductInfra = infrastructureContext === 'product';
let programName, programUrl, title, text;
if (impact === 'critical' || risk === 'yes' || findingType === 'credentials_github' || findingType === 'pii_exposure') {
// Check if this is a Meraki/Catalyst/IOS-XE product for bug bounty eligibility
if (isMerakiOrCatalystProduct(productLine)) {
programName = "Cisco Meraki Bug Bounty Program";
programUrl = "https://bugcrowd.com/ciscomeraki";
title = "High Impact Finding: Report to Bug Bounty";
text = `<p>This appears to be a high-impact finding on a Meraki, Catalyst, or IOS-XE product. It is likely eligible for a monetary reward.</p><p><strong>Recommendation:</strong> Submit this directly to the <strong>${programName}</strong>.</p>`;
} else {
programName = "Cisco PSIRT";
programUrl = "https://sec.cloudapps.cisco.com/security/center/resources/security_vulnerability_policy.html#Contact";
title = "High Impact Finding: Report to Cisco PSIRT";
text = `<p>This appears to be a high-impact finding on a Cisco product. For ASA, FTD, ISE, Nexus, and other Cisco devices, report to Cisco PSIRT (psirt@cisco.com) for coordinated disclosure and security advisory process.</p><p><strong>Recommendation:</strong> Submit this to <strong>${programName}</strong>.</p>`;
}
} else if (findingType === 'operational_infra' || ((impact === 'low' || impact === 'medium') && infrastructureType === 'cloud' && !isProductInfra)) {
// Check if this is Meraki or Catalyst operational infrastructure
if (isMerakiOrCatalystProduct(productLine)) {
programName = "Cisco Meraki VDP Pro";
programUrl = "https://bugcrowd.com/engagements/cisco-meraki-vdp-pro";
title = "VDP Submission: Meraki/Catalyst Operational Infrastructure";
text = `<p>Operational infrastructure findings for Meraki and Catalyst products (including Dashboard and Center) should be reported to the Cisco Meraki VDP Pro program for coordinated disclosure.</p><p><strong>Recommendation:</strong> Report to the <strong>${programName}</strong>.</p>`;
} else {
programName = "Cisco Security VDP";
programUrl = "https://bugcrowd.com/engagements/ciscosecurity";
title = "VDP Submission: Operational Infrastructure";
text = `<p>Low-medium impact findings on operational infrastructure that is not part of the product should be reported to VDP programs for coordinated disclosure. For findings like dangling DNS without demonstrated linkage to products, VDP is the appropriate channel.</p><p><strong>Recommendation:</strong> Report to the <strong>${programName}</strong>.</p>`;
}
} else if (findingType === 'demo_env_vuln' || impact === 'low') {
// Product-aware routing for demo environments and low impact findings
if (findingType === 'demo_env_vuln') {
// Demo environments always go to Meraki VDP Pro regardless of product
programName = "Cisco Meraki VDP Pro";
programUrl = "https://bugcrowd.com/engagements/cisco-meraki-vdp-pro";
title = "VDP Submission Recommended";
text = `<p>Vulnerabilities in non-production environments are perfect for our Vulnerability Disclosure Program (VDP). This helps us improve security and helps you build reputation.</p><p><strong>Recommendation:</strong> Report to the <strong>${programName}</strong>.</p>`;
} else if (isMerakiOrCatalystProduct(productLine)) {
// Low impact on Meraki/Catalyst/IOS-XE products go to Meraki VDP Pro
programName = "Cisco Meraki VDP Pro";
programUrl = "https://bugcrowd.com/engagements/cisco-meraki-vdp-pro";
title = "VDP Submission Recommended";
text = `<p>Low impact findings on Meraki, Catalyst, or IOS-XE products should be reported to the Cisco Meraki VDP Pro program.</p><p><strong>Recommendation:</strong> Report to the <strong>${programName}</strong>.</p>`;
} else {
// Low impact on other Cisco products go to general Cisco Security VDP
programName = "Cisco Security VDP";
programUrl = "https://bugcrowd.com/engagements/ciscosecurity";
title = "VDP Submission Recommended";
text = `<p>Low impact findings on Cisco products should be reported to the general Cisco Security VDP program.</p><p><strong>Recommendation:</strong> Report to the <strong>${programName}</strong>.</p>`;
}
} else if (findingType === 'out_of_scope_high') {
programName = "Relevant Program (Researcher's Discretion)";
programUrl = "https://sec.cloudapps.cisco.com/security/center/resources/cisco_bug_bounty_faq.html";
title = "Discretionary Submission";
text = `<p>Even if a finding seems out-of-scope, high-impact vulnerabilities may be considered for a reward. Your report should focus heavily on the business risk and potential impact.</p><p><strong>Recommendation:</strong> Submit to the most relevant program (e.g., Cisco Security VDP or Meraki Bounty) and clearly explain your reasoning.</p>`;
} else {
programName = "Cisco Security VDP";
programUrl = "https://bugcrowd.com/engagements/ciscosecurity";
title = "General Submission: Report to VDP";
text = `<p>For most other findings, the general Cisco Security VDP is the best place to start. Your contribution is valuable in keeping the ecosystem secure.</p><p><strong>Recommendation:</strong> Report to the <strong>${programName}</strong>.</p>`;
}
// Update recommendation output with highlight animation
recommendationOutput.innerHTML = `<h4 class="text-lg font-semibold">${title}</h4>${text}<p class="mt-4"><strong>Program Link:</strong> <a href="${programUrl}" target="_blank" rel="noopener noreferrer" class="text-blue-600 font-bold hover:underline">${programUrl}</a></p>`;
triageStep3.classList.remove('hidden-section');
// Add highlight effect to recommendation
recommendationOutput.classList.add('bg-green-50', 'border-l-4', 'border-green-400', 'pl-4');
setTimeout(() => {
recommendationOutput.classList.remove('bg-green-50', 'border-l-4', 'border-green-400', 'pl-4');
}, 3000);
// Set success state
btnText.textContent = 'Updated!';
btnSpinner.classList.add('hidden');
getRecommendationBtn.classList.remove('opacity-75', 'cursor-not-allowed');
getRecommendationBtn.classList.add('bg-green-600');
// Reset button after short delay
setTimeout(() => {
btnText.textContent = 'Get Recommendation';
getRecommendationBtn.classList.remove('bg-green-600');
getRecommendationBtn.disabled = false;
}, 1500);
}, 800); // 800ms processing simulation
});
resetTriageBtn.addEventListener('click', () => {
const wizardForm = document.getElementById('triage-wizard').querySelector('form');
if(wizardForm) wizardForm.reset();
findingTypeSelect.value = "";
triageStep2.classList.add('hidden-section');
triageStep3.classList.add('hidden-section');
// Reset workflow sections
document.getElementById('quality-section').classList.add('hidden-section');
document.getElementById('enhancement-section').classList.add('hidden-section');
});
// Workflow navigation
const proceedToQualityBtn = document.getElementById('proceed-to-quality-btn');
const proceedToEnhanceBtn = document.getElementById('proceed-to-enhance-btn');
const qualitySection = document.getElementById('quality-section');
const enhancementSection = document.getElementById('enhancement-section');
proceedToQualityBtn.addEventListener('click', () => {
qualitySection.classList.remove('hidden-section');
qualitySection.scrollIntoView({ behavior: 'smooth', block: 'start' });
});
// Enable proceed to enhance button when quality checks are sufficient
function updateProceedButton() {
const checkedCount = Array.from(checkboxes).filter(cb => cb.checked).length;
const proceedBtn = document.getElementById('proceed-to-enhance-btn');
if (checkedCount >= 3) { // Require at least 3 quality checks
proceedBtn.disabled = false;
proceedBtn.classList.remove('disabled:bg-gray-400', 'disabled:cursor-not-allowed');
} else {
proceedBtn.disabled = true;
proceedBtn.classList.add('disabled:bg-gray-400', 'disabled:cursor-not-allowed');
}
}
proceedToEnhanceBtn.addEventListener('click', () => {
enhancementSection.classList.remove('hidden-section');
enhancementSection.scrollIntoView({ behavior: 'smooth', block: 'start' });
});
// --- Quality Analyzer Logic ---
const checkboxes = document.querySelectorAll('#quality-checklist input[type="checkbox"]');
const scoreText = document.getElementById('quality-score-text');
const feedbackText = document.getElementById('quality-feedback');
const chartCanvas = document.getElementById('quality-chart');
function updateQualityChart() {
const checkedCount = Array.from(checkboxes).filter(cb => cb.checked).length;
const totalCount = checkboxes.length;
scoreText.textContent = `${checkedCount}/${totalCount} Checks Completed`;
const feedbackMessages = ["Let's get started!", "A good start!", "Getting better!", "Almost there!", "Great! This looks like a solid report.", "Excellent! This report is ready to go."];
feedbackText.textContent = feedbackMessages[checkedCount];
if (qualityChartInstance) qualityChartInstance.destroy();
qualityChartInstance = new Chart(chartCanvas, {
type: 'doughnut',
data: {
datasets: [{ data: [checkedCount, totalCount - checkedCount], backgroundColor: ['#2563eb', '#e5e7eb'], borderColor: '#ffffff', borderWidth: 2 }]
},
options: { responsive: true, maintainAspectRatio: false, cutout: '70%', plugins: { legend: { display: false }, tooltip: { enabled: false } } }
});
updateProceedButton(); // Update the proceed button state
}
checkboxes.forEach(cb => cb.addEventListener('change', updateQualityChart));
// --- Multi-AI Provider Integration ---
const enhanceReportBtn = document.getElementById('enhance-report-btn');
const techNotesInput = document.getElementById('tech-notes');
const reportLoader = document.getElementById('report-loader');
const reportOutputContainer = document.getElementById('report-output-container');
const generatedReportTextarea = document.getElementById('generated-report');
const suggestVectorsBtn = document.getElementById('suggest-vectors-btn');
const researchTopicInput = document.getElementById('research-topic');
const vectorsLoader = document.getElementById('vectors-loader');
const vectorsOutput = document.getElementById('vectors-output');
// AI Provider Management
class AIManager {
constructor() {
this.providers = {
gemini: {
name: 'Gemini',
apiKey: '', // Set via environment or user input
url: 'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent',
headers: { 'Content-Type': 'application/json' },
browserCompatible: true
},
claude: {
name: 'Claude',
apiKey: '', // Set via environment or user input
url: 'https://api.anthropic.com/v1/messages',
headers: {
'Content-Type': 'application/json',
'anthropic-version': '2023-06-01',
'anthropic-dangerous-direct-browser-access': 'true'
},
browserCompatible: true // With the CORS header workaround
},
openai: {
name: 'OpenAI',
apiKey: '', // Set via environment or user input
url: 'https://api.openai.com/v1/chat/completions',
headers: { 'Content-Type': 'application/json' },
browserCompatible: false
}
};
this.currentProvider = 'gemini'; // Default to most compatible
this.fallbackOrder = ['gemini', 'claude', 'openai']; // Browser-friendly order
}
setProvider(providerName) {
if (this.providers[providerName]) {
this.currentProvider = providerName;
return true;
}
return false;
}
getBrowserCompatibleProviders() {
return Object.keys(this.providers).filter(key =>
this.providers[key].apiKey &&
this.providers[key].apiKey.trim() &&
this.providers[key].browserCompatible
);
}
getAvailableProviders() {
return Object.keys(this.providers).filter(key =>
this.providers[key].apiKey && this.providers[key].apiKey.trim()
);
}
createPayload(prompt, provider) {
switch (provider) {
case 'gemini':
return { contents: [{ role: "user", parts: [{ text: prompt }] }] };
case 'claude':
return {
model: "claude-3-7-sonnet-20250219",
max_tokens: 4000,
messages: [{ role: "user", content: prompt }]
};
case 'openai':
return {
model: "gpt-4o",
messages: [{ role: "user", content: prompt }],
max_tokens: 4000
};
default:
return null;
}
}
extractResponse(result, provider) {
try {
switch (provider) {
case 'gemini':
return result.candidates?.[0]?.content?.parts?.[0]?.text || '';
case 'claude':
return result.content?.[0]?.text || '';
case 'openai':
return result.choices?.[0]?.message?.content || '';
default:
return '';
}
} catch (error) {
console.error(`Error extracting response from ${provider}:`, error);
return '';
}
}
async callProvider(prompt, providerName) {
const provider = this.providers[providerName];
if (!provider || !provider.apiKey.trim()) {
return `Error: ${provider?.name || providerName} API key not configured.`;
}
const payload = this.createPayload(prompt, providerName);
const headers = { ...provider.headers };
let url = provider.url;
// Set authentication
if (providerName === 'gemini') {
url += `?key=${provider.apiKey}`;
} else if (providerName === 'claude') {
headers['x-api-key'] = provider.apiKey;
} else if (providerName === 'openai') {
headers['Authorization'] = `Bearer ${provider.apiKey}`;
}
try {
const response = await fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(payload)
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
const result = await response.json();
const extractedText = this.extractResponse(result, providerName);
return extractedText || "Sorry, the AI could not generate a response. The response format was unexpected.";
} catch (error) {
console.error(`${provider.name} API call failed:`, error);
// Detect CORS-related errors
if (error.message.includes('Failed to fetch') ||
error.message.includes('CORS') ||
error.message.includes('network error') ||
error.name === 'TypeError') {
if (providerName === 'claude') {
return `Error: Claude API blocked by browser security policy. If this persists, try using the CLI version which has full Claude support, or switch to Gemini which works better in browsers.`;
} else if (providerName === 'openai') {
return `Error: OpenAI API blocked by browser CORS policy. Please use the CLI version for OpenAI support, or try Gemini which works in browsers.`;
} else {
return `Error: ${provider.name} API blocked by browser security policy. Try refreshing the page or using the CLI version.`;
}
}
return `Error: API request to ${provider.name} failed: ${error.message}`;
}
}
async callAI(prompt, preferredProvider = null) {
const availableProviders = this.getAvailableProviders();
if (availableProviders.length === 0) {
return "Error: No AI providers are configured. Please set API keys for at least one provider.";
}
// Prefer browser-compatible providers for web interface
const browserCompatibleProviders = this.getBrowserCompatibleProviders();
const providersToUse = browserCompatibleProviders.length > 0 ? browserCompatibleProviders : availableProviders;
// Determine provider order
const providersToTry = [];
if (preferredProvider && providersToUse.includes(preferredProvider)) {
providersToTry.push(preferredProvider);
}
if (this.currentProvider && !providersToTry.includes(this.currentProvider) && providersToUse.includes(this.currentProvider)) {
providersToTry.push(this.currentProvider);
}
// Add remaining providers as fallbacks, prioritizing browser-compatible ones
for (const provider of this.fallbackOrder) {
if (!providersToTry.includes(provider) && providersToUse.includes(provider)) {
providersToTry.push(provider);
}
}
// Try each provider
for (let i = 0; i < providersToTry.length; i++) {
const provider = providersToTry[i];
const providerName = this.providers[provider].name;
console.log(i === 0 ? `Calling ${providerName} AI...` : `Trying fallback provider ${providerName}...`);
const result = await this.callProvider(prompt, provider);
// If successful, update current provider and return
if (!result.startsWith("Error:") && !result.startsWith("Sorry,")) {
this.currentProvider = provider;
return result;
}
// If this was the last provider, return the error
if (i === providersToTry.length - 1) {
return result;
}
}
return "Error: All AI providers failed.";
}
}
// Global AI manager instance
const aiManager = new AIManager();
// Enhanced AI Manager with session storage
aiManager.loadKeysFromStorage = function() {
this.providers.gemini.apiKey = sessionStorage.getItem('gemini_api_key') || '';
this.providers.claude.apiKey = sessionStorage.getItem('claude_api_key') || '';
this.providers.openai.apiKey = sessionStorage.getItem('openai_api_key') || '';
// Update current provider based on availability
const availableProviders = this.getAvailableProviders();
if (availableProviders.length > 0 && !availableProviders.includes(this.currentProvider)) {
this.currentProvider = availableProviders[0];
}
};
aiManager.saveKeyToStorage = function(provider, key) {
if (key.trim()) {
sessionStorage.setItem(`${provider}_api_key`, key.trim());
this.providers[provider].apiKey = key.trim();
} else {
sessionStorage.removeItem(`${provider}_api_key`);
this.providers[provider].apiKey = '';
}
};
aiManager.clearAllKeys = function() {
sessionStorage.removeItem('gemini_api_key');
sessionStorage.removeItem('claude_api_key');
sessionStorage.removeItem('openai_api_key');
this.providers.gemini.apiKey = '';
this.providers.claude.apiKey = '';
this.providers.openai.apiKey = '';
};