use crate::ops::security_detection::detector_support::{attacks, DetectionError};
pub const SPEC_TOML: &str = r#"schema_version = 1
id = "security_detection.detect_path_traversal"
archetype = "rule-bytes-to-bool"
display_name = "Detect Path Traversal"
summary = "Returns true for decoded or raw parent-directory traversal."
category = "C"
[intrinsic]
wgsl = "security_detection_detect_path_traversal"
[signature]
inputs = ["Bytes"]
output = "Bool"
laws = []
equivalence_classes = ["raw_traversal", "encoded_traversal", "plain_path", "t47_cap"]
workgroup_size = [64, 1, 1]
tags = ["security-detection", "path-traversal", "owasp", "t47"]
fixtures_dir = "fixtures/"
"#;
pub const REFERENCE_VECTORS_TOML: &str = r#"[[case]]
name = "positive_encoded"
input = "path=..%2f..%2fetc/passwd"
expected = true
[[case]]
name = "negative_plain_path"
input = "path=/var/www/static/app.js"
expected = false
"#;
pub mod lowering {
#[must_use]
pub const fn source() -> &'static str {
r#"@compute @workgroup_size(64)
pub fn detect_path_traversal() {
out[0] = select(0u, 1u,
contains_ci("../") || contains_ci("..\\") ||
contains_ci("..//") || contains_ci("..\\\\"));
}"#
}
}
pub fn detect_path_traversal(input: &[u8]) -> Result<bool, DetectionError> {
attacks::detect_path_traversal(input)
}
pub mod implementation {
pub use super::detect_path_traversal;
pub mod kernel {
pub use super::super::detect_path_traversal;
}
pub mod lowering {
pub mod wgsl {
pub use super::super::super::lowering::source;
}
}
}