story 2-14-openapi-support-matrix-regression-corpus: implemented and reviewed via bmad-loop
This commit is contained in:
1 parent
16dc777911
commit
194cac169f
84 files changed
+23255
-1
No files matched your search
@@ -57,6 +57,10 @@ pub(super) fn matches_source(
|
||||
pointer.contains("/example") && matches!(&node.value, CanonicalSourceValue::String(value) if secret_like(pointer, value))
|
||||
}
|
||||
"invalid_server" if is_error => invalid_server(pointer, node),
|
||||
"unsupported_security_requirement" if is_error => {
|
||||
matches!(&node.value, CanonicalSourceValue::Object(fields) if !fields.is_empty())
|
||||
|| invalid_security_requirement(pointer, node)
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@@ -201,6 +205,31 @@ fn secret_like(pointer: &str, value: &str) -> bool {
|
||||
|| value.starts_with("sk-")
|
||||
}
|
||||
|
||||
/// Accepts malformed `security` shapes at their scoped source location only:
|
||||
/// the document `security` member, an operation `security` member, or a
|
||||
/// non-object item of the corresponding security array. An object is valid
|
||||
/// only as an array item, including the empty `{}` public alternative.
|
||||
fn invalid_security_requirement(pointer: &str, node: &CanonicalSourceNode) -> bool {
|
||||
const METHODS: &[&str] = &[
|
||||
"get", "post", "put", "patch", "delete", "head", "options", "trace", "connect",
|
||||
];
|
||||
let is_index = |part: &str| !part.is_empty() && part.bytes().all(|b| b.is_ascii_digit());
|
||||
let segments: Vec<&str> = pointer.split('/').collect();
|
||||
match segments.as_slice() {
|
||||
["", "security"] => true,
|
||||
["", "security", index] => {
|
||||
is_index(index) && !matches!(&node.value, CanonicalSourceValue::Object(_))
|
||||
}
|
||||
["", "paths", _, method, "security"] => METHODS.contains(method),
|
||||
["", "paths", _, method, "security", index] => {
|
||||
METHODS.contains(method)
|
||||
&& is_index(index)
|
||||
&& !matches!(&node.value, CanonicalSourceValue::Object(_))
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn invalid_server(pointer: &str, node: &CanonicalSourceNode) -> bool {
|
||||
if pointer == "/host" {
|
||||
return !matches!(&node.value, CanonicalSourceValue::String(host) if !host.is_empty() && !host.contains('@') && !host.chars().any(char::is_whitespace));
|
||||
|
||||
Reference in new issue
Block a user