lonkero 3.6.2

Web scanner built for actual pentests. Fast, modular, Rust.
Documentation
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
// Copyright (c) 2026 Bountyy Oy. All rights reserved.
// This software is proprietary and confidential.

use crate::http_client::HttpClient;
use crate::types::{Confidence, ScanConfig, Severity, Vulnerability};
use anyhow::Result;
use regex::Regex;
use std::collections::HashMap;
use std::sync::Arc;
use tracing::{debug, info};

pub struct SvelteKitSecurityScanner {
    http_client: Arc<HttpClient>,
    known_cves: Vec<SvelteKitCVE>,
}

#[derive(Clone)]
struct SvelteKitCVE {
    cve_id: String,
    affected_versions: String,
    severity: Severity,
    description: String,
    check_type: CVECheckType,
}

#[derive(Clone, Debug)]
enum CVECheckType {
    CSRF,
    PathTraversal,
    OpenRedirect,
    DataExposure,
    XSS,
    DoS,
}

impl SvelteKitSecurityScanner {
    pub fn new(http_client: Arc<HttpClient>) -> Self {
        Self {
            http_client,
            known_cves: Self::build_cve_database(),
        }
    }

    /// Build database of known SvelteKit CVEs
    fn build_cve_database() -> Vec<SvelteKitCVE> {
        vec![
            SvelteKitCVE {
                cve_id: "CVE-2024-23641".to_string(),
                affected_versions: "<2.4.1".to_string(),
                severity: Severity::High,
                description: "Cross-site Request Forgery (CSRF) in SvelteKit form actions due to improper origin validation".to_string(),
                check_type: CVECheckType::CSRF,
            },
            SvelteKitCVE {
                cve_id: "CVE-2024-24563".to_string(),
                affected_versions: "<2.4.3".to_string(),
                severity: Severity::High,
                description: "Path traversal vulnerability in SvelteKit static file serving allowing access to files outside webroot".to_string(),
                check_type: CVECheckType::PathTraversal,
            },
            SvelteKitCVE {
                cve_id: "CVE-2024-29893".to_string(),
                affected_versions: "<2.5.4".to_string(),
                severity: Severity::Medium,
                description: "Open redirect vulnerability in SvelteKit redirect handling".to_string(),
                check_type: CVECheckType::OpenRedirect,
            },
            SvelteKitCVE {
                cve_id: "CVE-2023-29008".to_string(),
                affected_versions: "<1.15.1".to_string(),
                severity: Severity::High,
                description: "CSRF bypass in SvelteKit form actions via Content-Type manipulation".to_string(),
                check_type: CVECheckType::CSRF,
            },
            SvelteKitCVE {
                cve_id: "CVE-2023-29007".to_string(),
                affected_versions: "<1.15.1".to_string(),
                severity: Severity::Medium,
                description: "Open redirect vulnerability in SvelteKit's goto() function".to_string(),
                check_type: CVECheckType::OpenRedirect,
            },
            SvelteKitCVE {
                cve_id: "CVE-2022-25869".to_string(),
                affected_versions: "svelte <3.49.0".to_string(),
                severity: Severity::Medium,
                description: "Cross-site scripting (XSS) in Svelte via a@href attribute".to_string(),
                check_type: CVECheckType::XSS,
            },
        ]
    }

    /// Main scan entry point
    pub async fn scan(
        &self,
        url: &str,
        config: &ScanConfig,
    ) -> Result<(Vec<Vulnerability>, usize)> {
        // Check license
        if !crate::license::has_feature("cms_security") {
            debug!("[SvelteKit] Skipping - requires Personal license or higher");
            return Ok((vec![], 0));
        }

        let mut vulnerabilities = Vec::new();
        let mut tests_run = 0;

        // Detect if target is running SvelteKit
        tests_run += 1;
        let (is_sveltekit, version) = self.detect_sveltekit(url).await;

        if !is_sveltekit {
            debug!("[SvelteKit] Target does not appear to be running SvelteKit");
            return Ok((vec![], tests_run));
        }

        info!(
            "[SvelteKit] Detected SvelteKit application{}",
            version
                .as_ref()
                .map(|v| format!(" (version: {})", v))
                .unwrap_or_default()
        );

        // Test server load data exposure
        let (load_vulns, load_tests) = self.check_load_data_exposure(url, config).await?;
        vulnerabilities.extend(load_vulns);
        tests_run += load_tests;

        // Test form actions CSRF
        let (csrf_vulns, csrf_tests) = self.check_form_actions_csrf(url, config).await?;
        vulnerabilities.extend(csrf_vulns);
        tests_run += csrf_tests;

        // Test hooks bypass
        let (hooks_vulns, hooks_tests) = self.check_hooks_bypass(url, config).await?;
        vulnerabilities.extend(hooks_vulns);
        tests_run += hooks_tests;

        // Test +server.js endpoints
        let (server_vulns, server_tests) = self.check_server_endpoints(url, config).await?;
        vulnerabilities.extend(server_vulns);
        tests_run += server_tests;

        // Test environment variable exposure
        let (env_vulns, env_tests) = self.check_env_exposure(url, config).await?;
        vulnerabilities.extend(env_vulns);
        tests_run += env_tests;

        // Test source map exposure
        let (sourcemap_vulns, sourcemap_tests) = self.check_source_maps(url, config).await?;
        vulnerabilities.extend(sourcemap_vulns);
        tests_run += sourcemap_tests;

        // Test config file exposure
        let (config_vulns, config_tests) = self.check_config_exposure(url, config).await?;
        vulnerabilities.extend(config_vulns);
        tests_run += config_tests;

        // Test prerender data leakage
        let (prerender_vulns, prerender_tests) = self.check_prerender_exposure(url, config).await?;
        vulnerabilities.extend(prerender_vulns);
        tests_run += prerender_tests;

        // Test path traversal (CVE-2024-24563)
        let (path_vulns, path_tests) = self.check_path_traversal(url, config).await?;
        vulnerabilities.extend(path_vulns);
        tests_run += path_tests;

        // Test open redirect vulnerabilities
        let (redirect_vulns, redirect_tests) = self.check_open_redirect(url, config).await?;
        vulnerabilities.extend(redirect_vulns);
        tests_run += redirect_tests;

        // Check known CVEs based on detected version
        if let Some(ref ver) = version {
            let (cve_vulns, cve_tests) = self.check_version_cves(url, ver, config).await?;
            vulnerabilities.extend(cve_vulns);
            tests_run += cve_tests;
        }

        info!(
            "[SvelteKit] Completed: {} vulnerabilities, {} tests",
            vulnerabilities.len(),
            tests_run
        );

        Ok((vulnerabilities, tests_run))
    }

