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
// Copyright (c) 2026 Bountyy Oy. All rights reserved.
// This software is proprietary and confidential.

use regex::Regex;
/**
 * Nuclei Template Validator
 * Production-grade validation for custom Nuclei templates
 *
 * Features:
 * - YAML syntax validation
 * - Nuclei template schema validation
 * - Dangerous pattern detection
 * - Performance impact analysis
 * - Security validation
 *
 * © 2026 Bountyy Oy
 */
use serde::{Deserialize, Serialize};
use serde_yaml;
use std::collections::{HashMap, HashSet};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ValidationResult {
    pub valid: bool,
    pub errors: Vec<ValidationError>,
    pub warnings: Vec<ValidationWarning>,
    pub security_score: u8,    // 0-100
    pub performance_score: u8, // 0-100
    pub metadata: ValidationMetadata,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ValidationError {
    pub error_type: String,
    pub message: String,
    pub line: Option<usize>,
    pub severity: ErrorSeverity,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ValidationWarning {
    pub warning_type: String,
    pub message: String,
    pub line: Option<usize>,
    pub suggestion: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ErrorSeverity {
    Critical,
    High,
    Medium,
    Low,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ValidationMetadata {
    pub template_type: String,
    pub request_count: usize,
    pub matcher_count: usize,
    pub extractor_count: usize,
    pub has_stop_at_first_match: bool,
    pub estimated_execution_time_ms: u64,
    pub max_redirects: usize,
    pub potential_rate_limit_issues: bool,
}

#[derive(Debug, Deserialize)]
struct NucleiTemplate {
    id: String,
    info: TemplateInfo,
    #[serde(default)]
    http: Option<Vec<HttpRequest>>,
    #[serde(default)]
    network: Option<Vec<NetworkRequest>>,
    #[serde(default)]
    dns: Option<Vec<DnsRequest>>,
    #[serde(default)]
    file: Option<Vec<FileRequest>>,
    #[serde(default)]
    variables: Option<HashMap<String, String>>,
}

#[derive(Debug, Deserialize)]
struct TemplateInfo {
    name: String,
    author: Option<String>,
    severity: String,
    #[serde(default)]
    description: Option<String>,
    #[serde(default)]
    tags: Option<Vec<String>>,
    #[serde(default)]
    reference: Option<Vec<String>>,
}

#[derive(Debug, Deserialize)]
struct HttpRequest {
    #[serde(default)]
    method: Option<String>,
    #[serde(default)]
    path: Option<Vec<String>>,
    #[serde(default)]
    raw: Option<Vec<String>>,
    #[serde(default)]
    headers: Option<HashMap<String, String>>,
    #[serde(default)]
    body: Option<String>,
    #[serde(default)]
    matchers: Option<Vec<Matcher>>,
    #[serde(default)]
    extractors: Option<Vec<Extractor>>,
    #[serde(default)]
    redirects: Option<bool>,
    #[serde(default)]
    max_redirects: Option<usize>,
    #[serde(default)]
    stop_at_first_match: Option<bool>,
}

#[derive(Debug, Deserialize)]
struct NetworkRequest {
    #[serde(default)]
    inputs: Option<Vec<NetworkInput>>,
    #[serde(default)]
    matchers: Option<Vec<Matcher>>,
}

#[derive(Debug, Deserialize)]
struct NetworkInput {
    #[serde(default)]
    data: Option<String>,
}

#[derive(Debug, Deserialize)]
struct DnsRequest {
    #[serde(default)]
    name: Option<String>,
    #[serde(default)]
    matchers: Option<Vec<Matcher>>,
}

#[derive(Debug, Deserialize)]
struct FileRequest {
    #[serde(default)]
    extensions: Option<Vec<String>>,
    #[serde(default)]
    matchers: Option<Vec<Matcher>>,
}

#[derive(Debug, Deserialize)]
struct Matcher {
    #[serde(rename = "type")]
    matcher_type: Option<String>,
    #[serde(default)]
    condition: Option<String>,
    #[serde(default)]
    words: Option<Vec<String>>,
    #[serde(default)]
    regex: Option<Vec<String>>,
    #[serde(default)]
    status: Option<Vec<u16>>,
    #[serde(default)]
    dsl: Option<Vec<String>>,
    #[serde(default)]
    part: Option<String>,
}

#[derive(Debug, Deserialize)]
struct Extractor {
    #[serde(rename = "type")]
    extractor_type: Option<String>,
    #[serde(default)]
    regex: Option<Vec<String>>,
    #[serde(default)]
    name: Option<String>,
    #[serde(default)]
    part: Option<String>,
}

pub struct TemplateValidator {
    dangerous_patterns: HashSet<String>,
    dangerous_commands: HashSet<String>,
    max_request_count: usize,
    max_execution_time_ms: u64,
}

impl Default for TemplateValidator {
    fn default() -> Self {
        Self::new()
    }
}

impl TemplateValidator {
    pub fn new() -> Self {
        let mut dangerous_patterns = HashSet::new();
        dangerous_patterns.insert("eval(".to_string());
        dangerous_patterns.insert("exec(".to_string());
        dangerous_patterns.insert("system(".to_string());
        dangerous_patterns.insert("shell_exec".to_string());
        dangerous_patterns.insert("passthru".to_string());
        dangerous_patterns.insert("rm -rf".to_string());
        dangerous_patterns.insert("DROP TABLE".to_string());
        dangerous_patterns.insert("DELETE FROM".to_string());
        dangerous_patterns.insert("TRUNCATE".to_string());

        let mut dangerous_commands = HashSet::new();
        dangerous_commands.insert("curl".to_string());
        dangerous_commands.insert("wget".to_string());
        dangerous_commands.insert("nc".to_string());
        dangerous_commands.insert("netcat".to_string());
        dangerous_commands.insert("bash".to_string());
        dangerous_commands.insert("sh".to_string());
        dangerous_commands.insert("/bin/".to_string());

        Self {
            dangerous_patterns,
            dangerous_commands,
            max_request_count: 50,
            max_execution_time_ms: 60000, // 60 seconds
        }
    }

    /// Validate a Nuclei template YAML
    pub fn validate(&self, template_yaml: &str) -> ValidationResult {
        let mut errors = Vec::new();
        let mut warnings = Vec::new();
        let mut security_score = 100u8;
        let mut performance_score = 100u8;

        // 1. YAML Syntax Validation
        let template = match serde_yaml::from_str::<NucleiTemplate>(template_yaml) {
            Ok(t) => t,
            Err(e) => {
                errors.push(ValidationError {
                    error_type: "syntax_error".to_string(),
                    message: format!("Invalid YAML syntax: {}", e),
                    line: None,
                    severity: ErrorSeverity::Critical,
                });

                return ValidationResult {
                    valid: false,
                    errors,
                    warnings,
                    security_score: 0,
                    performance_score: 0,
                    metadata: ValidationMetadata {
                        template_type: "unknown".to_string(),
                        request_count: 0,
                        matcher_count: 0,
                        extractor_count: 0,
                        has_stop_at_first_match: false,
                        estimated_execution_time_ms: 0,
                        max_redirects: 0,
                        potential_rate_limit_issues: false,
                    },
                };
            }
        };

        // 2. Schema Validation
        self.validate_schema(&template, &mut errors, &mut warnings);

        // 3. Security Validation
        let security_issues = self.validate_security(&template, template_yaml);
        if !security_issues.is_empty() {
            security_score = security_score.saturating_sub((security_issues.len() * 20) as u8);
            errors.extend(security_issues);
        }

        // 4. Performance Validation
        let (perf_warnings, perf_metadata) = self.validate_performance(&template);
        if !perf_warnings.is_empty() {
            performance_score = performance_score.saturating_sub((perf_warnings.len() * 10) as u8);
            warnings.extend(perf_warnings);
        }

        // 5. Best Practices Validation
        let best_practice_warnings = self.validate_best_practices(&template);
        warnings.extend(best_practice_warnings);

        // Determine template type
        let template_type = if template.http.is_some() {
            "http"
        } else if template.network.is_some() {
            "network"
        } else if template.dns.is_some() {
            "dns"
        } else if template.file.is_some() {
            "file"
        } else {
            "unknown"
        }
        .to_string();

        let valid = errors.is_empty();

        ValidationResult {
            valid,
            errors,
            warnings,
            security_score,
            performance_score,
            metadata: ValidationMetadata {
                template_type,
                ..perf_metadata
            },
        }
    }

    fn validate_schema(
        &self,
        template: &NucleiTemplate,
        errors: &mut Vec<ValidationError>,
        warnings: &mut Vec<ValidationWarning>,
    ) {
        // Validate ID
        if template.id.is_empty() {
            errors.push(ValidationError {
                error_type: "missing_id".to_string(),
                message: "Template ID is required".to_string(),
                line: None,
                severity: ErrorSeverity::High,
            });
        }

        // Validate ID format (should be lowercase with hyphens)
        if !template
            .id
            .chars()
            .all(|c| c.is_ascii_lowercase() || c == '-' || c.is_ascii_digit())
        {
            warnings.push(ValidationWarning {
                warning_type: "id_format".to_string(),
                message: "Template ID should use lowercase letters, numbers, and hyphens only"
                    .to_string(),
                line: None,
                suggestion: Some(template.id.to_lowercase().replace('_', "-")),
            });
        }

        // Validate severity
        let valid_severities = ["info", "low", "medium", "high", "critical"];
        if !valid_severities.contains(&template.info.severity.as_str()) {
            errors.push(ValidationError {
                error_type: "invalid_severity".to_string(),
                message: format!(
                    "Invalid severity '{}'. Must be one of: info, low, medium, high, critical",
                    template.info.severity
                ),
                line: None,
                severity: ErrorSeverity::Medium,
            });
        }

        // Validate name
        if template.info.name.is_empty() {
            errors.push(ValidationError {
                error_type: "missing_name".to_string(),
                message: "Template name is required".to_string(),
                line: None,
                severity: ErrorSeverity::High,
            });
        }

        // Check for at least one request type
        if template.http.is_none()
            && template.network.is_none()
            && template.dns.is_none()
            && template.file.is_none()
        {
            errors.push(ValidationError {
                error_type: "no_requests".to_string(),
                message: "Template must have at least one request (http, network, dns, or file)"
                    .to_string(),
                line: None,
                severity: ErrorSeverity::Critical,
            });
        }

        // Validate HTTP requests
        if let Some(http_requests) = &template.http {
            for (idx, req) in http_requests.iter().enumerate() {
                if req.path.is_none() && req.raw.is_none() {
                    errors.push(ValidationError {
                        error_type: "missing_path_or_raw".to_string(),
                        message: format!(
                            "HTTP request {} must have either 'path' or 'raw' defined",
                            idx + 1
                        ),
                        line: None,
                        severity: ErrorSeverity::High,
                    });
                }

                if req.matchers.is_none() {
                    warnings.push(ValidationWarning {
                        warning_type: "no_matchers".to_string(),
                        message: format!("HTTP request {} has no matchers defined", idx + 1),
                        line: None,
                        suggestion: Some("Add matchers to detect vulnerabilities".to_string()),
                    });
                }
            }
        }
    }

    fn validate_security(
        &self,
        template: &NucleiTemplate,
        template_yaml: &str,
    ) -> Vec<ValidationError> {
        let mut errors = Vec::new();

        // Check for dangerous patterns in the entire template
        for pattern in &self.dangerous_patterns {
            if template_yaml.contains(pattern) {
                errors.push(ValidationError {
                    error_type: "dangerous_pattern".to_string(),
                    message: format!(
                        "Dangerous pattern detected: '{}'. This could lead to code execution.",
                        pattern
                    ),
                    line: None,
                    severity: ErrorSeverity::Critical,
                });
            }
        }

        // Check for dangerous commands
        for command in &self.dangerous_commands {
            if template_yaml.contains(command) {
                errors.push(ValidationError {
                    error_type: "dangerous_command".to_string(),
                    message: format!("Potentially dangerous command detected: '{}'. Ensure proper safeguards are in place.", command),
                    line: None,
                    severity: ErrorSeverity::High,
                });
            }
        }

        // Check for credential leakage patterns
        let credential_patterns = vec![
            (r#"password\s*=\s*['"][^'"]+['"]"#, "hardcoded password"),
            (r#"api[_-]?key\s*=\s*['"][^'"]+['"]"#, "hardcoded API key"),
            (r#"secret\s*=\s*['"][^'"]+['"]"#, "hardcoded secret"),
            (r#"token\s*=\s*['"][^'"]+['"]"#, "hardcoded token"),
            (r"aws_access_key_id", "AWS credentials"),
            (r"private[_-]?key", "private key"),
        ];

        for (pattern, name) in credential_patterns {
            if let Ok(re) = Regex::new(pattern) {
                if re.is_match(template_yaml) {
                    errors.push(ValidationError {
                        error_type: "credential_leakage".to_string(),
                        message: format!(
                            "Potential {} detected in template. Never hardcode credentials.",
                            name
                        ),
                        line: None,
                        severity: ErrorSeverity::Critical,
                    });
                }
            }
        }

        // Check for SSRF without proper validation
        if let Some(http_requests) = &template.http {
            for req in http_requests {
                if let Some(paths) = &req.path {
                    for path in paths {
                        if path.contains("{{")
                            && (path.contains("http://") || path.contains("https://"))
                        {
                            errors.push(ValidationError {
                                error_type: "potential_ssrf".to_string(),
                                message: "Template uses user-controlled URLs which could lead to SSRF. Ensure proper validation.".to_string(),
                                line: None,
                                severity: ErrorSeverity::High,
                            });
                        }
                    }
                }
            }
        }

        // Check for SQL injection without proper context
        if template_yaml.contains("SQL") || template_yaml.contains("sql") {
            if !template_yaml.contains("safe") && !template_yaml.contains("test") {
                errors.push(ValidationError {
                    error_type: "potential_sqli".to_string(),
                    message: "Template appears to test for SQL injection. Ensure it's properly scoped to test environments.".to_string(),
                    line: None,
                    severity: ErrorSeverity::Medium,
                });
            }
        }

        errors
    }

    fn validate_performance(
        &self,
        template: &NucleiTemplate,
    ) -> (Vec<ValidationWarning>, ValidationMetadata) {
        let mut warnings = Vec::new();
        let mut request_count = 0;
        let mut matcher_count = 0;
        let mut extractor_count = 0;
        let mut has_stop_at_first_match = false;
        let mut max_redirects = 5;
        let mut estimated_time_ms = 0u64;

        // Count HTTP requests and analyze
        if let Some(http_requests) = &template.http {
            request_count = http_requests.len();

            if request_count > self.max_request_count {
                warnings.push(ValidationWarning {
                    warning_type: "too_many_requests".to_string(),
                    message: format!(
                        "Template has {} requests. Consider reducing for better performance.",
                        request_count
                    ),
                    line: None,
                    suggestion: Some(format!(
                        "Recommended maximum: {} requests",
                        self.max_request_count
                    )),
                });
            }

            for req in http_requests {
                // Estimate execution time per request (average 1000ms per HTTP request)
                estimated_time_ms += 1000;

                // Check for path explosion
                if let Some(paths) = &req.path {
                    if paths.len() > 10 {
                        warnings.push(ValidationWarning {
                            warning_type: "path_explosion".to_string(),
                            message: format!(
                                "Request has {} paths. This will multiply execution time.",
                                paths.len()
                            ),
                            line: None,
                            suggestion: Some(
                                "Consider splitting into multiple templates".to_string(),
                            ),
                        });
                        estimated_time_ms += (paths.len() as u64 - 1) * 1000;
                    }
                }

                // Count matchers
                if let Some(matchers) = &req.matchers {
                    matcher_count += matchers.len();

                    // Check for complex regex matchers
                    for matcher in matchers {
                        if let Some(regexes) = &matcher.regex {
                            for regex_pattern in regexes {
                                if regex_pattern.contains(".*.*") || regex_pattern.contains(".+.+")
                                {
                                    warnings.push(ValidationWarning {
                                        warning_type: "complex_regex".to_string(),
                                        message: "Complex regex pattern detected. May cause performance issues.".to_string(),
                                        line: None,
                                        suggestion: Some("Simplify regex or use word matchers where possible".to_string()),
                                    });
                                }
                            }
                        }
                    }
                }

                // Count extractors
                if let Some(extractors) = &req.extractors {
                    extractor_count += extractors.len();
                }

                // Check stop_at_first_match
                if req.stop_at_first_match.unwrap_or(false) {
                    has_stop_at_first_match = true;
                }

                // Check redirects
                if let Some(max_redir) = req.max_redirects {
                    max_redirects = max_redir;
                    if max_redir > 10 {
                        warnings.push(ValidationWarning {
                            warning_type: "excessive_redirects".to_string(),
                            message: format!(
                                "max_redirects set to {}. This may cause slow execution.",
                                max_redir
                            ),
                            line: None,
                            suggestion: Some(
                                "Consider limiting redirects to 5 or less".to_string(),
                            ),
                        });
                    }
                }
            }
        }

        // Check for rate limit issues
        let potential_rate_limit = request_count > 20;
        if potential_rate_limit {
            warnings.push(ValidationWarning {
                warning_type: "rate_limit_risk".to_string(),
                message: "High request count may trigger rate limiting on target servers."
                    .to_string(),
                line: None,
                suggestion: Some(
                    "Add delays between requests or use threads carefully".to_string(),
                ),
            });
        }

        // Check total estimated execution time
        if estimated_time_ms > self.max_execution_time_ms {
            warnings.push(ValidationWarning {
                warning_type: "long_execution".to_string(),
                message: format!(
                    "Estimated execution time: {}s. Consider optimizing.",
                    estimated_time_ms / 1000
                ),
                line: None,
                suggestion: Some("Reduce request count or use stop-at-first-match".to_string()),
            });
        }

        let metadata = ValidationMetadata {
            template_type: "http".to_string(),
            request_count,
            matcher_count,
            extractor_count,
            has_stop_at_first_match,
            estimated_execution_time_ms: estimated_time_ms,
            max_redirects,
            potential_rate_limit_issues: potential_rate_limit,
        };

        (warnings, metadata)
    }

    fn validate_best_practices(&self, template: &NucleiTemplate) -> Vec<ValidationWarning> {
        let mut warnings = Vec::new();

        // Check for author
        if template.info.author.is_none() {
            warnings.push(ValidationWarning {
                warning_type: "missing_author".to_string(),
                message: "Template should include author information".to_string(),
                line: None,
                suggestion: Some("Add 'author' field in template info".to_string()),
            });
        }

        // Check for description
        if template.info.description.is_none() {
            warnings.push(ValidationWarning {
                warning_type: "missing_description".to_string(),
                message: "Template should include a description".to_string(),
                line: None,
                suggestion: Some(
                    "Add 'description' field explaining what this template detects".to_string(),
                ),
            });
        }

        // Check for tags
        if template.info.tags.is_none() || template.info.tags.as_ref().unwrap().is_empty() {
            warnings.push(ValidationWarning {
                warning_type: "missing_tags".to_string(),
                message: "Template should include tags for better organization".to_string(),
                line: None,
                suggestion: Some(
                    "Add relevant tags (e.g., 'sqli', 'xss', 'cve-2023-xxxx')".to_string(),
                ),
            });
        }

        // Check for reference
        if template.info.reference.is_none() {
            warnings.push(ValidationWarning {
                warning_type: "missing_reference".to_string(),
                message: "Consider adding references to vulnerability advisories or documentation"
                    .to_string(),
                line: None,
                suggestion: Some("Add 'reference' field with relevant URLs".to_string()),
            });
        }

        warnings
    }

    /// Quick validation (basic checks only)
    pub fn validate_quick(&self, template_yaml: &str) -> bool {
        serde_yaml::from_str::<NucleiTemplate>(template_yaml).is_ok()
    }

    /// Validate template schema only
    pub fn validate_schema_only(&self, template_yaml: &str) -> Result<(), String> {
        match serde_yaml::from_str::<NucleiTemplate>(template_yaml) {
            Ok(_) => Ok(()),
            Err(e) => Err(format!("Schema validation failed: {}", e)),
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_valid_template() {
        let validator = TemplateValidator::new();
        let template = r#"
id: test-template
info:
  name: Test Template
  author: test
  severity: medium
  description: Test description
  tags:
    - test
http:
  - method: GET
    path:
      - "{{BaseURL}}/test"
    matchers:
      - type: word
        words:
          - "vulnerable"
"#;

        let result = validator.validate(template);
        assert!(result.valid);
    }

    #[test]
    fn test_invalid_yaml() {
        let validator = TemplateValidator::new();
        let template = "invalid: yaml: syntax: error:";

        let result = validator.validate(template);
        assert!(!result.valid);
    }

    #[test]
    fn test_dangerous_pattern_detection() {
        let validator = TemplateValidator::new();
        let template = r#"
id: dangerous-template
info:
  name: Dangerous
  severity: high
http:
  - raw:
      - |
        GET /test?cmd=eval($_GET['x']) HTTP/1.1
"#;

        let result = validator.validate(template);
        assert!(!result.errors.is_empty());
    }
}