use crate::ops::security_detection::detector_support::{spans, ByteSpan, DetectionError};
pub const SPEC_TOML: &str = r#"schema_version = 1
id = "security_detection.detect_uuid"
archetype = "match-bytes-pattern"
display_name = "Detect UUID"
summary = "Returns offset-length spans for canonical UUID byte sequences."
category = "C"
[intrinsic]
wgsl = "security_detection_detect_uuid"
[signature]
inputs = ["Bytes", "Bytes"]
output = "Bytes"
laws = []
equivalence_classes = ["canonical", "missing_dash", "bad_hex", "t47_cap"]
workgroup_size = [64, 1, 1]
tags = ["security-detection", "uuid", "secret-scan", "t47"]
fixtures_dir = "fixtures/"
"#;
pub const REFERENCE_VECTORS_TOML: &str = r#"[[case]]
name = "positive_uuid"
input = "id 550e8400-e29b-41d4-a716-446655440000 ok"
expected_spans = [{ offset = 3, len = 36 }]
[[case]]
name = "negative_missing_dash"
input = "id 550e8400e29b41d4a716446655440000 ok"
expected_spans = []
"#;
pub mod lowering {
#[must_use]
pub const fn source() -> &'static str {
r#"@compute @workgroup_size(64)
pub fn detect_uuid(@builtin(global_invocation_id) gid: vec3<u32>) {
let i = gid.x;
if (i + 36u > input_len) { return; }
for (var n = 0u; n < 36u; n = n + 1u) {
let dash = n == 8u || n == 13u || n == 18u || n == 23u;
if ((dash && input[i + n] != 45u) || (!dash && !is_hex(input[i + n]))) { return; }
}
if (token_boundary(i, i + 36u)) { emit_span(i, 36u); }
}"#
}
}
pub fn detect_uuid(input: &[u8]) -> Result<Vec<ByteSpan>, DetectionError> {
spans::uuid_spans(input)
}
pub mod implementation {
pub use super::detect_uuid;
pub mod kernel {
pub use super::super::detect_uuid;
}
pub mod lowering {
pub mod wgsl {
pub use super::super::super::lowering::source;
}
}
}