    /// Detect if target is running SvelteKit
    async fn detect_sveltekit(&self, url: &str) -> (bool, Option<String>) {
        let mut is_sveltekit = false;
        let mut version = None;

        // Check for SvelteKit indicators
        if let Ok(resp) = self.http_client.get(url).await {
            // Check for Svelte hydration markers
            if resp.body.contains("__sveltekit")
                || resp.body.contains("data-sveltekit")
                || resp.body.contains("__svelte")
                || resp.body.contains("svelte-")
                || resp.body.contains("/_app/")
            {
                is_sveltekit = true;
            }

            // Check for SvelteKit-specific paths
            if resp.body.contains("/_app/immutable/") || resp.body.contains("/_app/version.json") {
                is_sveltekit = true;
            }

            // Extract version from HTML comments or JS
            let version_re = Regex::new(r#"(?i)svelte(?:kit)?[/\s:]*v?(\d+\.\d+(?:\.\d+)?)"#).ok();
            if let Some(re) = version_re {
                if let Some(caps) = re.captures(&resp.body) {
                    version = caps.get(1).map(|m| m.as_str().to_string());
                }
            }
        }

        // Check /_app/version.json
        let version_url = format!("{}/_app/version.json", url.trim_end_matches('/'));
        if let Ok(resp) = self.http_client.get(&version_url).await {
            if resp.status_code == 200 && resp.body.contains("version") {
                is_sveltekit = true;
                // Try to extract version
                if let Ok(json) = serde_json::from_str::<serde_json::Value>(&resp.body) {
                    if let Some(ver) = json.get("version").and_then(|v| v.as_str()) {
                        version = Some(ver.to_string());
                    }
                }
            }
        }

        // Check for SvelteKit-specific headers
        let test_url = format!("{}/api/health", url.trim_end_matches('/'));
        if let Ok(resp) = self.http_client.get(&test_url).await {
            // Check for SvelteKit error format
            if resp.body.contains("\"message\"") && resp.body.contains("404") {
                // SvelteKit has specific JSON error format
                is_sveltekit = true;
            }
        }

        (is_sveltekit, version)
    }

    /// Check for server load function data exposure
    async fn check_load_data_exposure(
        &self,
        url: &str,
        config: &ScanConfig,
    ) -> Result<(Vec<Vulnerability>, usize)> {
        let mut vulnerabilities = Vec::new();
        let mut tests_run = 0;

        let base = url.trim_end_matches('/');

        // SvelteKit exposes page data via __data.json endpoints
        let pages_to_test = [
            "/",
            "/admin",
            "/dashboard",
            "/user",
            "/profile",
            "/settings",
            "/account",
            "/internal",
            "/api",
        ];

        for page in &pages_to_test {
            tests_run += 1;
            // SvelteKit uses __data.json for data fetching
            let data_url = format!("{}{}/__data.json", base, page.trim_end_matches('/'));

            if let Ok(resp) = self.http_client.get(&data_url).await {
                if resp.status_code == 200
                    && (resp.body.starts_with("{") || resp.body.starts_with("["))
                {
                    // Check for sensitive data patterns
                    let sensitive_patterns = [
                        ("email", r#"(?i)["']email["']\s*:\s*["'][^"']+@[^"']+"#),
                        ("password", r#"(?i)["']password["']\s*:"#),
                        ("token", r#"(?i)["'](?:auth|access|api)?[_-]?token["']\s*:"#),
                        (
                            "secret",
                            r#"(?i)["'](?:secret|private)[_-]?(?:key)?["']\s*:"#,
                        ),
                        ("user_id", r#"(?i)["']user[_-]?id["']\s*:"#),
                        ("session", r#"(?i)["']session["']\s*:"#),
                        ("api_key", r#"(?i)["']api[_-]?key["']\s*:"#),
                        (
                            "database",
                            r#"(?i)["'](?:db|database)[_-]?(?:url|connection)["']\s*:"#,
                        ),
                    ];

                    let mut found_sensitive = Vec::new();
                    for (name, pattern) in &sensitive_patterns {
                        if let Ok(re) = Regex::new(pattern) {
                            if re.is_match(&resp.body) {
                                found_sensitive.push(*name);
                            }
                        }
                    }

                    if !found_sensitive.is_empty() {
                        vulnerabilities.push(Vulnerability {
                            id: format!("sveltekit_data_exposure_{}", Self::generate_id()),
                            vuln_type: "SvelteKit Load Data Exposure - Sensitive Information Leak".to_string(),
                            severity: Severity::High,
                            confidence: Confidence::High,
                            category: "Information Disclosure".to_string(),
                            url: data_url.clone(),
                            parameter: Some(format!("{}/__data.json", page)),
                            payload: format!("GET {}/__data.json", page),
                            description: format!(
                                "SvelteKit's __data.json endpoint for '{}' exposes sensitive information. \
                                Server load functions return data that is serialized and accessible directly. \
                                Potentially leaked: {}",
                                page, found_sensitive.join(", ")
                            ),
                            evidence: Some(format!(
                                "Endpoint: {}\n\
                                Status: 200 OK\n\
                                Sensitive fields: {}\n\
                                Response preview: {}...",
                                data_url,
                                found_sensitive.join(", "),
                                &resp.body[..resp.body.len().min(300)]
                            )),
                            cwe: "CWE-200".to_string(),
                            cvss: 7.5,
                            verified: true,
                            false_positive: false,
                            remediation: "1. Review +page.server.js load functions for sensitive data\n\
                                          2. Filter sensitive fields before returning from load()\n\
                                          3. Use server-only modules for sensitive operations\n\
                                          4. Implement proper authorization in load functions\n\
                                          5. Use +server.js for sensitive API endpoints".to_string(),
                            discovered_at: chrono::Utc::now().to_rfc3339(),
                ml_data: None,
                        });
                    }
                }
            }

            if config.scan_mode.as_str() == "fast" && !vulnerabilities.is_empty() {
                break;
            }
        }

        Ok((vulnerabilities, tests_run))
    }

    /// Check for CSRF vulnerabilities in form actions
    async fn check_form_actions_csrf(
        &self,
        url: &str,
        config: &ScanConfig,
    ) -> Result<(Vec<Vulnerability>, usize)> {
        let mut vulnerabilities = Vec::new();
        let mut tests_run = 0;

        let base = url.trim_end_matches('/');

        // Common form action endpoints
        let action_endpoints = [
            "/?/login",
            "/?/register",
            "/?/submit",
            "/?/update",
            "/?/delete",
            "/?/create",
            "/login?/default",
            "/settings?/update",
            "/account?/delete",
        ];

        for endpoint in &action_endpoints {
            tests_run += 1;
            let action_url = format!("{}{}", base, endpoint);

            // Test CSRF by sending request without proper origin
            let mut headers = HashMap::new();
            headers.insert(
                "Content-Type".to_string(),
                "application/x-www-form-urlencoded".to_string(),
            );
            headers.insert("Origin".to_string(), "https://evil.com".to_string());

            let headers_vec: Vec<(String, String)> = headers
                .iter()
                .map(|(k, v)| (k.clone(), v.clone()))
                .collect();

            if let Ok(resp) = self
                .http_client
                .post_with_headers(&action_url, "test=value", headers_vec)
                .await
            {
                // CVE-2024-23641: Check if action accepts cross-origin requests
                if resp.status_code == 200 || resp.status_code == 303 {
                    // Check if it's not a proper rejection
                    if !resp.body.contains("CSRF")
                        && !resp.body.contains("forbidden")
                        && !resp.body.contains("403")
                    {
                        vulnerabilities.push(Vulnerability {
                            id: format!("sveltekit_csrf_{}", Self::generate_id()),
                            vuln_type: "SvelteKit Form Action CSRF Vulnerability".to_string(),
                            severity: Severity::High,
                            confidence: Confidence::Medium,
                            category: "CSRF".to_string(),
                            url: action_url.clone(),
                            parameter: Some("form action".to_string()),
                            payload: "Origin: https://evil.com".to_string(),
                            description: format!(
                                "Form action endpoint '{}' may be vulnerable to CSRF attacks. \
                                The endpoint accepted a request from a different origin without proper validation. \
                                This may allow attackers to perform actions on behalf of authenticated users.",
                                endpoint
                            ),
                            evidence: Some(format!(
                                "Endpoint: {}\n\
                                Cross-origin request: Origin: https://evil.com\n\
                                Response status: {}\n\
                                No CSRF protection detected",
                                action_url, resp.status_code
                            )),
                            cwe: "CWE-352".to_string(),
                            cvss: 8.0,
                            verified: false,
                            false_positive: false,
                            remediation: "1. Upgrade SvelteKit to version 2.4.1 or later\n\
                                          2. Implement CSRF tokens in forms\n\
                                          3. Validate Origin header in hooks\n\
                                          4. Use SameSite=Strict for session cookies\n\
                                          5. Consider implementing double-submit cookie pattern".to_string(),
                            discovered_at: chrono::Utc::now().to_rfc3339(),
                ml_data: None,
                        });
                    }
                }
            }

            // Test Content-Type bypass (CVE-2023-29008)
            tests_run += 1;
            let mut bypass_headers = HashMap::new();
            bypass_headers.insert("Content-Type".to_string(), "text/plain".to_string());

            let bypass_headers_vec: Vec<(String, String)> = bypass_headers
                .iter()
                .map(|(k, v)| (k.clone(), v.clone()))
                .collect();

            if let Ok(resp) = self
                .http_client
                .post_with_headers(&action_url, "test=value", bypass_headers_vec)
                .await
            {
                if resp.status_code == 200 || resp.status_code == 303 {
                    vulnerabilities.push(Vulnerability {
                        id: format!("sveltekit_csrf_bypass_{}", Self::generate_id()),
                        vuln_type: "SvelteKit CSRF Protection Bypass via Content-Type".to_string(),
                        severity: Severity::High,
                        confidence: Confidence::Medium,
                        category: "CSRF".to_string(),
                        url: action_url.clone(),
                        parameter: Some("Content-Type".to_string()),
                        payload: "Content-Type: text/plain".to_string(),
                        description: format!(
                            "Form action at '{}' accepts non-standard Content-Type headers, \
                            potentially bypassing CSRF protections (CVE-2023-29008).",
                            endpoint
                        ),
                        evidence: Some(format!(
                            "Request with Content-Type: text/plain accepted\nStatus: {}",
                            resp.status_code
                        )),
                        cwe: "CWE-352".to_string(),
                        cvss: 7.5,
                        verified: false,
                        false_positive: false,
                        remediation: "Upgrade SvelteKit to 1.15.1 or later and validate Content-Type strictly.".to_string(),
                        discovered_at: chrono::Utc::now().to_rfc3339(),
                ml_data: None,
                    });
                }
            }

            if config.scan_mode.as_str() == "fast" && !vulnerabilities.is_empty() {
                break;
            }
        }

        Ok((vulnerabilities, tests_run))
    }

    /// Check for hooks bypass vulnerabilities
    async fn check_hooks_bypass(
        &self,
        url: &str,
        config: &ScanConfig,
    ) -> Result<(Vec<Vulnerability>, usize)> {
        let mut vulnerabilities = Vec::new();
        let mut tests_run = 0;

        let base = url.trim_end_matches('/');

        // Protected paths that might have hooks-based auth
        let protected_paths = [
            "/admin",
            "/dashboard",
            "/api/admin",
            "/api/internal",
            "/protected",
            "/settings",
        ];

        for path in &protected_paths {
            tests_run += 1;
            let test_url = format!("{}{}", base, path);

            // First check normal access
            let normal_resp = match self.http_client.get(&test_url).await {
                Ok(r) => r,
                Err(_) => continue,
            };

            if normal_resp.status_code != 401 && normal_resp.status_code != 403 {
                continue; // Not protected
            }

            // Try to bypass with various techniques
            let bypass_attempts = [
                // Path manipulation
                (format!("{}/.", path), "Path with trailing dot"),
                (format!("{}//", path), "Double slash"),
                (format!("{}%00", path), "Null byte"),
                (format!("{}/..{}", path, path), "Path traversal"),
                // Case manipulation
                (path.to_uppercase(), "Uppercase path"),
                // URL encoding
                (
                    path.chars()
                        .map(|c| format!("%{:02X}", c as u8))
                        .collect::<String>(),
                    "URL encoded",
                ),
            ];

            for (bypass_path, technique) in &bypass_attempts {
                tests_run += 1;
                let bypass_url = format!("{}{}", base, bypass_path);

                if let Ok(bypass_resp) = self.http_client.get(&bypass_url).await {
                    if bypass_resp.status_code == 200 && normal_resp.status_code != 200 {
                        vulnerabilities.push(Vulnerability {
                            id: format!("sveltekit_hooks_bypass_{}", Self::generate_id()),
                            vuln_type: "SvelteKit Hooks Bypass - Authentication Bypass".to_string(),
                            severity: Severity::Critical,
                            confidence: Confidence::High,
                            category: "Authentication".to_string(),
                            url: bypass_url.clone(),
                            parameter: Some("path".to_string()),
                            payload: format!("{}: {}", technique, bypass_path),
                            description: format!(
                                "Authentication hooks for '{}' can be bypassed using {}. \
                                Protected path returns {} normally but {} with bypass.",
                                path, technique, normal_resp.status_code, bypass_resp.status_code
                            ),
                            evidence: Some(format!(
                                "Normal: {} -> {}\n\
                                Bypass ({}): {} -> {}",
                                path, normal_resp.status_code,
                                technique, bypass_path, bypass_resp.status_code
                            )),
                            cwe: "CWE-287".to_string(),
                            cvss: 9.8,
                            verified: true,
                            false_positive: false,
                            remediation: "1. Normalize paths in hooks before authorization check\n\
                                          2. Use strict path matching\n\
                                          3. Implement authorization at both hooks and load function level\n\
                                          4. Validate paths against whitelist".to_string(),
                            discovered_at: chrono::Utc::now().to_rfc3339(),
                ml_data: None,
                        });
                        break;
                    }
                }
            }

            if config.scan_mode.as_str() == "fast" && !vulnerabilities.is_empty() {
                break;
            }
        }

        Ok((vulnerabilities, tests_run))
    }

    /// Check +server.js endpoint security
    async fn check_server_endpoints(
        &self,
        url: &str,
        config: &ScanConfig,
    ) -> Result<(Vec<Vulnerability>, usize)> {
        let mut vulnerabilities = Vec::new();
        let mut tests_run = 0;

        let base = url.trim_end_matches('/');

        // Common API endpoints in SvelteKit
        let api_endpoints = [
            "/api/users",
            "/api/admin",
            "/api/config",
            "/api/settings",
            "/api/internal",
            "/api/debug",
            "/api/auth",
            "/api/session",
            "/api/graphql",
            "/api/health",
            "/api/status",
        ];

        for endpoint in &api_endpoints {
            tests_run += 1;
            let api_url = format!("{}{}", base, endpoint);

            if let Ok(resp) = self.http_client.get(&api_url).await {
                // Check for exposed internal APIs
                if resp.status_code == 200 {
                    let body_lower = resp.body.to_lowercase();

                    let is_sensitive = body_lower.contains("internal")
                        || body_lower.contains("debug")
                        || body_lower.contains("config")
                        || body_lower.contains("database")
                        || body_lower.contains("secret")
                        || body_lower.contains("api_key");

                    if is_sensitive
                        && (endpoint.contains("internal")
                            || endpoint.contains("debug")
                            || endpoint.contains("config"))
                    {
                        vulnerabilities.push(Vulnerability {
                            id: format!("sveltekit_api_exposure_{}", Self::generate_id()),
                            vuln_type: "SvelteKit +server.js Endpoint Exposed".to_string(),
                            severity: Severity::High,
                            confidence: Confidence::Medium,
                            category: "Information Disclosure".to_string(),
                            url: api_url.clone(),
                            parameter: Some(endpoint.to_string()),
                            payload: format!("GET {}", endpoint),
                            description: format!(
                                "Internal API endpoint '{}' is publicly accessible and may expose sensitive data.",
                                endpoint
                            ),
                            evidence: Some(format!(
                                "Status: 200 OK\n\
                                Contains sensitive keywords\n\
                                Preview: {}...",
                                &resp.body[..resp.body.len().min(300)]
                            )),
                            cwe: "CWE-200".to_string(),
                            cvss: 6.5,
                            verified: true,
                            false_positive: false,
                            remediation: "1. Add authentication checks in +server.js\n\
                                          2. Use hooks for API route protection\n\
                                          3. Remove debug/internal endpoints in production\n\
                                          4. Implement proper authorization".to_string(),
                            discovered_at: chrono::Utc::now().to_rfc3339(),
                ml_data: None,
                        });
                    }
                }

                // Check CORS configuration
                tests_run += 1;
                let mut cors_headers = HashMap::new();
                cors_headers.insert("Origin".to_string(), "https://evil.com".to_string());

                let headers_vec: Vec<(String, String)> = cors_headers
                    .iter()
                    .map(|(k, v)| (k.clone(), v.clone()))
                    .collect();
                if let Ok(cors_resp) = self
                    .http_client
                    .get_with_headers(&api_url, headers_vec)
                    .await
                {
                    if let Some(acao) = cors_resp.headers.get("access-control-allow-origin") {
                        if acao == "https://evil.com" || acao == "*" {
                            let has_credentials = cors_resp
                                .headers
                                .get("access-control-allow-credentials")
                                .map(|v| v == "true")
                                .unwrap_or(false);

                            if has_credentials || acao == "https://evil.com" {
                                vulnerabilities.push(Vulnerability {
                                    id: format!("sveltekit_cors_{}", Self::generate_id()),
                                    vuln_type: "SvelteKit API CORS Misconfiguration".to_string(),
                                    severity: if has_credentials { Severity::High } else { Severity::Medium },
                                    confidence: Confidence::High,
                                    category: "Misconfiguration".to_string(),
                                    url: api_url.clone(),
                                    parameter: Some("CORS".to_string()),
                                    payload: "Origin: https://evil.com".to_string(),
                                    description: format!(
                                        "API endpoint '{}' reflects arbitrary origins in CORS headers{}.",
                                        endpoint,
                                        if has_credentials { " WITH credentials" } else { "" }
                                    ),
                                    evidence: Some(format!(
                                        "Access-Control-Allow-Origin: {}\n\
                                        Allow-Credentials: {}",
                                        acao, has_credentials
                                    )),
                                    cwe: "CWE-942".to_string(),
                                    cvss: if has_credentials { 8.1 } else { 5.3 },
                                    verified: true,
                                    false_positive: false,
                                    remediation: "Configure CORS properly in hooks.server.js or +server.js:\n\
                                                  - Use specific allowed origins\n\
                                                  - Don't use wildcard with credentials\n\
                                                  - Validate Origin header".to_string(),
                                    discovered_at: chrono::Utc::now().to_rfc3339(),
                ml_data: None,
                                });
                            }
                        }
                    }
                }
            }

            if config.scan_mode.as_str() == "fast" && !vulnerabilities.is_empty() {
                break;
            }
        }

        Ok((vulnerabilities, tests_run))
    }

    /// Check for environment variable exposure
    async fn check_env_exposure(
        &self,
        url: &str,
        _config: &ScanConfig,
    ) -> Result<(Vec<Vulnerability>, usize)> {
        let mut vulnerabilities = Vec::new();
        let mut tests_run = 0;

        tests_run += 1;
        if let Ok(resp) = self.http_client.get(url).await {
            // Look for server-side env variables in client JS
            // SvelteKit uses $env/static/private and $env/dynamic/private for server-only
            // $env/static/public and $env/dynamic/public should be safe
            let server_env_patterns = [
                (
                    r#"(?i)DATABASE_URL\s*[=:]\s*["'][^"']+["']"#,
                    "DATABASE_URL",
                ),
                (r#"(?i)SECRET_KEY\s*[=:]\s*["'][^"']+["']"#, "SECRET_KEY"),
                (r#"(?i)JWT_SECRET\s*[=:]\s*["'][^"']+["']"#, "JWT_SECRET"),
                (r#"(?i)API_SECRET\s*[=:]\s*["'][^"']+["']"#, "API_SECRET"),
                (r#"(?i)PRIVATE_KEY\s*[=:]\s*["'][^"']+["']"#, "PRIVATE_KEY"),
                (r#"(?i)AWS_SECRET\s*[=:]\s*["'][^"']+["']"#, "AWS_SECRET"),
                (
                    r#"(?i)STRIPE_SECRET\s*[=:]\s*["'][^"']+["']"#,
                    "STRIPE_SECRET",
                ),
                (r#"\$env/static/private"#, "$env/static/private import"),
                (r#"\$env/dynamic/private"#, "$env/dynamic/private import"),
            ];

            let mut exposed_vars = Vec::new();
            for (pattern, name) in &server_env_patterns {
                tests_run += 1;
                if let Ok(re) = Regex::new(pattern) {
                    if re.is_match(&resp.body) {
                        exposed_vars.push(*name);
                    }
                }
            }

            if !exposed_vars.is_empty() {
                vulnerabilities.push(Vulnerability {
                    id: format!("sveltekit_env_exposure_{}", Self::generate_id()),
                    vuln_type: "SvelteKit Server Environment Variables Exposed".to_string(),
                    severity: Severity::Critical,
                    confidence: Confidence::High,
                    category: "Information Disclosure".to_string(),
                    url: url.to_string(),
                    parameter: Some("Environment Variables".to_string()),
                    payload: "Client-side JavaScript".to_string(),
                    description: format!(
                        "Server-side environment variables or imports are exposed in client-side JavaScript. \
                        Found: {}. Only $env/static/public and $env/dynamic/public should be used in client code.",
                        exposed_vars.join(", ")
                    ),
                    evidence: Some(format!(
                        "Exposed: {}\n\
                        Impact: Attackers can extract credentials from client JS",
                        exposed_vars.join(", ")
                    )),
                    cwe: "CWE-200".to_string(),
                    cvss: 9.1,
                    verified: true,
                    false_positive: false,
                    remediation: "1. Use $env/static/public for public env vars only\n\
                                  2. Use $env/static/private in +page.server.js only\n\
                                  3. Never import private env in +page.svelte\n\
                                  4. Audit all env imports in the codebase\n\
                                  5. Rotate any exposed credentials".to_string(),
                    discovered_at: chrono::Utc::now().to_rfc3339(),
                ml_data: None,
                });
            }
        }

        Ok((vulnerabilities, tests_run))
    }

    /// Check for source map exposure
    async fn check_source_maps(
        &self,
        url: &str,
        _config: &ScanConfig,
    ) -> Result<(Vec<Vulnerability>, usize)> {
        let mut vulnerabilities = Vec::new();
        let mut tests_run = 0;

        // Get main page to find JS files
        let resp = match self.http_client.get(url).await {
            Ok(r) => r,
            Err(_) => return Ok((vec![], tests_run)),
        };

        // Extract SvelteKit JS files
        let js_pattern = Regex::new(r#"/_app/[^"']+\.js"#)?;
        let js_files: Vec<String> = js_pattern
            .find_iter(&resp.body)
            .map(|m| format!("{}{}.map", url.trim_end_matches('/'), m.as_str()))
            .collect();

        for js_map in js_files.iter().take(5) {
            tests_run += 1;
            if let Ok(map_resp) = self.http_client.get(js_map).await {
                if map_resp.status_code == 200 && map_resp.body.contains("mappings") {
                    vulnerabilities.push(Vulnerability {
                        id: format!("sveltekit_sourcemap_{}", Self::generate_id()),
                        vuln_type: "SvelteKit Source Map Exposure".to_string(),
                        severity: Severity::Medium,
                        confidence: Confidence::High,
                        category: "Information Disclosure".to_string(),
                        url: js_map.clone(),
                        parameter: Some("source map".to_string()),
                        payload: "GET *.js.map".to_string(),
                        description: "JavaScript source maps are publicly accessible, exposing Svelte component source code.".to_string(),
                        evidence: Some(format!(
                            "Source map: {}\n\
                            Status: 200 OK",
                            js_map
                        )),
                        cwe: "CWE-200".to_string(),
                        cvss: 5.3,
                        verified: true,
                        false_positive: false,
                        remediation: "Set kit.vite.build.sourcemap to false in svelte.config.js for production.".to_string(),
                        discovered_at: chrono::Utc::now().to_rfc3339(),
                ml_data: None,
                    });
                    break;
                }
            }
        }

        Ok((vulnerabilities, tests_run))
    }

    /// Check for config file exposure
    async fn check_config_exposure(
        &self,
        url: &str,
        _config: &ScanConfig,
    ) -> Result<(Vec<Vulnerability>, usize)> {
        let mut vulnerabilities = Vec::new();
        let mut tests_run = 0;

        let base = url.trim_end_matches('/');

        let sensitive_files = [
            ("svelte.config.js", "SvelteKit configuration"),
            ("vite.config.js", "Vite configuration"),
            ("vite.config.ts", "Vite configuration"),
            (".env", "Environment variables"),
            (".env.local", "Local environment"),
            (".env.production", "Production environment"),
            ("package.json", "Package configuration"),
            ("tsconfig.json", "TypeScript configuration"),
            (".svelte-kit/output/server/manifest.json", "Server manifest"),
            ("_app/version.json", "Version info"),
        ];

        for (file, desc) in &sensitive_files {
            tests_run += 1;
            let file_url = format!("{}/{}", base, file);

            if let Ok(resp) = self.http_client.get(&file_url).await {
                if resp.status_code == 200 {
                    let is_config = resp.body.contains("export")
                        || resp.body.contains("module")
                        || resp.body.starts_with("{")
                        || resp.body.contains("DATABASE")
                        || resp.body.contains("SECRET");

                    if is_config {
                        vulnerabilities.push(Vulnerability {
                            id: format!("sveltekit_config_exposure_{}", Self::generate_id()),
                            vuln_type: format!("SvelteKit {} Exposed", desc),
                            severity: if file.contains(".env") {
                                Severity::Critical
                            } else {
                                Severity::Medium
                            },
                            confidence: Confidence::High,
                            category: "Information Disclosure".to_string(),
                            url: file_url.clone(),
                            parameter: Some(file.to_string()),
                            payload: format!("GET /{}", file),
                            description: format!("The {} file is publicly accessible.", desc),
                            evidence: Some(format!(
                                "File: {}\n\
                                Status: 200\n\
                                Preview: {}...",
                                file,
                                &resp.body[..resp.body.len().min(200)]
                            )),
                            cwe: "CWE-200".to_string(),
                            cvss: if file.contains(".env") { 9.1 } else { 5.3 },
                            verified: true,
                            false_positive: false,
                            remediation:
                                "Configure server/adapter to block access to config files."
                                    .to_string(),
                            discovered_at: chrono::Utc::now().to_rfc3339(),
                            ml_data: None,
                        });
                    }
                }
            }
        }

        Ok((vulnerabilities, tests_run))
    }

    /// Check for prerender data leakage
    async fn check_prerender_exposure(
        &self,
        url: &str,
        _config: &ScanConfig,
    ) -> Result<(Vec<Vulnerability>, usize)> {
        let mut vulnerabilities = Vec::new();
        let mut tests_run = 0;

        let base = url.trim_end_matches('/');

        // Check for prerendered __data.json files that might contain stale/sensitive data
        let prerender_paths = [
            "/__data.json",
            "/about/__data.json",
            "/blog/__data.json",
            "/products/__data.json",
        ];

        for path in &prerender_paths {
            tests_run += 1;
            let data_url = format!("{}{}", base, path);

            if let Ok(resp) = self.http_client.get(&data_url).await {
                if resp.status_code == 200 && resp.body.starts_with("{") {
                    // Check if data appears to be prerendered (static)
                    // and contains potentially outdated sensitive info
                    let body_lower = resp.body.to_lowercase();
                    if body_lower.contains("user")
                        || body_lower.contains("auth")
                        || body_lower.contains("session")
                    {
                        vulnerabilities.push(Vulnerability {
                            id: format!("sveltekit_prerender_{}", Self::generate_id()),
                            vuln_type: "SvelteKit Prerendered Data Exposure".to_string(),
                            severity: Severity::Medium,
                            confidence: Confidence::Medium,
                            category: "Information Disclosure".to_string(),
                            url: data_url.clone(),
                            parameter: Some(path.to_string()),
                            payload: format!("GET {}", path),
                            description: format!(
                                "Prerendered __data.json at '{}' may contain cached user/auth data \
                                that persists across deployments.",
                                path
                            ),
                            evidence: Some(format!(
                                "Contains user/auth related data in prerendered output"
                            )),
                            cwe: "CWE-200".to_string(),
                            cvss: 5.3,
                            verified: false,
                            false_positive: false,
                            remediation: "1. Don't prerender pages with user-specific data\n\
                                          2. Use +page.server.js for dynamic user data\n\
                                          3. Add prerender = false for authenticated pages"
                                .to_string(),
                            discovered_at: chrono::Utc::now().to_rfc3339(),
                            ml_data: None,
                        });
                        break;
                    }
                }
            }
        }

        Ok((vulnerabilities, tests_run))
    }

    /// Check for path traversal (CVE-2024-24563)
    async fn check_path_traversal(
        &self,
        url: &str,
        _config: &ScanConfig,
    ) -> Result<(Vec<Vulnerability>, usize)> {
        let mut vulnerabilities = Vec::new();
        let mut tests_run = 0;

        let base = url.trim_end_matches('/');

        // Path traversal payloads for static file serving
        let traversal_payloads = [
            ("/_app/../../../etc/passwd", "/etc/passwd"),
            ("/_app/..%2f..%2f..%2fetc/passwd", "/etc/passwd (encoded)"),
            (
                "/_app/....//....//....//etc/passwd",
                "/etc/passwd (double dot)",
            ),
            ("/static/../../../package.json", "package.json"),
            (
                "/_app/%2e%2e/%2e%2e/%2e%2e/etc/passwd",
                "/etc/passwd (full encode)",
            ),
        ];

        for (payload, desc) in &traversal_payloads {
            tests_run += 1;
            let test_url = format!("{}{}", base, payload);

            if let Ok(resp) = self.http_client.get(&test_url).await {
                let is_success = resp.status_code == 200
                    && (resp.body.contains("root:") ||  // /etc/passwd
                    resp.body.contains("\"name\":") ||  // package.json
                    resp.body.contains("dependencies"));

                if is_success {
                    vulnerabilities.push(Vulnerability {
                        id: format!("sveltekit_path_traversal_{}", Self::generate_id()),
                        vuln_type: "SvelteKit Path Traversal (CVE-2024-24563)".to_string(),
                        severity: Severity::High,
                        confidence: Confidence::High,
                        category: "Path Traversal".to_string(),
                        url: test_url.clone(),
                        parameter: Some("path".to_string()),
                        payload: payload.to_string(),
                        description: format!(
                            "Path traversal vulnerability in SvelteKit static file serving. \
                            Successfully accessed {} using traversal payload.",
                            desc
                        ),
                        evidence: Some(format!(
                            "Payload: {}\n\
                            Response indicates file access\n\
                            Status: {}",
                            payload, resp.status_code
                        )),
                        cwe: "CWE-22".to_string(),
                        cvss: 7.5,
                        verified: true,
                        false_positive: false,
                        remediation: "Upgrade SvelteKit to version 2.4.3 or later.".to_string(),
                        discovered_at: chrono::Utc::now().to_rfc3339(),
                        ml_data: None,
                    });
                    break;
                }
            }
        }

        Ok((vulnerabilities, tests_run))
    }

    /// Check for open redirect vulnerabilities
    async fn check_open_redirect(
        &self,
        url: &str,
        _config: &ScanConfig,
    ) -> Result<(Vec<Vulnerability>, usize)> {
        let mut vulnerabilities = Vec::new();
        let mut tests_run = 0;

        let base = url.trim_end_matches('/');

        // Test redirect parameters
        let redirect_params = [
            ("redirect", "https://evil.com"),
            ("next", "https://evil.com"),
            ("return", "//evil.com"),
            ("url", "https://evil.com"),
            ("goto", "//evil.com"),
            ("returnTo", "https://evil.com"),
        ];

        for (param, payload) in &redirect_params {
            tests_run += 1;
            let test_url = format!("{}/?{}={}", base, param, urlencoding::encode(payload));

            if let Ok(resp) = self.http_client.get(&test_url).await {
                // Check for redirect to evil.com
                if resp.status_code == 302 || resp.status_code == 301 || resp.status_code == 307 {
                    if let Some(location) = resp.headers.get("location") {
                        if location.contains("evil.com") {
                            vulnerabilities.push(Vulnerability {
                                id: format!("sveltekit_open_redirect_{}", Self::generate_id()),
                                vuln_type: "SvelteKit Open Redirect".to_string(),
                                severity: Severity::Medium,
                                confidence: Confidence::High,
                                category: "Open Redirect".to_string(),
                                url: test_url.clone(),
                                parameter: Some(param.to_string()),
                                payload: payload.to_string(),
                                description: format!(
                                    "Open redirect via '{}' parameter allows redirecting users to malicious sites.",
                                    param
                                ),
                                evidence: Some(format!(
                                    "Parameter: {}={}\n\
                                    Location header: {}",
                                    param, payload, location
                                )),
                                cwe: "CWE-601".to_string(),
                                cvss: 6.1,
                                verified: true,
                                false_positive: false,
                                remediation: "1. Validate redirect URLs against allowlist\n\
                                              2. Use relative URLs for redirects\n\
                                              3. Upgrade SvelteKit to 2.5.4+ (CVE-2024-29893)".to_string(),
                                discovered_at: chrono::Utc::now().to_rfc3339(),
                ml_data: None,
                            });
                            break;
                        }
                    }
                }
            }
        }

        Ok((vulnerabilities, tests_run))
    }

    /// Check for version-specific CVEs
    async fn check_version_cves(
        &self,
        url: &str,
        version: &str,
        _config: &ScanConfig,
    ) -> Result<(Vec<Vulnerability>, usize)> {
        let mut vulnerabilities = Vec::new();
        let mut tests_run = 0;

        let version_parts: Vec<u32> = version.split('.').filter_map(|p| p.parse().ok()).collect();

        if version_parts.len() < 2 {
            return Ok((vec![], tests_run));
        }

        let major = version_parts[0];
        let minor = version_parts[1];
        let patch = version_parts.get(2).copied().unwrap_or(0);

        for cve in &self.known_cves {
            tests_run += 1;

            let is_affected = match cve.cve_id.as_str() {
                "CVE-2024-23641" => {
                    major < 2
                        || (major == 2 && minor < 4)
                        || (major == 2 && minor == 4 && patch < 1)
                }
                "CVE-2024-24563" => {
                    major < 2
                        || (major == 2 && minor < 4)
                        || (major == 2 && minor == 4 && patch < 3)
                }
                "CVE-2024-29893" => {
                    major < 2
                        || (major == 2 && minor < 5)
                        || (major == 2 && minor == 5 && patch < 4)
                }
                "CVE-2023-29008" | "CVE-2023-29007" => {
                    major < 1
                        || (major == 1 && minor < 15)
                        || (major == 1 && minor == 15 && patch < 1)
                }
                "CVE-2022-25869" => false, // Svelte core, need different version check
                _ => false,
            };

            if is_affected {
                vulnerabilities.push(Vulnerability {
                    id: format!("sveltekit_cve_{}_{}", cve.cve_id, Self::generate_id()),
                    vuln_type: format!("SvelteKit {} - {:?}", cve.cve_id, cve.check_type),
                    severity: cve.severity.clone(),
                    confidence: Confidence::High,
                    category: "Known Vulnerability".to_string(),
                    url: url.to_string(),
                    parameter: Some(format!("SvelteKit {}", version)),
                    payload: format!("{}: {}", cve.cve_id, cve.affected_versions),
                    description: format!(
                        "{}\n\nDetected: {}\nAffected: {}",
                        cve.description, version, cve.affected_versions
                    ),
                    evidence: Some(format!(
                        "CVE: {}\nVersion: {}\nAffected: {}",
                        cve.cve_id, version, cve.affected_versions
                    )),
                    cwe: match cve.check_type {
                        CVECheckType::CSRF => "CWE-352",
                        CVECheckType::PathTraversal => "CWE-22",
                        CVECheckType::OpenRedirect => "CWE-601",
                        CVECheckType::XSS => "CWE-79",
                        _ => "CWE-1035",
                    }
                    .to_string(),
                    cvss: match cve.severity {
                        Severity::Critical => 9.8,
                        Severity::High => 7.5,
                        Severity::Medium => 5.3,
                        _ => 3.0,
                    },
                    verified: false,
                    false_positive: false,
                    remediation: format!(
                        "Upgrade SvelteKit. See: https://nvd.nist.gov/vuln/detail/{}",
                        cve.cve_id
                    ),
                    discovered_at: chrono::Utc::now().to_rfc3339(),
                    ml_data: None,
                });
            }
        }

        Ok((vulnerabilities, tests_run))
    }

    fn generate_id() -> String {
        use rand::Rng;
        let mut rng = rand::rng();
        format!("{:08x}", rng.random::<u32>())
    }
}