Merge bmad-loop/20260928-001624-0637/2-14-openapi-support-matrix-regression-corpus into main (bmad-loop)

This commit is contained in:
bsodfather committed 2026-09-29 20:48:40 +03:00
commit 7ffde8885d
84 files changed
+23255 -1

No files matched your search

+27
View File
@@ -21,6 +21,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Install Rust toolchain
run: |
@@ -109,6 +111,31 @@ jobs:
- name: Check Rust boundaries
run: scripts/check-rust-boundaries.sh
- name: Run offline OpenAPI support corpus gate
run: cargo test -p crank-import --test corpus -- --test-threads=1
- name: Check OpenAPI matrix and corpus compatibility versions
env:
MATRIX_BASE_REF: ${{ gitea.base_ref }}
MATRIX_EVENT_BEFORE: ${{ gitea.event.before }}
run: |
if [ -n "$MATRIX_BASE_REF" ]; then
base_ref="origin/$MATRIX_BASE_REF"
elif [ -n "$MATRIX_EVENT_BEFORE" ] && ! printf '%s' "$MATRIX_EVENT_BEFORE" | grep -Eq '^0+$'; then
base_ref="$MATRIX_EVENT_BEFORE"
else
base_ref="$(git merge-base HEAD origin/main)"
fi
python3 scripts/check-openapi-matrix-compatibility.py --base "$base_ref"
- name: Save OpenAPI corpus evidence
if: always()
uses: actions/upload-artifact@v4
with:
name: openapi-corpus-evidence
path: crates/crank-import/target/openapi-corpus/evidence-*.json
if-no-files-found: warn
- name: Run clippy
run: cargo clippy --workspace --all-targets --all-features --jobs "$CARGO_BUILD_JOBS" -- -D warnings
Generated
+1
View File
@@ -766,6 +766,7 @@ dependencies = [
"serde",
"serde_json",
"serde_yaml",
"sha2 0.10.9",
"thiserror 2.0.18",
"url",
]
@@ -103,7 +103,9 @@ impl AdminService {
let global_blocker = preview
.findings
.iter()
.find(|finding| finding.severity == ImportFindingSeverity::Error)
.find(|finding| {
finding.severity == ImportFindingSeverity::Error && finding.operation_key.is_none()
})
.map(|finding| finding.code.clone());
let mut planned = Vec::with_capacity(selected_keys.len());
@@ -1,5 +1,34 @@
use serde_json::{Value, json};
use serial_test::serial;
use std::{sync::Arc, time::Duration};
use async_trait::async_trait;
use crank_community_mcp::session::InMemorySessionStore;
use crank_core::{
MachineAccessMode, MachineCredentialVerifier, MachineCredentialVerifierError,
OperationSecurityLevel, PlatformApiKeyScope, VerifiedMachineCredential,
};
struct CorpusMcpCredentialVerifier;
#[async_trait]
impl MachineCredentialVerifier for CorpusMcpCredentialVerifier {
async fn verify_bearer_token(
&self,
_workspace_slug: &str,
_agent_slug: &str,
token: &str,
) -> Result<Option<VerifiedMachineCredential>, MachineCredentialVerifierError> {
Ok(
(token == "corpus-test-token").then_some(VerifiedMachineCredential {
machine_access_mode: MachineAccessMode::StaticAgentKey,
max_security_level: OperationSecurityLevel::Standard,
scopes: vec![PlatformApiKeyScope::Read, PlatformApiKeyScope::Write],
platform_api_key_id: None,
}),
)
}
}
use super::super::common::*;
@@ -53,6 +82,7 @@ struct CreatedPlan {
reference: String,
digest: String,
body: Value,
preview: Value,
}
async fn create_plan(
@@ -111,6 +141,7 @@ async fn create_plan(
reference,
digest,
body,
preview,
}
}
@@ -287,6 +318,7 @@ async fn same_key_and_digest_replay_report_without_extra_draft_and_changed_diges
reference: plan.reference.clone(),
digest: "0".repeat(64),
body: plan.body.clone(),
preview: plan.preview.clone(),
};
let (changed_status, _) = apply_plan(&client, &base_url, &changed, "stable-apply-key").await;
assert_eq!(changed_status, reqwest::StatusCode::CONFLICT);
@@ -662,3 +694,153 @@ async fn disabled_auth_secret_rejects_apply_without_leaking_credentials() {
assert_eq!(after["total"], 1);
assert_eq!(after["items"][0]["name"], "beta");
}
#[tokio::test(flavor = "multi_thread")]
#[serial]
async fn ac_4_corpus_operation_completes_the_real_http_to_mcp_workflow() {
use axum::{Json, Router};
let registry = test_registry().await;
let (request_tx, mut request_rx) = tokio::sync::mpsc::unbounded_channel();
let upstream =
Router::new().fallback(move |method: axum::http::Method, uri: axum::http::Uri| {
let request_tx = request_tx.clone();
async move {
request_tx.send((method, uri)).unwrap();
Json(json!({"id":"corpus-0"}))
}
});
let upstream_base = spawn_admin_api(upstream).await;
let storage = test_storage_root("corpus_ac4");
let base_url = spawn_admin_api(build_test_app(registry.clone(), storage)).await;
let client = authorized_client(&base_url).await;
let fixture_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../crates/crank-import/tests/corpus/representative-00.json");
let mut fixture: Value = serde_json::from_slice(&std::fs::read(fixture_path).unwrap()).unwrap();
let upstream_origin = upstream_base
.as_ref()
.split("/api/admin/workspaces/")
.next()
.unwrap();
fixture["servers"] = json!([{ "url": upstream_origin }]);
let document = serde_json::to_string(&fixture).unwrap();
let plan = create_plan(&client, &base_url, &document, full_plan()).await;
assert_eq!(plan.body["counts"]["actionable"], 1);
let (status, report) = apply_plan(&client, &base_url, &plan, "corpus-ac4-import").await;
assert_eq!(status, reqwest::StatusCode::OK, "Apply failed: {report}");
assert!(report_has_outcome_status(&report, "created"));
let operations = operation_list(&client, &base_url).await;
assert_eq!(operations["total"], 1);
assert_eq!(operations["items"][0]["status"], "draft");
let operation_id = operations["items"][0]["id"].as_str().unwrap().to_owned();
// The admin test run performs the persisted Draft validation and a real
// HTTP execution against the local fixture server before publication.
let test_run = client
.post(format!("{base_url}/operations/{operation_id}/test-runs"))
.json(&json!({"version":1,"input":{}}))
.send()
.await
.unwrap();
assert_eq!(test_run.status(), reqwest::StatusCode::OK);
let test_result: Value = test_run.json().await.unwrap();
assert_eq!(test_result["ok"], true, "Draft test failed: {test_result}");
let published = client
.post(format!("{base_url}/operations/{operation_id}/publish"))
.header(
reqwest::header::IF_MATCH,
operation_etag(&client, &base_url, &operation_id).await,
)
.json(&json!({"version":1}))
.send()
.await
.unwrap();
assert_eq!(published.status(), reqwest::StatusCode::OK);
let agent = client.post(format!("{base_url}/agents")).json(&json!({
"slug":"corpus-regression-agent","display_name":"Corpus Regression Agent",
"description":"Local corpus acceptance fixture","instructions":{},"tool_selection_policy":{}
})).send().await.unwrap().json::<Value>().await.unwrap();
let agent_id = agent["agent_id"].as_str().unwrap();
let bindings = client.post(format!("{base_url}/agents/{agent_id}/bindings"))
.header(reqwest::header::IF_MATCH, agent_etag(&client, &base_url, agent_id).await)
.json(&json!([{"operation_id":operation_id,"operation_version":1,"tool_name":"corpusOperation00","tool_title":"Synthetic operation 00","enabled":true}]))
.send().await.unwrap();
assert_eq!(bindings.status(), reqwest::StatusCode::OK);
let agent_publish = client
.post(format!("{base_url}/agents/{agent_id}/publish"))
.header(
reqwest::header::IF_MATCH,
agent_etag(&client, &base_url, agent_id).await,
)
.json(&json!({"version":1}))
.send()
.await
.unwrap();
assert_eq!(agent_publish.status(), reqwest::StatusCode::OK);
let mcp = crank_community_mcp::build_app(
registry,
Duration::ZERO,
None,
test_secret_crypto(),
crank_runtime::community_with_outbound_policy(
crank_runtime::OutboundHttpPolicy::allowing_hosts(["127.0.0.1"]),
)
.build(),
crank_runtime::RequestRateLimiter::new(
crank_runtime::RequestRateLimitConfig::new(100, 100).unwrap(),
),
Arc::new(crank_runtime::InMemoryCoordinationStateStore::default()),
Arc::new(InMemorySessionStore::default()),
Arc::new(CorpusMcpCredentialVerifier),
);
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
let address = listener.local_addr().unwrap();
tokio::spawn(async move {
axum::serve(listener, mcp).await.unwrap();
});
let mcp_base = format!("http://{address}");
let mcp_url = format!("{mcp_base}/v1/default/corpus-regression-agent");
let initialized = client.post(&mcp_url).bearer_auth("corpus-test-token")
.header("accept", "application/json, text/event-stream")
.json(&json!({"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"corpus","version":"1"}}}))
.send().await.unwrap();
assert_eq!(initialized.status(), reqwest::StatusCode::OK);
let session = initialized
.headers()
.get("mcp-session-id")
.unwrap()
.to_str()
.unwrap()
.to_owned();
let notification = client
.post(&mcp_url)
.bearer_auth("corpus-test-token")
.header("accept", "application/json, text/event-stream")
.header("mcp-session-id", &session)
.header("mcp-protocol-version", "2025-11-25")
.json(&json!({"jsonrpc":"2.0","method":"notifications/initialized","params":{}}))
.send()
.await
.unwrap();
assert_eq!(notification.status(), reqwest::StatusCode::ACCEPTED);
let called = client.post(&mcp_url).bearer_auth("corpus-test-token")
.header("accept", "application/json, text/event-stream").header("mcp-session-id", session)
.header("mcp-protocol-version", "2025-11-25")
.json(&json!({"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"corpusOperation00","arguments":{}}}))
.send().await.unwrap();
assert_eq!(called.status(), reqwest::StatusCode::OK);
let call: Value = called.json().await.unwrap();
assert_eq!(call["result"]["isError"], false, "MCP call failed: {call}");
assert_eq!(call["result"]["structuredContent"]["id"], "corpus-0");
for stage in ["Draft test run", "MCP call"] {
let (method, uri) = request_rx
.try_recv()
.unwrap_or_else(|_| panic!("{stage} missed upstream"));
assert_eq!(method, axum::http::Method::GET, "{stage}");
assert_eq!(uri.path(), "/items/0", "{stage}");
}
}
mod corpus_hostile;
@@ -0,0 +1,295 @@
use super::*;
#[tokio::test(flavor = "multi_thread")]
#[serial]
async fn ac_5_hostile_corpus_cases_are_bounded_atomic_and_redacted() {
let registry = test_registry().await;
let base_url = spawn_admin_api(build_test_app(registry, test_storage_root("corpus_ac5"))).await;
let client = authorized_client(&base_url).await;
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../crates/crank-import/tests/corpus");
let hostile_xml = std::fs::read_to_string(root.join("hostile-xml.json")).unwrap();
let before = operation_list(&client, &base_url).await;
let started = std::time::Instant::now();
let plan = create_plan(&client, &base_url, &hostile_xml, full_plan()).await;
assert!(
started.elapsed() < Duration::from_secs(5),
"hostile document exceeded bounded test budget"
);
assert!(
plan.body["counts"]["blocked"].as_u64().unwrap_or(0) > 0,
"hostile XML must be a blocker: {}",
plan.body
);
let xml_candidate = &plan.preview["preview"]["groups"][0]["operations"][0];
assert_eq!(xml_candidate["key"], "GET /xml");
assert!(
xml_candidate["findings"]
.as_array()
.is_some_and(|findings| findings.iter().any(|finding| finding["code"]
== "unsupported_xml_response_media_type"
&& finding["severity"] == "error")),
"HTTP preview must expose the exact XML blocker: {}",
plan.preview
);
assert_eq!(
plan.body["candidates"][0]["reason"], "unsupported_xml_response_media_type",
"HTTP plan must retain the XML blocker: {}",
plan.body
);
let (status, report) = apply_plan(&client, &base_url, &plan, "corpus-ac5-hostile").await;
assert_eq!(
status,
reqwest::StatusCode::CONFLICT,
"blocker must reject atomically: {report}"
);
assert_eq!(operation_list(&client, &base_url).await, before);
let secret = std::fs::read_to_string(root.join("hostile-secret.json")).unwrap();
let secret_plan = create_plan(&client, &base_url, &secret, full_plan()).await;
let exposed = format!("{}{}", secret_plan.preview, secret_plan.body);
assert!(
!exposed.contains("sk_test_corpus_secret_canary"),
"secret canary leaked into plan evidence"
);
assert_eq!(operation_list(&client, &base_url).await, before);
for file in ["hostile-malformed.json", "hostile-oversized.json"] {
let source = std::fs::read(root.join(file)).unwrap();
let started = std::time::Instant::now();
let upload = reqwest::multipart::Part::bytes(source)
.file_name(file)
.mime_str("application/json")
.unwrap();
let response = client
.post(format!("{base_url}/imports/openapi/preview"))
.multipart(reqwest::multipart::Form::new().part("file", upload))
.send()
.await
.unwrap();
let status = response.status();
let body = response.text().await.unwrap_or_default();
assert!(
!status.is_success(),
"{file} unexpectedly passed preview: {body}"
);
assert!(
started.elapsed() < Duration::from_secs(5),
"{file} exceeded bounded upload/parse time"
);
assert!(
!body.contains("sk_test_corpus_secret_canary"),
"hostile error response leaked a secret canary"
);
assert_eq!(
operation_list(&client, &base_url).await,
before,
"{file} mutated the operation registry"
);
}
// Real HTTP preview+plan: a root security requirement combined with an
// explicit empty operation override must leave the public operation
// actionable and block only the inherited one. No Apply mutation follows.
let mixed_security: Value = serde_json::json!({
"openapi": "3.0.3",
"info": { "title": "Mixed security plan probe", "version": "1" },
"servers": [{ "url": "https://security.example.test" }],
"components": { "securitySchemes": { "probe": { "type": "http", "scheme": "basic" } } },
"security": [{ "probe": [] }],
"paths": {
"/public": { "get": { "security": [], "operationId": "securityPublic",
"responses": { "200": { "description": "ok" } } } },
"/secured": { "get": { "operationId": "securitySecured",
"responses": { "200": { "description": "ok" } } } }
}
});
let security_mixed = serde_json::to_string(&mixed_security).unwrap();
let security_plan = create_plan(&client, &base_url, &security_mixed, full_plan()).await;
assert_eq!(
security_plan.body["counts"]["selected"], 2,
"{}",
security_plan.body
);
assert_eq!(
security_plan.body["counts"]["actionable"], 1,
"{}",
security_plan.body
);
assert_eq!(
security_plan.body["counts"]["blocked"], 1,
"{}",
security_plan.body
);
let security_candidates = security_plan.body["candidates"].as_array().unwrap();
let by_key = |key: &str| {
security_candidates
.iter()
.find(|candidate| candidate["key"] == key)
.unwrap_or_else(|| panic!("candidate {key} missing: {}", security_plan.body))
};
let public = by_key("GET /public");
let secured = by_key("GET /secured");
assert_eq!(
public["state"].as_str(),
Some("actionable"),
"public candidate with empty security override must stay actionable: {}",
security_plan.body
);
assert!(
public["reason"].is_null(),
"public candidate must not carry a security blocker: {}",
security_plan.body
);
assert_eq!(
secured["state"].as_str(),
Some("blocked"),
"inherited security requirement must block the affected candidate: {}",
security_plan.body
);
assert_eq!(
secured["reason"].as_str(),
Some("unsupported_security_requirement"),
"secured candidate must expose the exact security blocker: {}",
security_plan.body
);
assert_eq!(
operation_list(&client, &base_url).await,
before,
"security-scoped plan must not mutate the operation registry"
);
let (blocked_status, blocked_report) = apply_plan(
&client,
&base_url,
&security_plan,
"corpus-ac5-security-blocked",
)
.await;
assert_eq!(
blocked_status,
reqwest::StatusCode::CONFLICT,
"{blocked_report}"
);
assert_eq!(operation_list(&client, &base_url).await, before);
let public_plan = create_plan(
&client,
&base_url,
&security_mixed,
json!({
"selection_mode": "partial",
"selected_operation_keys": ["GET /public"]
}),
)
.await;
assert_eq!(public_plan.body["counts"]["actionable"], 1);
assert_eq!(public_plan.body["counts"]["blocked"], 0);
let (public_status, public_report) = apply_plan(
&client,
&base_url,
&public_plan,
"corpus-ac5-security-public",
)
.await;
assert_eq!(public_status, reqwest::StatusCode::OK, "{public_report}");
assert!(report_has_outcome_status(&public_report, "created"));
let after = operation_list(&client, &base_url).await;
assert_eq!(after["total"], 1, "{after}");
}
#[tokio::test(flavor = "multi_thread")]
#[serial]
async fn p0_api_malformed_local_security_is_atomic_across_openapi_versions() {
for (version, document) in [
(
"openapi-3.1",
serde_json::json!({
"openapi": "3.1.0",
"info": { "title": "Security API regression", "version": "1" },
"servers": [{ "url": "https://security.example.test" }],
"security": [{ "probe": [] }],
"paths": {
"/bad": { "get": { "security": "basic", "operationId": "badOp",
"responses": { "200": { "description": "ok" } } } },
"/public": { "get": { "security": [], "operationId": "publicOp",
"responses": { "200": { "description": "ok" } } } }
}
}),
),
(
"swagger-2.0",
serde_json::json!({
"swagger": "2.0",
"info": { "title": "Security API regression", "version": "1" },
"host": "security.example.test",
"schemes": ["https"],
"security": [{ "apiKey": [] }],
"paths": {
"/bad": { "get": { "security": "apikey", "operationId": "badOp",
"responses": { "200": { "description": "ok" } } } },
"/public": { "get": { "security": [], "operationId": "publicOp",
"responses": { "200": { "description": "ok" } } } }
}
}),
),
] {
let registry = test_registry().await;
let base_url = spawn_admin_api(build_test_app(
registry,
test_storage_root(&format!("security_api_{version}")),
))
.await;
let client = authorized_client(&base_url).await;
let source = serde_json::to_string(&document).unwrap();
let before = operation_list(&client, &base_url).await;
let plan = create_plan(&client, &base_url, &source, full_plan()).await;
assert_eq!(
plan.body["counts"]["actionable"], 1,
"{version}: {}",
plan.body
);
assert_eq!(
plan.body["counts"]["blocked"], 1,
"{version}: {}",
plan.body
);
let candidates = plan.body["candidates"].as_array().unwrap();
let bad = candidates
.iter()
.find(|item| item["key"] == "GET /bad")
.unwrap();
let public = candidates
.iter()
.find(|item| item["key"] == "GET /public")
.unwrap();
assert_eq!(bad["state"], "blocked", "{version}: {}", plan.body);
assert_eq!(bad["reason"], "unsupported_security_requirement");
assert_eq!(public["state"], "actionable", "{version}: {}", plan.body);
assert!(public["reason"].is_null());
let (status, report) = apply_plan(&client, &base_url, &plan, "security-full").await;
assert_eq!(status, reqwest::StatusCode::CONFLICT, "{version}: {report}");
assert_eq!(operation_list(&client, &base_url).await, before);
let public_plan = create_plan(
&client,
&base_url,
&source,
json!({
"selection_mode": "partial",
"selected_operation_keys": ["GET /public"]
}),
)
.await;
assert_eq!(public_plan.body["counts"]["actionable"], 1);
assert_eq!(public_plan.body["counts"]["blocked"], 0);
let (status, report) =
apply_plan(&client, &base_url, &public_plan, "security-public").await;
assert_eq!(status, reqwest::StatusCode::OK, "{version}: {report}");
assert!(report_has_outcome_status(&report, "created"));
let after = operation_list(&client, &base_url).await;
assert_eq!(after["total"], 1, "{version}: {after}");
assert_eq!(after["items"][0]["status"], "draft");
}
}
+1
View File
@@ -13,5 +13,6 @@ crank-schema = { path = "../crank-schema" }
serde.workspace = true
serde_json.workspace = true
serde_yaml.workspace = true
sha2.workspace = true
thiserror.workspace = true
url.workspace = true
+1
View File
@@ -12,6 +12,7 @@ mod normalize_finding_validation;
mod normalize_limits;
mod normalize_projection;
mod normalize_schema;
mod normalize_security;
mod openapi3;
mod openapi3_findings;
mod payload;
@@ -146,6 +146,7 @@ pub fn normalize_verified_bundle(
}
None => return Err(ImportParseError::UnsupportedDocument),
};
super::normalize_security::append_security_requirement_findings(&mut parsed, &root);
super::metadata_findings::collect_secret_like_examples(
&root,
"",
@@ -238,6 +239,8 @@ fn preview_from_operations<'a>(
.push(candidate);
}
super::normalize_security::attach_operation_findings(&mut groups, &findings);
sort_findings(&mut findings);
ImportPreview {
source: source.clone(),
@@ -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));
@@ -0,0 +1,166 @@
//! Effective per-operation security scopes for the OpenAPI importer.
use serde_json::Value;
use super::{
model::{
ImportFinding, ImportFindingSeverity, ImportGroupPreview, RestImportDocument,
RestImportOperation, SourceLocation,
},
normalize_coverage,
};
pub(super) fn attach_operation_findings(
groups: &mut std::collections::BTreeMap<String, ImportGroupPreview>,
findings: &[ImportFinding],
) {
for group in groups.values_mut() {
for candidate in &mut group.operations {
let additions = findings
.iter()
.filter(|finding| {
finding.severity == ImportFindingSeverity::Error
&& finding.operation_key.as_deref() == Some(candidate.key.as_str())
&& !candidate.findings.iter().any(|existing| {
existing.code == finding.code
&& existing.severity == finding.severity
&& existing.message == finding.message
})
})
.cloned()
.collect::<Vec<_>>();
candidate.findings.extend(additions);
}
}
}
/// Computes the effective security requirements for every candidate operation
/// and attaches source-located blockers to precisely the affected candidates.
///
/// Effective requirements follow the OpenAPI semantics: an operation that
/// declares its own `security` member wins over the document root; an empty
/// array (`security: []`) explicitly disables inheritance. Within a
/// requirement array the items are alternatives (OR): an empty requirement
/// object `{}` is the public alternative and makes the whole operation
/// public, so no blocker is produced for that operation.
///
/// A malformed security shape — a non-array `security` value or a non-object
/// array item — must never be discarded silently: the affected operation
/// receives one blocker with the exact source location. A supported non-empty
/// requirement remains a blocker until an administrator binds a compatible
/// Auth Profile.
pub(super) fn append_security_requirement_findings(parsed: &mut RestImportDocument, root: &Value) {
let operations = &parsed.operations;
let findings = &mut parsed.findings;
let locations = &mut parsed.internal_finding_locations;
let root_security = root.get("security");
for operation in operations {
let Some(path_item) = root
.pointer(&format!(
"/paths/{}",
normalize_coverage::escape_pointer(&operation.path)
))
.and_then(|item| item.get(method_as_lower(operation)))
else {
continue;
};
let Some(security) = path_item
.get("security")
.or_else(|| root_security.filter(|_| path_item.get("security").is_none()))
else {
continue;
};
let base_pointer = if path_item.get("security").is_some() {
format!(
"/paths/{}/{}/security",
normalize_coverage::escape_pointer(&operation.path),
method_as_lower(operation)
)
} else {
"/security".to_owned()
};
let alternatives = match security.as_array() {
Some(alternatives) => alternatives,
None => {
push_security_blocker(
findings,
locations,
operation,
&base_pointer,
"security имеет некорректный формат: ожидается массив требований; операции с незапакованным блоком безопасности не публикуются.",
);
continue;
}
};
// Validate the item shapes first: only a fully well-formed array may
// use the empty requirement object `{}` as its public OR alternative.
if !alternatives
.iter()
.all(|requirement| requirement.as_object().is_some())
{
for (index, requirement) in alternatives.iter().enumerate() {
let pointer = format!("{base_pointer}/{index}");
match requirement.as_object() {
Some(schemes) if schemes.is_empty() => {
// In a malformed array the empty alternative does
// not make the operation public, but it also cannot
// block on its own.
continue;
}
Some(_) => push_security_blocker(
findings,
locations,
operation,
&pointer,
"Требование безопасности должно быть привязано к настроенному Auth Profile перед публикацией этой операции; остальные операции не блокируются.",
),
None => push_security_blocker(
findings,
locations,
operation,
&pointer,
"security содержит альтернативу без объекта требований: формат не поддерживается, операция не публикуется.",
),
}
}
continue;
}
if alternatives.iter().any(|requirement| {
requirement
.as_object()
.is_some_and(serde_json::Map::is_empty)
}) {
continue;
}
for (index, _) in alternatives.iter().enumerate() {
push_security_blocker(
findings,
locations,
operation,
&format!("{base_pointer}/{index}"),
"Требование безопасности должно быть привязано к настроенному Auth Profile перед публикацией этой операции; остальные операции не блокируются.",
);
}
}
}
fn push_security_blocker(
findings: &mut Vec<ImportFinding>,
locations: &mut Vec<Option<SourceLocation>>,
operation: &RestImportOperation,
pointer: &str,
message: &str,
) {
findings.push(ImportFinding {
code: "unsupported_security_requirement".to_owned(),
severity: ImportFindingSeverity::Error,
message: message.to_owned(),
operation_key: Some(operation.key.clone()),
});
locations.push(Some(SourceLocation {
pointer: pointer.to_owned(),
}));
}
fn method_as_lower(operation: &RestImportOperation) -> String {
format!("{:?}", operation.method).to_ascii_lowercase()
}
@@ -0,0 +1,29 @@
{
"actionable_count": 50,
"content_digest": "296bb06a311615952c4688089515f514d417bf75b05645fb82ffaa41b92c73ad",
"content_digest_algorithm": "sha256",
"content_digest_definition": "SHA-256 of compact key-sorted JSON before the content_digest field is added.",
"corpus_version": "1.0.3",
"denominator": 50,
"evidence_identity": "be17fbf86429a8953acba4f3e8114d47c088305c0b1720678c4ffea8476f4f24",
"evidence_version": "1.0.0",
"exclusions": [],
"manifest_digest": "2abf220447fc73547583eab65370b84d1f3353a203909e16216d48b055919b47",
"matrix_contract": {
"construct_rows": 384,
"semantic_probes": "AC-1 runs a generated normalizer probe for every matrix row, including every 2xx status in all three formats."
},
"matrix_digest": "29f1e93850b057bb374895d60a8b2dacc8d01371b53d579f558c9dd2b85aa209",
"matrix_version": "1.0.2",
"method": "real normalize_verified_document + preview_from_ir; every NormalizedIr passed validate_normalized_ir",
"raw_counts": {
"covered_source_constructs": 1837,
"documents": 63,
"findings": 0,
"representative_operations": 50,
"semantic_coverage_entries": 514,
"source_constructs": 1837
},
"silent_loss_count": 0,
"uncovered_source_constructs": []
}
+973
View File
@@ -0,0 +1,973 @@
//! Offline regression gates for the versioned OpenAPI support matrix and corpus.
use crank_import::rest::model::CoverageDisposition;
use crank_import::rest::model::{CanonicalSourceNode, CanonicalSourceValue};
use crank_import::rest::{
ImportParseError, NormalizationConfig, SourceDigest, normalize_verified_document,
preview_from_ir, validate_normalized_ir,
};
use serde::Deserialize;
use serde_json::{Value, json};
use sha2::{Digest, Sha256};
use std::{
fs,
path::{Path, PathBuf},
};
#[path = "corpus/matrix.rs"]
mod matrix;
fn tests_root() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR")).join("tests")
}
fn hex(bytes: impl AsRef<[u8]>) -> String {
Sha256::digest(bytes)
.iter()
.map(|b| format!("{b:02x}"))
.collect()
}
fn canonical_json(value: &Value) -> Vec<u8> {
serde_json::to_vec(value).expect("JSON values serialize")
}
fn escape_pointer(value: &str) -> String {
value.replace('~', "~0").replace('/', "~1")
}
fn source_ledger(
value: &Value,
pointer: &str,
ledger: &mut std::collections::BTreeMap<String, Value>,
) {
assert!(ledger.insert(pointer.to_owned(), value.clone()).is_none());
match value {
Value::Array(items) => {
for (index, item) in items.iter().enumerate() {
source_ledger(item, &format!("{pointer}/{index}"), ledger);
}
}
Value::Object(fields) => {
for (key, item) in fields {
source_ledger(item, &format!("{pointer}/{}", escape_pointer(key)), ledger);
}
}
_ => {}
}
}
fn canonical_source_ledger(
node: &CanonicalSourceNode,
ledger: &mut std::collections::BTreeMap<String, Value>,
) -> Value {
let value = match &node.value {
CanonicalSourceValue::Null => Value::Null,
CanonicalSourceValue::Boolean(value) => json!(value),
CanonicalSourceValue::Number(value) => {
serde_json::from_str(value).expect("canonical number")
}
CanonicalSourceValue::String(value) => json!(value),
CanonicalSourceValue::Array(items) => Value::Array(
items
.iter()
.map(|item| canonical_source_ledger(item, ledger))
.collect(),
),
CanonicalSourceValue::Object(items) => {
let mut fields = serde_json::Map::new();
for (key, item) in items {
fields.insert(key.clone(), canonical_source_ledger(item, ledger));
}
Value::Object(fields)
}
};
assert!(
ledger
.insert(node.location.pointer.clone(), value.clone())
.is_none()
);
value
}
#[derive(Debug, Deserialize)]
struct Manifest {
corpus_version: String,
matrix_version: String,
compatibility_impact: String,
documents: Vec<Document>,
}
#[derive(Debug, Deserialize)]
struct Document {
id: String,
file: String,
sha256: String,
canonical_digest: Option<String>,
origin: String,
license: String,
specification_version: String,
classification: String,
expected_preview: Value,
}
fn manifest() -> Manifest {
serde_json::from_slice(
&fs::read(tests_root().join("corpus/manifest.json")).expect("manifest exists"),
)
.expect("manifest JSON is valid")
}
fn normalize(source: &str) -> Result<crank_import::rest::NormalizedIr, ImportParseError> {
let source_digest = SourceDigest::parse(hex(source.as_bytes())).expect("sha256 is valid");
normalize_verified_document(source, source_digest, &NormalizationConfig::default())
}
#[test]
fn ac_2_manifest_covers_fifty_provenanced_specs_with_exact_expectations() {
let manifest = manifest();
assert_eq!(manifest.corpus_version, "1.0.3");
assert_eq!(manifest.matrix_version, "1.0.2");
assert!(!manifest.compatibility_impact.trim().is_empty());
assert!(manifest.documents.len() >= 50);
let root = tests_root().join("corpus");
let mut versions = std::collections::BTreeSet::new();
let mut representative_count = 0;
for document in &manifest.documents {
assert!(!document.id.is_empty());
assert!(
document.origin.starts_with("synthetic:"),
"{} lacks provenance",
document.id
);
assert!(
document.license.contains("CC0"),
"{} lacks license",
document.id
);
assert_eq!(document.sha256.len(), 64);
versions.insert(document.specification_version.as_str());
let source = fs::read(root.join(&document.file))
.unwrap_or_else(|e| panic!("{}: {e}", document.file));
assert_eq!(
hex(&source),
document.sha256,
"checksum mismatch for {}",
document.file
);
if let Ok(value) = serde_json::from_slice::<Value>(&source) {
let digest = hex(canonical_json(&value));
assert_eq!(
document.canonical_digest.as_deref(),
Some(digest.as_str()),
"canonical digest mismatch for {}",
document.file
);
} else {
assert!(
document.canonical_digest.is_none(),
"malformed JSON has no canonical digest"
);
}
if document.classification == "representative" {
representative_count += 1;
let text = std::str::from_utf8(&source).expect("fixtures are UTF-8");
let ir =
normalize(text).unwrap_or_else(|e| panic!("{} failed parser: {e}", document.file));
validate_normalized_ir(&ir).expect("normalized IR has explicit source coverage");
let preview = preview_from_ir(&ir);
let repeated_preview =
preview_from_ir(&normalize(text).expect("repeat normalization succeeds"));
assert_eq!(
serde_json::to_value(&preview).unwrap(),
serde_json::to_value(&repeated_preview).unwrap(),
"deterministic preview diff for {}:\nexpected={}\nactual={}",
document.file,
serde_json::to_string_pretty(&preview).unwrap(),
serde_json::to_string_pretty(&repeated_preview).unwrap(),
);
let candidates = preview
.groups
.iter()
.flat_map(|g| &g.operations)
.collect::<Vec<_>>();
assert_eq!(
candidates.len(),
document.expected_preview["operation_count"]
.as_u64()
.unwrap() as usize,
"operation count in {}",
document.file
);
assert_eq!(
candidates.len(),
1,
"corpus fixtures are single-operation exact oracles"
);
let expected = &document.expected_preview["operations"][0];
let actual_candidate = serde_json::to_value(candidates[0]).unwrap();
assert_eq!(
actual_candidate,
expected["candidate"],
"frozen candidate diff for {}:\nexpected={}\nactual={}",
document.file,
serde_json::to_string_pretty(&expected["candidate"]).unwrap(),
serde_json::to_string_pretty(&actual_candidate).unwrap(),
);
let blocking_codes = candidates[0]
.findings
.iter()
.filter(|finding| {
finding.severity == crank_import::rest::ImportFindingSeverity::Error
})
.map(|finding| finding.code.clone())
.collect::<Vec<_>>();
assert_eq!(json!(blocking_codes), expected["blocker_codes"]);
assert_eq!(
blocking_codes.is_empty(),
expected["actionable"].as_bool().unwrap()
);
assert_eq!(
hex(canonical_json(&actual_candidate)),
expected["candidate_digest"],
"candidate canonical digest in {}",
document.file
);
assert_eq!(
hex(canonical_json(&serde_json::to_value(&preview).unwrap())),
document.expected_preview["canonical_preview_digest"],
"preview canonical digest in {}",
document.file
);
let actual_preview = serde_json::to_value(&preview).unwrap();
assert_eq!(
actual_preview,
document.expected_preview["canonical_preview"],
"frozen readable preview diff for {}:\nexpected={}\nactual={}",
document.file,
serde_json::to_string_pretty(&document.expected_preview["canonical_preview"])
.unwrap(),
serde_json::to_string_pretty(&actual_preview).unwrap(),
);
assert_eq!(
serde_json::to_value(candidates[0].method).unwrap().as_str(),
expected["method"].as_str()
);
assert_eq!(candidates[0].path, expected["path"].as_str().unwrap());
assert_eq!(
candidates[0].operation_id.as_deref(),
expected["operation_id"].as_str()
);
assert!(
preview.findings.is_empty(),
"unexpected preview findings in {}: {:?}",
document.file,
preview.findings
);
let mut actual_findings = candidates[0]
.findings
.iter()
.map(|f| f.code.as_str())
.collect::<Vec<_>>();
let mut expected_findings = document.expected_preview["finding_codes"]
.as_array()
.unwrap()
.iter()
.map(|v| v.as_str().unwrap())
.collect::<Vec<_>>();
actual_findings.sort_unstable();
expected_findings.sort_unstable();
assert_eq!(
actual_findings, expected_findings,
"finding codes in {}",
document.file
);
} else {
assert_eq!(document.classification, "hostile");
let text = std::str::from_utf8(&source).unwrap();
let parsed = normalize(text);
assert_eq!(
parsed,
normalize(text),
"hostile parser result changed on deterministic rerun for {}",
document.file
);
if [
"hostile-empty.json",
"hostile-malformed.json",
"hostile-oversized.json",
"hostile-deep.json",
"hostile-aliases.yaml",
]
.contains(&document.file.as_str())
{
if [
"hostile-oversized.json",
"hostile-deep.json",
"hostile-aliases.yaml",
]
.contains(&document.file.as_str())
{
assert!(
matches!(parsed, Err(ImportParseError::LimitExceeded)),
"{} must fail within configured bounds: {parsed:?}",
document.file
);
} else {
assert!(parsed.is_err(), "{} must be rejected", document.file);
}
} else if document.file == "hostile-trace.json" {
let ir = parsed.expect("TRACE is reported instead of silently discarded");
assert!(
ir.findings
.iter()
.any(|f| f.code == "unsupported_http_method")
);
assert!(ir.coverage.iter().any(|c| c.construct_id.contains("trace")
&& c.disposition == CoverageDisposition::Finding));
} else if document.file == "hostile-xml.json" {
let ir = parsed.expect("XML is represented by an explicit finding");
let preview = preview_from_ir(&ir);
let codes = preview
.groups
.iter()
.flat_map(|g| &g.operations)
.flat_map(|o| &o.findings)
.map(|f| f.code.as_str())
.collect::<Vec<_>>();
assert!(
codes
.iter()
.any(|code| code.contains("xml") || code.contains("media")),
"XML findings: {codes:?}"
);
} else if document.file == "hostile-secret.json" {
let ir = parsed.expect("secret-like examples remain inspectable");
let evidence = serde_json::to_string(&preview_from_ir(&ir)).unwrap();
assert!(
!evidence.contains("sk_test_corpus_secret_canary"),
"secret canary leaked into preview evidence"
);
} else {
let ir = parsed.unwrap_or_else(|error| {
panic!(
"{} must have an explicit finding or bounded rejection: {error}",
document.file
)
});
validate_normalized_ir(&ir).expect("hostile construct coverage remains explicit");
assert!(
!ir.coverage.is_empty(),
"{} has no construct ledger",
document.file
);
let preview = preview_from_ir(&ir);
match document.file.as_str() {
"hostile-cycle.json" => {
assert_eq!(
ir.operations.len(),
1,
"recursive schema must not drop the source operation"
);
assert!(
ir.findings
.iter()
.chain(ir.operations.iter().flat_map(|op| &op.findings))
.all(|finding| {
finding.severity
!= crank_import::rest::ImportFindingSeverity::Error
}),
"bounded cycle policy must not yield an unexplained blocker: {:?} {:?}",
ir.findings,
ir.operations.iter().map(|op| &op.findings)
);
assert!(
ir.unresolved_references.is_empty(),
"resolved recursion must not be reported as unresolvable: {:?}",
ir.unresolved_references
);
let cycle_edge = |recursive: bool| {
ir.reference_graph.edges.iter().any(|edge| {
edge.recursive == recursive
&& edge.source.location.pointer
== "/components/schemas/Node/properties/next/$ref"
&& edge.target.location.pointer == "/components/schemas/Node"
})
};
assert!(
cycle_edge(false) && cycle_edge(true),
"Node.next must resolve through both bounded and recursive edges: {:?}",
ir.reference_graph.edges
);
let response = ir.operations[0]
.response_variants
.iter()
.find(|variant| variant.status_code == 200)
.expect("200 response is retained");
assert!(
matches!(
&response.schema,
Some(schema) if matches!(
&schema.kind,
crank_import::rest::NormalizedSchemaKind::Object {
properties, ..
} if properties.contains_key("next")
)
),
"recursive node schema must be projected: {:?}",
response.schema
);
assert!(
ir.coverage.iter().any(|entry| {
entry.location.pointer
== "/components/schemas/Node/properties/next/properties/next"
&& entry.disposition == CoverageDisposition::Mapped
}),
"bounded recursion must remain Mapped in the resolved source ledger: {:?}",
ir.coverage
);
assert_eq!(
document.expected_preview["mapped_recursive_pointer"].as_str(),
Some("/components/schemas/Node/properties/next/properties/next")
);
assert_eq!(
ir.findings
.iter()
.map(|f| (f.code.clone(), f.severity.clone()))
.collect::<Vec<_>>(),
vec![(
"missing_servers".to_owned(),
crank_import::rest::ImportFindingSeverity::Warning
)],
"cycle fixture must expose only the exact bounded warning set: {:?}",
ir.findings
);
assert_eq!(
document.expected_preview["operation_count"].as_u64(),
Some(1)
);
assert_eq!(
document.expected_preview["recursive_edge"]["source"].as_str(),
Some("/components/schemas/Node/properties/next/$ref")
);
assert_eq!(
document.expected_preview["recursive_edge"]["target"].as_str(),
Some("/components/schemas/Node")
);
assert_eq!(document.expected_preview["blocker_findings"], json!([]));
assert_eq!(
document.expected_preview["unresolved_references"],
json!([])
);
assert_eq!(
document.expected_preview["warning_findings"],
json!([{"code":"missing_servers","severity":"Warning","operation_key":null}])
);
}
"hostile-external-ref.json" => assert!(
ir.findings.iter()
.chain(ir.operations.iter().flat_map(|op| &op.findings))
.any(|finding| finding.code == "external_reference_disabled"
&& finding.location.pointer == "/paths/~1hostile/get/responses/200/content/application~1json/schema/$ref"),
"external ref must be denied at its source: {:?}",
ir.findings
),
"hostile-duplicate-ids.json" => assert_eq!(
ir.operations.len(),
2,
"duplicate IDs must not drop a source operation"
),
"hostile-composition-conflict.json" => {
assert_eq!(
ir.operations.len(),
1,
"conflicting allOf must keep the source operation explicit"
);
let conflict = ir.operations[0]
.findings
.iter()
.find(|finding| finding.code == "all_of_conflict")
.unwrap_or_else(|| {
panic!(
"allOf conflict must be named: {:?}",
ir.operations[0].findings
)
});
assert_eq!(
conflict.severity,
crank_import::rest::ImportFindingSeverity::Error,
"allOf conflict must block the candidate: {:?}",
conflict
);
assert_eq!(
conflict.operation_key.as_deref(),
Some("GET /hostile"),
"conflict must belong to the affected candidate: {:?}",
conflict
);
assert_eq!(
conflict.location.pointer,
"/paths/~1hostile/get/responses/200/content/application~1json/schema/allOf",
"conflict must point at the conflicting allOf: {:?}",
conflict
);
assert!(
ir.coverage
.iter()
.any(|entry| {
entry.location
.pointer
== "/paths/~1hostile/get/responses/200/content/application~1json/schema/allOf"
})
&& ir
.operations[0]
.findings
.iter()
.any(|finding| finding.code == "all_of_conflict"
&& finding.location.pointer
== "/paths/~1hostile/get/responses/200/content/application~1json/schema/allOf"),
"conflicting allOf must stay in the source ledger bound to the explicit finding: {:?}",
ir.coverage
);
let response = ir.operations[0]
.response_variants
.iter()
.find(|variant| variant.status_code == 200)
.expect("200 response is retained");
assert!(
matches!(
&response.schema,
Some(schema) if matches!(
&schema.kind,
crank_import::rest::NormalizedSchemaKind::Composition {
operator, variants
} if operator == "allOf" && variants.len() == 2
)
),
"conflict branches must be preserved verbatim: {:?}",
response.schema
);
assert_eq!(
ir.findings
.iter()
.map(|f| (f.code.clone(), f.severity.clone()))
.collect::<Vec<_>>(),
vec![(
"missing_servers".to_owned(),
crank_import::rest::ImportFindingSeverity::Warning
)],
"composition conflict fixture must keep the exact warning set: {:?}",
ir.findings
);
assert_eq!(
document.expected_preview["operation_count"].as_u64(),
Some(1)
);
assert_eq!(
document.expected_preview["blocker_findings"],
json!([{"code":"all_of_conflict","severity":"Error",
"operation_key":"GET /hostile",
"location":"/paths/~1hostile/get/responses/200/content/application~1json/schema/allOf"}])
);
assert_eq!(
document.expected_preview["composition"],
json!({"operator":"allOf","branch_count":2})
);
assert_eq!(
document.expected_preview["warning_findings"],
json!([{"code":"missing_servers","severity":"Warning","operation_key":null}])
);
}
"hostile-security-scope.json" => {
assert_eq!(
ir.operations.len(),
2,
"security-scope fixture must keep both candidates explicit: {:?}",
ir.operations.iter().map(|op| &op.key).collect::<Vec<_>>()
);
let requirements = ir
.findings
.iter()
.filter(|finding| finding.code == "unsupported_security_requirement")
.collect::<Vec<_>>();
assert_eq!(
requirements.len(),
1,
"exactly the inherited requirement must produce a blocker: {:?}",
ir.findings
);
let requirement = &requirements[0];
assert_eq!(
requirement.severity,
crank_import::rest::ImportFindingSeverity::Error,
"security requirement must block its candidate: {:?}",
requirement
);
assert_eq!(
requirement.operation_key.as_deref(),
Some("GET /secure"),
"blocker must belong only to the inherited secured candidate: {:?}",
requirement
);
assert_eq!(
requirement.location.pointer, "/security/0",
"inherited requirement must point at the document root requirement: {:?}",
requirement
);
let mut by_key = std::collections::BTreeMap::new();
for group in &preview.groups {
for candidate in &group.operations {
by_key.insert(candidate.key.clone(), candidate);
}
}
let public = by_key.get("GET /public").expect("public candidate present");
assert!(
public.findings.iter().all(|finding| finding.severity
!= crank_import::rest::ImportFindingSeverity::Error),
"public operation with security: [] must stay actionable: {:?}",
public.findings
);
assert!(
by_key
.get("GET /secure")
.expect("secured candidate present")
.findings
.iter()
.any(|finding| finding.code == "unsupported_security_requirement"
&& finding.severity
== crank_import::rest::ImportFindingSeverity::Error),
"inherited requirement must block the secured candidate: {:?}",
by_key.get("GET /secure").unwrap().findings
);
assert!(
preview
.findings
.iter()
.all(|finding| finding.operation_key.is_some()),
"no document-global blocker may be produced: {:?}",
preview.findings
);
assert!(
ir.coverage
.iter()
.any(|entry| entry.location.pointer == "/security/0"
&& entry.disposition == CoverageDisposition::Finding),
"inherited requirement must stay in the source ledger bound to the finding: {:?}",
ir.coverage
);
let mut actual_operation_keys = preview
.groups
.iter()
.flat_map(|group| &group.operations)
.map(|op| op.key.clone())
.collect::<Vec<_>>();
actual_operation_keys.sort();
assert_eq!(
json!(actual_operation_keys),
document.expected_preview["operation_keys"],
"security-scope operation oracle for {}",
document.file
);
let actual_blockers = requirements
.iter()
.map(|finding| {
json!({"code": finding.code.clone(), "severity": "Error",
"operation_key": finding.operation_key.clone(),
"location": finding.location.pointer.clone()})
})
.collect::<Vec<_>>();
assert_eq!(
actual_blockers,
document.expected_preview["blocker_findings"]
.as_array()
.unwrap()
.clone(),
"security-scope blocker oracle for {}: actual {actual_blockers:?}",
document.file
);
let actual_warnings = ir
.findings
.iter()
.filter(|finding| {
finding.severity
== crank_import::rest::ImportFindingSeverity::Warning
})
.map(|finding| {
json!({"code": finding.code.clone(), "severity": "Warning",
"operation_key": finding.operation_key.clone()})
})
.collect::<Vec<_>>();
assert_eq!(
actual_warnings,
document.expected_preview["warning_findings"]
.as_array()
.unwrap()
.clone(),
"security-scope warning oracle for {}: actual {actual_warnings:?}",
document.file
);
}
_ => unreachable!("hostile fixture must have a dedicated expectation"),
}
}
}
}
// Exact file set: manifest rows are unique and every corpus data file is
// accounted exactly once, so duplicates or orphan fixtures cannot inflate
// or hide coverage.
let mut ids = std::collections::BTreeSet::new();
let mut files = std::collections::BTreeSet::new();
for document in &manifest.documents {
assert!(
ids.insert(document.id.clone()),
"duplicate manifest document id {}",
document.id
);
assert!(
files.insert(document.file.clone()),
"duplicate manifest file {}",
document.file
);
}
let expected_files = files
.into_iter()
.chain(std::iter::once("manifest.json".to_owned()))
.chain(std::iter::once("matrix.rs".to_owned()))
.collect::<std::collections::BTreeSet<_>>();
let actual_files = fs::read_dir(&root)
.expect("corpus directory exists")
.map(|entry| entry.unwrap().file_name().to_string_lossy().into_owned())
.collect::<std::collections::BTreeSet<_>>();
assert_eq!(
actual_files, expected_files,
"corpus directory must equal the manifest file set exactly"
);
assert_eq!(representative_count, 50);
assert!(
versions
.iter()
.any(|version| version.starts_with("OpenAPI 3.0"))
&& versions
.iter()
.any(|version| version.starts_with("OpenAPI 3.1"))
&& versions.contains("Swagger 2.0")
);
}
#[test]
fn ac_3_evidence_reports_actionable_denominator_exclusions_and_zero_silent_loss() {
let manifest = manifest();
let mut denominator = 0_u64;
let mut actionable_count = 0_u64;
let mut operation_count = 0_u64;
let mut source_construct_count = 0_u64;
let mut covered_source_construct_count = 0_u64;
let mut semantic_coverage_count = 0_u64;
let mut silent_loss = Vec::new();
let mut exclusions = Vec::new();
let mut finding_count = 0_u64;
for document in &manifest.documents {
if document.classification != "representative" {
continue;
}
let source_bytes = fs::read(tests_root().join("corpus").join(&document.file)).unwrap();
let source: Value =
serde_json::from_slice(&source_bytes).expect("representative corpus source is JSON");
let mut raw_ledger = std::collections::BTreeMap::new();
source_ledger(&source, "", &mut raw_ledger);
let source_text = std::str::from_utf8(&source_bytes).unwrap();
let ir = normalize(source_text).unwrap();
validate_normalized_ir(&ir).unwrap();
let mut normalized_ledger = std::collections::BTreeMap::new();
let _ = canonical_source_ledger(&ir.source_tree, &mut normalized_ledger);
assert_eq!(
normalized_ledger, raw_ledger,
"normalizer source-tree ledger differs from raw document for {}",
document.file
);
source_construct_count += raw_ledger.len() as u64;
let coverage_by_id = ir
.coverage
.iter()
.map(|entry| (entry.construct_id.as_str(), entry))
.collect::<std::collections::BTreeMap<_, _>>();
for pointer in raw_ledger.keys() {
let source_id = format!("source:{pointer}");
match coverage_by_id.get(source_id.as_str()) {
Some(entry)
if entry.location.pointer == *pointer
&& entry.disposition == CoverageDisposition::Mapped =>
{
covered_source_construct_count += 1;
}
_ => silent_loss.push(json!({"document":document.id,"source_pointer":pointer,"coverage_id":source_id})),
}
}
let findings = ir
.findings
.iter()
.chain(
ir.operations
.iter()
.flat_map(|operation| &operation.findings),
)
.collect::<Vec<_>>();
for entry in ir
.coverage
.iter()
.filter(|entry| !entry.construct_id.starts_with("source:"))
{
semantic_coverage_count += 1;
assert!(
raw_ledger.contains_key(&entry.location.pointer),
"coverage {} points outside raw source tree for {}",
entry.construct_id,
document.file
);
match entry.disposition {
CoverageDisposition::Mapped => {}
CoverageDisposition::Finding => assert!(
findings
.iter()
.any(|finding| finding.construct_id == entry.construct_id
&& finding.location == entry.location),
"finding coverage {} has no matching finding in {}",
entry.construct_id,
document.file
),
}
}
for operation in &ir.operations {
denominator += 1;
operation_count += 1;
if operation
.findings
.iter()
.all(|f| f.severity != crank_import::rest::ImportFindingSeverity::Error)
{
actionable_count += 1;
} else {
exclusions.push(json!({"document":document.id,"operation":operation.key,"reason":"blocking_finding","findings":operation.findings.iter().map(|f| &f.code).collect::<Vec<_>>()}));
}
}
finding_count += ir.findings.len() as u64;
}
assert!(denominator > 0);
assert!(
actionable_count * 100 >= denominator * 95,
"actionable {actionable_count}/{denominator}; exclusions={exclusions:?}"
);
let silent_loss_count = silent_loss.len() as u64;
assert_eq!(
source_construct_count, covered_source_construct_count,
"independently enumerated raw source constructs lack coverage: {silent_loss:?}"
);
let mut reversed_counts = (0_u64, 0_u64, 0_u64);
for document in manifest
.documents
.iter()
.rev()
.filter(|document| document.classification == "representative")
{
let source = fs::read_to_string(tests_root().join("corpus").join(&document.file)).unwrap();
let ir = normalize(&source).unwrap();
reversed_counts.0 += ir.operations.len() as u64;
reversed_counts.1 += ir
.operations
.iter()
.filter(|operation| {
operation.findings.iter().all(|finding| {
finding.severity != crank_import::rest::ImportFindingSeverity::Error
})
})
.count() as u64;
reversed_counts.2 += ir.findings.len() as u64;
}
assert_eq!(
reversed_counts,
(operation_count, actionable_count, finding_count),
"aggregate evidence must not depend on manifest order"
);
let manifest_bytes = fs::read(tests_root().join("corpus/manifest.json")).unwrap();
let manifest_digest = hex(&manifest_bytes);
let matrix_bytes = fs::read(tests_root().join("support-matrix.yaml")).unwrap();
let matrix_digest = hex(&matrix_bytes);
let matrix_value: serde_yaml::Value = serde_yaml::from_slice(&matrix_bytes).unwrap();
let matrix_row_count = matrix_value["constructs"].as_sequence().unwrap().len();
let evidence_identity = hex(format!(
"{}\n{}\n{}\n{}",
manifest.corpus_version, manifest.matrix_version, manifest_digest, matrix_digest
));
let mut evidence = json!({
"evidence_version":"1.0.0", "corpus_version":manifest.corpus_version, "matrix_version":manifest.matrix_version,
"evidence_identity":evidence_identity,
"content_digest_algorithm":"sha256",
"content_digest_definition":"SHA-256 of compact key-sorted JSON before the content_digest field is added.",
"manifest_digest":manifest_digest,
"matrix_digest":matrix_digest,
"denominator":denominator, "actionable_count":actionable_count, "exclusions":exclusions,
"raw_counts":{"documents":manifest.documents.len(),"representative_operations":operation_count,"findings":finding_count,"source_constructs":source_construct_count,"covered_source_constructs":covered_source_construct_count,"semantic_coverage_entries":semantic_coverage_count},
"matrix_contract":{"construct_rows":matrix_row_count,"semantic_probes":"AC-1 runs a generated normalizer probe for every matrix row, including every 2xx status in all three formats."},
"uncovered_source_constructs":silent_loss,
"silent_loss_count":silent_loss_count,
"method":"real normalize_verified_document + preview_from_ir; every NormalizedIr passed validate_normalized_ir"
});
let content_digest = hex(canonical_json(&evidence));
evidence["content_digest"] = json!(content_digest);
let artifact = Path::new(env!("CARGO_MANIFEST_DIR")).join(format!(
"target/openapi-corpus/evidence-{evidence_identity}.json"
));
let target_dir = artifact.parent().unwrap();
fs::create_dir_all(target_dir).unwrap();
let bytes = serde_json::to_vec_pretty(&evidence).unwrap();
// Each process needs its own temp file: concurrent corpus runs must not
// truncate each other's pending evidence before atomic publication.
let mut nonce = 0u32;
let (publish, mut file) = loop {
let path = target_dir.join(format!(
"evidence.json.tmp-{}-{}-{nonce}",
&evidence_identity[..16],
std::process::id()
));
match fs::OpenOptions::new()
.write(true)
.create_new(true)
.open(&path)
{
Ok(file) => break (path, file),
Err(error) if error.kind() == std::io::ErrorKind::AlreadyExists && nonce < 1024 => {
nonce += 1;
}
Err(error) => panic!(
"cannot create evidence temp file {}: {error}",
path.display()
),
}
};
{
use std::io::Write;
file.write_all(&bytes).unwrap();
file.sync_all().unwrap();
}
// hard_link fails atomically when the final identity already exists.
// Rename would silently overwrite after an exists-check race, while
// create_new on the final path would expose partial bytes after a crash.
let published = match fs::hard_link(&publish, &artifact) {
Ok(()) => true,
Err(error) if error.kind() == std::io::ErrorKind::AlreadyExists => false,
Err(error) => panic!(
"cannot publish immutable evidence artifact {}: {error}",
artifact.display()
),
};
fs::remove_file(&publish).ok();
if !published {
let existing = fs::read(&artifact).unwrap();
assert_eq!(
existing,
bytes,
"immutable evidence identity {evidence_identity} already has conflicting contents at {}",
artifact.display()
);
}
if let Ok(directory) = fs::File::open(target_dir) {
let _ = directory.sync_all();
}
let reread: Value = serde_json::from_slice(&fs::read(artifact).unwrap()).unwrap();
assert_eq!(reread, evidence);
assert_eq!(reread["silent_loss_count"], 0);
assert_eq!(source_construct_count, covered_source_construct_count);
assert_eq!(reread["denominator"], denominator);
assert_eq!(reread["actionable_count"], actionable_count);
}
@@ -0,0 +1,5 @@
openapi: 3.1.0
info: {title: Aliases, version: 1}
paths: {}
x-anchor: &anchor {type: string}
x-aliases: [*anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor, *anchor]
@@ -0,0 +1,43 @@
{
"openapi": "3.1.0",
"info": {
"title": "Hostile generated",
"version": "1"
},
"paths": {
"/hostile": {
"get": {
"operationId": "hostileOperation",
"responses": {
"200": {
"description": "ok",
"content": {
"application/json": {
"schema": {
"allOf": [
{
"type": "object",
"properties": {
"id": {
"type": "string"
}
}
},
{
"type": "object",
"properties": {
"id": {
"type": "integer"
}
}
}
]
}
}
}
}
}
}
}
}
}
@@ -0,0 +1,38 @@
{
"openapi": "3.1.0",
"info": {
"title": "Hostile generated",
"version": "1"
},
"paths": {
"/hostile": {
"get": {
"operationId": "hostileOperation",
"responses": {
"200": {
"description": "ok",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Node"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Node": {
"type": "object",
"properties": {
"next": {
"$ref": "#/components/schemas/Node"
}
}
}
}
}
}
@@ -0,0 +1 @@
{"openapi":"3.1.0","info":{"title":"Hostile generated","version":"1"},"paths":{"/hostile":{"get":{"operationId":"hostileOperation","responses":{"200":{"description":"ok","content":{"application/json":{"schema":{"type":"object"}}}}}}}},"components":{"schemas":{"Deep":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"array","items":{"type":"string"}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
@@ -0,0 +1,36 @@
{
"openapi": "3.1.0",
"info": {
"title": "Hostile generated",
"version": "1"
},
"paths": {
"/hostile": {
"get": {
"operationId": "hostileOperation",
"responses": {
"200": {
"description": "ok",
"content": {
"application/json": {
"schema": {
"$ref": "https://external.example.test/schema.json"
}
}
}
}
}
}
},
"/other": {
"post": {
"operationId": "hostileOperation",
"responses": {
"200": {
"description": "ok"
}
}
}
}
}
}
@@ -0,0 +1 @@
{}
@@ -0,0 +1,26 @@
{
"openapi": "3.1.0",
"info": {
"title": "Hostile generated",
"version": "1"
},
"paths": {
"/hostile": {
"get": {
"operationId": "hostileOperation",
"responses": {
"200": {
"description": "ok",
"content": {
"application/json": {
"schema": {
"$ref": "https://external.example.test/schema.json"
}
}
}
}
}
}
}
}
}
@@ -0,0 +1 @@
{"openapi":
@@ -0,0 +1,12 @@
{
"openapi": "3.1.0",
"info": {"title": "Hostile generated", "version": "1"},
"paths": {"/hostile": {"get": {"operationId": "hostileOperation", "responses": {"200": {"description": "ok", "content": {"application/json": {"schema": {"type": "string"}}}}}}}},
"x-padding-0": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaLine truncated
}
@@ -0,0 +1,32 @@
{
"openapi": "3.1.0",
"info": {
"title": "Secret hostile",
"version": "1"
},
"paths": {
"/secret": {
"get": {
"operationId": "secretOperation",
"responses": {
"200": {
"description": "ok",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
},
"x-example": "sk_test_corpus_secret_canary"
}
}
},
"servers": [
{
"url": "https://api.example.test"
}
]
}
@@ -0,0 +1,48 @@
{
"openapi": "3.0.3",
"info": {
"title": "Hostile security scope",
"version": "1"
},
"servers": [
{
"url": "https://corpus.example.test"
}
],
"security": [
{
"corpusProbe": []
}
],
"components": {
"securitySchemes": {
"corpusProbe": {
"type": "http",
"scheme": "basic"
}
}
},
"paths": {
"/public": {
"get": {
"operationId": "publicProbe",
"security": [],
"responses": {
"200": {
"description": "ok"
}
}
}
},
"/secure": {
"get": {
"operationId": "secureProbe",
"responses": {
"200": {
"description": "ok"
}
}
}
}
}
}
@@ -0,0 +1,18 @@
{
"openapi": "3.1.0",
"info": {
"title": "TRACE hostile",
"version": "1"
},
"paths": {
"/trace": {
"trace": {
"responses": {
"200": {
"description": "unsupported"
}
}
}
}
}
}
@@ -0,0 +1,31 @@
{
"openapi": "3.1.0",
"info": {
"title": "XML hostile",
"version": "1"
},
"paths": {
"/xml": {
"get": {
"operationId": "xmlOperation",
"responses": {
"200": {
"description": "ok",
"content": {
"application/xml": {
"schema": {
"type": "string"
}
}
}
}
}
}
}
},
"servers": [
{
"url": "https://api.example.test"
}
]
}
File diff suppressed because it is too large. Load diff
+822
View File
@@ -0,0 +1,822 @@
//! Executable normalizer probes for every normative support-matrix row.
use super::*;
use crank_import::rest::{NormalizedSchemaKind, normalize_verified_bundle};
fn assert_actionable(ir: &crank_import::rest::NormalizedIr, context: &str) {
let preview = preview_from_ir(ir);
assert!(
!preview.findings.iter().any(|finding| {
finding.severity == crank_import::rest::ImportFindingSeverity::Error
}),
"{context} has a document blocker: {:?}",
preview.findings
);
assert!(
preview
.groups
.iter()
.flat_map(|group| &group.operations)
.all(|candidate| {
!candidate.findings.iter().any(|finding| {
finding.severity == crank_import::rest::ImportFindingSeverity::Error
})
}),
"{context} unexpectedly blocked: {:?}",
preview.groups
);
}
#[test]
fn ac_1_support_matrix_rows_have_exact_construct_contracts() {
let matrix_text = fs::read_to_string(tests_root().join("support-matrix.yaml"))
.expect("support matrix exists");
let matrix: serde_yaml::Value = serde_yaml::from_str(&matrix_text).expect("valid YAML");
assert_eq!(matrix["matrix_version"].as_str(), Some("1.0.2"));
assert!(
matrix["compatibility_impact"]
.as_str()
.is_some_and(|s| !s.trim().is_empty())
);
let rows = matrix["constructs"].as_sequence().expect("construct rows");
assert!(rows.len() >= 375);
let mut construct_keys = std::collections::BTreeSet::new();
for row in rows {
assert!(
row["specification_version"].as_str().is_some_and(|s| [
"OpenAPI 3.0",
"OpenAPI 3.1",
"Swagger 2.0"
]
.contains(&s))
);
assert!(row["construct_id"].as_str().is_some_and(|s| !s.is_empty()));
assert!(matches!(
row["status"].as_str(),
Some("supported" | "unsupported")
));
assert!(
row["preserved_semantics"]
.as_str()
.is_some_and(|s| !s.trim().is_empty())
);
assert!(
row["expected_finding"]
.as_str()
.is_some_and(|s| !s.trim().is_empty())
);
let key = format!(
"{}:{}",
row["specification_version"].as_str().unwrap(),
row["construct_id"].as_str().unwrap()
);
assert!(
construct_keys.insert(key.clone()),
"duplicate normative construct row: {key}"
);
if row["status"] == "supported" {
assert_eq!(
row["expected_finding"], "none",
"supported construct has a finding: {key}"
);
} else {
assert_ne!(
row["expected_finding"], "none",
"unsupported construct has no finding: {key}"
);
}
}
for version in ["OpenAPI 3.0", "OpenAPI 3.1", "Swagger 2.0"] {
// Exhaustive accounting: every normative row of this format must be
// matched by an executed probe before the loop completes.
let mut unprobed = rows
.iter()
.filter(|row| row["specification_version"] == version)
.map(|row| {
(
version.to_owned(),
row["construct_id"].as_str().unwrap().to_owned(),
)
})
.collect::<std::collections::BTreeSet<_>>();
let mut probed = |construct: &str| {
let taken = unprobed.remove(&(version.to_owned(), construct.to_owned()));
assert!(taken, "{version} double-probes or misses {construct}");
};
let ids = rows
.iter()
.filter(|r| r["specification_version"] == version)
.filter_map(|r| r["construct_id"].as_str())
.collect::<Vec<_>>();
for id in [
"http.method.get",
"http.method.post",
"http.method.put",
"http.method.patch",
"http.method.delete",
"http.method.head",
"http.method.options",
"parameter.location.path",
"parameter.location.query",
"parameter.location.header",
"parameter.location.cookie",
"request_body.application/json",
"request_body.application/x-www-form-urlencoded",
"request_body.multipart/form-data",
"reference.local",
"reference.external_allowlisted",
"composition.allOf",
"composition.oneOf",
"composition.anyOf",
"security.bearer",
"security.basic",
"security.api_key",
"media_type.application_xml.request",
"media_type.application_xml.response",
"http.method.trace",
"http.method.connect",
] {
assert!(ids.contains(&id), "{version} matrix misses {id}");
}
for security_kind in ["bearer", "basic", "api_key"] {
let construct = format!("security.{security_kind}");
let row = rows
.iter()
.find(|row| {
row["specification_version"] == version && row["construct_id"] == construct
})
.unwrap();
let probe = if version == "Swagger 2.0" {
json!({
"swagger":"2.0", "info":{"title":"Security probe","version":"1"},
"securityDefinitions":{"probe": if security_kind == "bearer" {
json!({"type":"oauth2","flow":"implicit","authorizationUrl":"https://auth.example.test","scopes":{}})
} else if security_kind == "api_key" {
json!({"type":"apiKey","name":"X-Key","in":"header"})
} else {
json!({"type":"basic"})
}},
"paths":{"/probe":{"get":{"security":[{"probe":[]}],"operationId":"securityProbe","responses":{"200":{"description":"ok"}}}}}
})
} else {
let scheme = match security_kind {
"bearer" => json!({"type":"http","scheme":"bearer"}),
"basic" => json!({"type":"http","scheme":"basic"}),
"api_key" => json!({"type":"apiKey","name":"X-Key","in":"header"}),
_ => unreachable!(),
};
json!({
"openapi": if version == "OpenAPI 3.0" {"3.0.3"} else {"3.1.0"},
"info":{"title":"Security probe","version":"1"},
"servers":[{"url":"https://matrix.example.test"}],
"components":{"securitySchemes":{"probe":scheme}},
"paths":{"/probe":{"get":{"security":[{"probe":[]}],"operationId":"securityProbe","responses":{"200":{"description":"ok"}}}}}
})
};
assert_eq!(
row["status"], "unsupported",
"security is not yet persisted as Auth Profile semantics"
);
let source = serde_json::to_string(&probe).unwrap();
let ir = normalize(&source).unwrap();
validate_normalized_ir(&ir).unwrap();
let expected_finding = row["expected_finding"].as_str().unwrap();
let requirement = ir
.findings
.iter()
.find(|finding| {
finding.code == expected_finding
&& finding.severity == crank_import::rest::ImportFindingSeverity::Error
})
.unwrap_or_else(|| {
panic!(
"{version} {construct} must be explicitly blocked: {:?}",
ir.findings
)
});
assert_eq!(
requirement.operation_key.as_deref(),
Some("GET /probe"),
"{version} {construct} blocker must belong to the affected candidate"
);
assert_eq!(
requirement.location.pointer, "/paths/~1probe/get/security/0",
"{version} {construct} blocker must point at the local requirement"
);
let preview = preview_from_ir(&ir);
let candidate = &preview.groups[0].operations[0];
assert!(
candidate
.findings
.iter()
.any(|finding| finding.code == expected_finding
&& finding.severity == crank_import::rest::ImportFindingSeverity::Error),
"{version} {construct} candidate must be blocked: {:?}",
candidate.findings
);
assert!(
ir.coverage.iter().any(|entry| entry.location.pointer
== "/paths/~1probe/get/security/0"
&& entry.disposition == CoverageDisposition::Finding),
"{version} {construct} has no finding coverage"
);
probed(&construct);
}
{
let construct = "security.override_empty";
let override_probe = |path: &str| {
if version == "Swagger 2.0" {
json!({
"swagger":"2.0", "info":{"title":"Security override probe","version":"1"},
"securityDefinitions":{"probe":{"type":"basic"}},
"security":[{"probe":[]}],
"paths":{path:{"get":{"security":[],"operationId":"securityOverride","responses":{"200":{"description":"ok"}}}}}
})
} else {
json!({
"openapi": if version == "OpenAPI 3.0" {"3.0.3"} else {"3.1.0"},
"info":{"title":"Security override probe","version":"1"},
"servers":[{"url":"https://matrix.example.test"}],
"components":{"securitySchemes":{"probe":{"type":"http","scheme":"basic"}}},
"security":[{"probe":[]}],
"paths":{path:{"get":{"security":[],"operationId":"securityOverride","responses":{"200":{"description":"ok"}}}}}
})
}
};
let source = serde_json::to_string(&override_probe("/override")).unwrap();
let ir = normalize(&source).unwrap();
validate_normalized_ir(&ir).unwrap();
assert!(
ir.findings
.iter()
.all(|finding| finding.code != "unsupported_security_requirement"),
"explicit empty security override must disable inheritance: {:?}",
ir.findings
);
let preview = preview_from_ir(&ir);
let candidate = &preview.groups[0].operations[0];
assert!(
candidate
.findings
.iter()
.all(|finding| finding.severity
!= crank_import::rest::ImportFindingSeverity::Error),
"overridden operation must remain actionable: {:?}",
candidate.findings
);
probed(construct);
}
{
let construct = "security.mixed_operations";
let mixed_probe = if version == "Swagger 2.0" {
json!({
"swagger":"2.0", "info":{"title":"Mixed security probe","version":"1"},
"securityDefinitions":{"probe":{"type":"basic"}},
"security":[{"probe":[]}],
"paths":{
"/public":{"get":{"security":[],"operationId":"publicProbe","responses":{"200":{"description":"ok"}}}},
"/secured":{"get":{"operationId":"securedProbe","responses":{"200":{"description":"ok"}}}}
}
})
} else {
json!({
"openapi": if version == "OpenAPI 3.0" {"3.0.3"} else {"3.1.0"},
"info":{"title":"Mixed security probe","version":"1"},
"servers":[{"url":"https://matrix.example.test"}],
"components":{"securitySchemes":{"probe":{"type":"http","scheme":"basic"}}},
"security":[{"probe":[]}],
"paths":{
"/public":{"get":{"security":[],"operationId":"publicProbe","responses":{"200":{"description":"ok"}}}},
"/secured":{"get":{"operationId":"securedProbe","responses":{"200":{"description":"ok"}}}}
}
})
};
let source = serde_json::to_string(&mixed_probe).unwrap();
let ir = normalize(&source).unwrap();
validate_normalized_ir(&ir).unwrap();
let expected_finding = rows
.iter()
.find(|row| {
row["specification_version"] == version && row["construct_id"] == construct
})
.unwrap()["expected_finding"]
.as_str()
.unwrap();
let requirements = ir
.findings
.iter()
.filter(|finding| finding.code == expected_finding)
.collect::<Vec<_>>();
assert_eq!(
requirements.len(),
1,
"exactly the inherited operation must be blocked: {:?}",
requirements
);
assert_eq!(
requirements[0].operation_key.as_deref(),
Some("GET /secured"),
"blocker must belong only to the affected candidate"
);
assert_eq!(requirements[0].location.pointer, "/security/0");
let preview = preview_from_ir(&ir);
let mut by_key = std::collections::BTreeMap::new();
for group in &preview.groups {
for candidate in &group.operations {
by_key.insert(candidate.key.clone(), candidate);
}
}
let public = by_key.get("GET /public").expect("public candidate present");
assert!(
public
.findings
.iter()
.all(|finding| finding.severity
!= crank_import::rest::ImportFindingSeverity::Error),
"public operation must stay actionable: {:?}",
public.findings
);
let secured = by_key
.get("GET /secured")
.expect("secured candidate present");
assert!(
secured
.findings
.iter()
.any(|finding| finding.code == expected_finding
&& finding.severity == crank_import::rest::ImportFindingSeverity::Error),
"secured operation must be blocked: {:?}",
secured.findings
);
assert!(
ir.coverage
.iter()
.any(|entry| entry.location.pointer == "/security/0"
&& entry.disposition == CoverageDisposition::Finding),
"mixed probe has no finding coverage"
);
probed(construct);
}
for method in [
"get", "post", "put", "patch", "delete", "head", "options", "trace", "connect",
] {
let construct = format!("http.method.{method}");
let row = rows
.iter()
.find(|row| {
row["specification_version"] == version && row["construct_id"] == construct
})
.unwrap();
let mut path_item = serde_json::Map::new();
path_item.insert(
method.to_owned(),
json!({
"operationId":"methodProbe", "responses":{"200":{"description":"ok"}}
}),
);
let probe = if version == "Swagger 2.0" {
json!({"swagger":"2.0","info":{"title":"Method probe","version":"1"},"paths":{"/probe":path_item,"/normal":{"get":{"operationId":"normalProbe","responses":{"200":{"description":"ok"}}}}}})
} else {
json!({"openapi":if version == "OpenAPI 3.0" {"3.0.3"} else {"3.1.0"},
"info":{"title":"Method probe","version":"1"},"servers":[{"url":"https://matrix.example.test"}],"paths":{"/probe":path_item,"/normal":{"get":{"operationId":"normalProbe","responses":{"200":{"description":"ok"}}}}}})
};
let source = serde_json::to_string(&probe).unwrap();
let ir = normalize(&source).unwrap();
validate_normalized_ir(&ir).unwrap();
if row["status"] == "supported" {
assert!(
ir.operations
.iter()
.any(
|operation| serde_json::to_value(operation.method).unwrap().as_str()
== Some(&method.to_ascii_uppercase())
),
"{version} {construct} was not preserved"
);
assert_eq!(row["expected_finding"], "none");
assert_actionable(&ir, &format!("{version} {construct}"));
} else {
let expected_finding = row["expected_finding"].as_str().unwrap();
assert!(
ir.operations
.iter()
.any(|operation| operation.path == "/normal"),
"{version} {construct} must not discard a supported neighbour"
);
assert!(
ir.findings
.iter()
.any(|finding| finding.code == expected_finding
&& finding.severity
== crank_import::rest::ImportFindingSeverity::Error),
"{version} {construct} missing exact finding {expected_finding}: {:?}",
ir.findings
);
assert!(
ir.coverage
.iter()
.any(|entry| entry.construct_id.ends_with(&format!("/{method}"))
&& entry.disposition == CoverageDisposition::Finding),
"{version} {construct} has no finding coverage"
);
}
probed(&construct);
}
for location in ["path", "query", "header", "cookie"] {
let construct = format!("parameter.location.{location}");
let row = rows
.iter()
.find(|row| {
row["specification_version"] == version && row["construct_id"] == construct
})
.unwrap();
let parameter = if version == "Swagger 2.0" {
json!({"name":"probe","in":location,"required":location == "path","type":"string"})
} else {
json!({"name":"probe","in":location,"required":location == "path","schema":{"type":"string"}})
};
let path = if location == "path" {
"/probe/{probe}"
} else {
"/probe"
};
let operation = json!({"operationId":"parameterProbe","parameters":[parameter],"responses":{"200":{"description":"ok"}}});
let probe = if version == "Swagger 2.0" {
json!({"swagger":"2.0","info":{"title":"Parameter probe","version":"1"},"paths":{path:{"get":operation}}})
} else {
json!({"openapi":if version == "OpenAPI 3.0" {"3.0.3"} else {"3.1.0"},
"info":{"title":"Parameter probe","version":"1"},"servers":[{"url":"https://matrix.example.test"}],"paths":{path:{"get":operation}}})
};
let source = serde_json::to_string(&probe).unwrap();
let ir = normalize(&source).unwrap();
validate_normalized_ir(&ir).unwrap();
if row["status"] == "supported" {
let parameter = ir.operations[0]
.parameters
.iter()
.find(|parameter| parameter.name == "probe")
.unwrap();
assert_eq!(
serde_json::to_value(parameter.location).unwrap(),
location,
"{version} {construct} location was changed"
);
assert!(
parameter.schema.is_some(),
"{version} {construct} schema was lost"
);
assert_eq!(parameter.required, location == "path");
let preview = preview_from_ir(&ir);
let candidate = &preview.groups[0].operations[0];
let expected_root = match location {
"path" => "$.request.path.",
"query" => "$.request.query.",
"header" => "$.request.headers.",
"cookie" => "$.request.cookies.",
_ => unreachable!(),
};
assert!(
candidate
.draft
.input_mapping
.rules
.iter()
.any(|rule| rule.source == "$.mcp.probe"
&& rule.target.starts_with(expected_root)),
"{version} {construct} input mapping missing {expected_root}: {:?}",
candidate.draft.input_mapping
);
assert_actionable(&ir, &format!("{version} {construct}"));
} else {
let expected_finding = row["expected_finding"].as_str().unwrap();
assert!(
ir.operations[0].findings.iter().any(|finding| finding.code
== expected_finding
&& finding.severity == crank_import::rest::ImportFindingSeverity::Error
&& finding.location.pointer == "/paths/~1probe/get/parameters/0"),
"{version} {construct} missing exact finding {expected_finding}"
);
}
probed(&construct);
}
for media_type in [
"application/json",
"application/x-www-form-urlencoded",
"multipart/form-data",
] {
let construct = format!("request_body.{media_type}");
let row = rows
.iter()
.find(|row| {
row["specification_version"] == version && row["construct_id"] == construct
})
.unwrap();
let operation = if version == "Swagger 2.0" {
let mut operation =
json!({"operationId":"bodyProbe","responses":{"200":{"description":"ok"}}});
operation["consumes"] = json!([media_type]);
if media_type == "application/json" {
operation["parameters"] = json!([{"name":"body","in":"body","required":true,"schema":{"type":"object","properties":{"value":{"type":"string"}}}}]);
} else {
operation["parameters"] =
json!([{"name":"value","in":"formData","required":true,"type":"string"}]);
}
operation
} else {
json!({"operationId":"bodyProbe","requestBody":{"required":true,"content":{
(media_type):{"schema":{"type":"object","properties":{"value":{"type":"string"}}}}
}},"responses":{"200":{"description":"ok"}}})
};
let probe = if version == "Swagger 2.0" {
json!({"swagger":"2.0","info":{"title":"Body probe","version":"1"},"paths":{"/probe":{"post":operation}}})
} else {
json!({"openapi":if version == "OpenAPI 3.0" {"3.0.3"} else {"3.1.0"},
"info":{"title":"Body probe","version":"1"},"servers":[{"url":"https://matrix.example.test"}],"paths":{"/probe":{"post":operation}}})
};
let source = serde_json::to_string(&probe).unwrap();
let ir = normalize(&source).unwrap();
validate_normalized_ir(&ir).unwrap();
if row["status"] == "supported" {
let variant = ir.operations[0]
.request_body_variants
.iter()
.find(|variant| variant.content_type == media_type)
.expect("request body variant retained");
assert!(
variant.schema.is_some(),
"{version} {construct} schema was lost: {:?}",
variant
);
assert!(
variant.required,
"{version} {construct} required request body contract was lost: {variant:?}"
);
let preview = preview_from_ir(&ir);
let contract = preview.groups[0].operations[0]
.draft
.target
.request_contract
.as_ref()
.expect("draft request contract");
assert!(contract.body_required);
assert!(
contract
.variants
.iter()
.any(|variant| variant.media_type == media_type)
);
assert_actionable(&ir, &format!("{version} {construct}"));
} else {
let expected_finding = row["expected_finding"].as_str().unwrap();
assert!(
ir.operations[0].findings.iter().any(|finding| finding.code
== expected_finding
&& finding.severity == crank_import::rest::ImportFindingSeverity::Error)
);
}
probed(&construct);
}
for (construct, is_request) in [
("media_type.application_xml.request", true),
("media_type.application_xml.response", false),
] {
let row = rows
.iter()
.find(|row| {
row["specification_version"] == version && row["construct_id"] == construct
})
.unwrap();
let operation = if version == "Swagger 2.0" {
let mut operation = json!({"operationId":"xmlProbe","responses":{"200":{"description":"ok","schema":{"type":"string"}}}});
if is_request {
operation["consumes"] = json!(["application/xml"]);
operation["parameters"] = json!([{"name":"body","in":"body","required":true,"schema":{"type":"string"}}]);
} else {
operation["produces"] = json!(["application/xml"]);
}
operation
} else if is_request {
json!({"operationId":"xmlProbe","requestBody":{"content":{"application/xml":{"schema":{"type":"string"}}}},"responses":{"200":{"description":"ok"}}})
} else {
json!({"operationId":"xmlProbe","responses":{"200":{"description":"ok","content":{"application/xml":{"schema":{"type":"string"}}}}}})
};
let probe = if version == "Swagger 2.0" {
json!({"swagger":"2.0","info":{"title":"XML probe","version":"1"},"paths":{"/probe":{"post":operation}}})
} else {
json!({"openapi":if version == "OpenAPI 3.0" {"3.0.3"} else {"3.1.0"},
"info":{"title":"XML probe","version":"1"},"servers":[{"url":"https://matrix.example.test"}],"paths":{"/probe":{"post":operation}}})
};
let source = serde_json::to_string(&probe).unwrap();
let ir = normalize(&source).unwrap();
validate_normalized_ir(&ir).unwrap();
let expected_finding = row["expected_finding"].as_str().unwrap();
assert_eq!(row["status"], "unsupported");
let expected_pointer = if version == "Swagger 2.0" {
if is_request {
"/paths/~1probe/post/consumes/0"
} else {
"/paths/~1probe/post/produces/0"
}
} else if is_request {
"/paths/~1probe/post/requestBody/content/application~1xml"
} else {
"/paths/~1probe/post/responses/200/content/application~1xml"
};
assert!(
ir.operations[0]
.findings
.iter()
.any(|finding| finding.code == expected_finding
&& finding.severity == crank_import::rest::ImportFindingSeverity::Error
&& finding.location.pointer == expected_pointer),
"{version} {construct} missing exact blocker {expected_finding}: {:?}",
ir.operations[0].findings
);
probed(construct);
}
for composition in ["allOf", "oneOf", "anyOf"] {
let construct = format!("composition.{composition}");
let row = rows
.iter()
.find(|row| {
row["specification_version"] == version && row["construct_id"] == construct
})
.unwrap();
let schema = json!({(composition):[{"type":"object","properties":{"id":{"type":"string"}}},{"type":"object","properties":{"name":{"type":"string"}}}]});
let response = if version == "Swagger 2.0" {
json!({"description":"ok","schema":schema})
} else {
json!({"description":"ok","content":{"application/json":{"schema":schema}}})
};
let probe = if version == "Swagger 2.0" {
json!({"swagger":"2.0","info":{"title":"Composition probe","version":"1"},"paths":{"/probe":{"get":{"operationId":"compositionProbe","responses":{"200":response}}}}})
} else {
json!({"openapi":if version == "OpenAPI 3.0" {"3.0.3"} else {"3.1.0"},
"info":{"title":"Composition probe","version":"1"},"servers":[{"url":"https://matrix.example.test"}],"paths":{"/probe":{"get":{"operationId":"compositionProbe","responses":{"200":response}}}}})
};
let source = serde_json::to_string(&probe).unwrap();
let ir = normalize(&source).unwrap();
validate_normalized_ir(&ir).unwrap();
assert_eq!(row["status"], "supported");
assert!(ir.operations[0].response_variants[0].schema.as_ref().is_some_and(|schema|
if composition == "allOf" {
matches!(&schema.kind, NormalizedSchemaKind::Object { properties, .. }
if properties.contains_key("id") && properties.contains_key("name"))
} else {
matches!(&schema.kind, NormalizedSchemaKind::Composition { operator, variants }
if operator == composition && variants.len() == 2
&& matches!(&variants[0].kind, NormalizedSchemaKind::Object { properties, .. }
if properties.contains_key("id"))
&& matches!(&variants[1].kind, NormalizedSchemaKind::Object { properties, .. }
if properties.contains_key("name")))
}),
"{version} {construct} composition was not retained: {:?}", ir.operations[0].response_variants);
assert_eq!(row["expected_finding"], "none");
assert_actionable(&ir, &format!("{version} {construct}"));
probed(&construct);
}
for external in [false, true] {
let construct = if external {
"reference.external_allowlisted"
} else {
"reference.local"
};
let row = rows
.iter()
.find(|row| {
row["specification_version"] == version && row["construct_id"] == construct
})
.unwrap();
let reference = if external {
"https://schemas.example.test/root.yaml#/Item"
} else if version == "Swagger 2.0" {
"#/definitions/Item"
} else {
"#/components/schemas/Item"
};
let schema = json!({"$ref":reference});
let response = if version == "Swagger 2.0" {
json!({"description":"ok","schema":schema})
} else {
json!({"description":"ok","content":{"application/json":{"schema":schema}}})
};
let probe = if version == "Swagger 2.0" {
let mut root = json!({"swagger":"2.0","info":{"title":"Reference probe","version":"1"},"paths":{"/probe":{"get":{"operationId":"referenceProbe","responses":{"200":response}}}}});
if !external {
root["definitions"] =
json!({"Item":{"type":"object","properties":{"id":{"type":"string"}}}});
}
root
} else {
let mut root = json!({"openapi":if version == "OpenAPI 3.0" {"3.0.3"} else {"3.1.0"},
"info":{"title":"Reference probe","version":"1"},"servers":[{"url":"https://matrix.example.test"}],"paths":{"/probe":{"get":{"operationId":"referenceProbe","responses":{"200":response}}}}});
if !external {
root["components"] = json!({"schemas":{"Item":{"type":"object","properties":{"id":{"type":"string"}}}}});
}
root
};
let source = serde_json::to_string(&probe).unwrap();
let ir = if external {
let external_source =
"Item: { type: object, properties: { id: { type: string } } }";
let snapshot = crank_import::rest::ExternalDocumentSnapshot {
canonical_uri: "https://schemas.example.test/root.yaml".to_owned(),
digest: SourceDigest::parse(hex(external_source.as_bytes())).unwrap(),
document: external_source.to_owned(),
};
let digest = SourceDigest::parse(hex(source.as_bytes())).unwrap();
normalize_verified_bundle(
&source,
digest,
&[snapshot],
&NormalizationConfig::default(),
)
.unwrap()
} else {
normalize(&source).unwrap()
};
validate_normalized_ir(&ir).unwrap();
assert_eq!(row["status"], "supported");
assert!(
!ir.reference_graph.edges.is_empty(),
"{version} {construct} did not resolve through a source-backed edge"
);
assert!(
ir.unresolved_references.is_empty(),
"{version} {construct} remains unresolved"
);
assert!(
matches!(
ir.operations[0].response_variants[0].schema.as_ref().map(|schema| &schema.kind),
Some(NormalizedSchemaKind::Object { properties, .. }) if properties.contains_key("id")
),
"{version} {construct} resolved schema was not projected into the operation"
);
assert_actionable(&ir, &format!("{version} {construct}"));
assert_eq!(row["expected_finding"], "none");
probed(construct);
}
for code in 200..300 {
let construct = format!("response.{code}");
let response_row = rows
.iter()
.find(|row| {
row["specification_version"] == version && row["construct_id"] == construct
})
.unwrap_or_else(|| panic!("{version} matrix misses {construct}"));
assert!(
ids.contains(&construct.as_str()),
"{version} matrix misses {construct}"
);
assert_eq!(response_row["status"], "supported");
assert_eq!(response_row["expected_finding"], "none");
let has_body = !matches!(code, 204 | 205);
let source = if version == "Swagger 2.0" {
json!({
"swagger":"2.0", "info":{"title":"Matrix probe","version":"1"},
"paths":{"/probe":{"get":{"operationId":"matrixProbe","responses":{
code.to_string(): if has_body {json!({"description":"success","schema":{"type":"object","properties":{"id":{"type":"string"}}}})} else {json!({"description":"success"})}
}}}}
})
} else {
json!({
"openapi": if version == "OpenAPI 3.0" {"3.0.3"} else {"3.1.0"},
"info":{"title":"Matrix probe","version":"1"},
"servers":[{"url":"https://matrix.example.test"}],
"paths":{"/probe":{"get":{"operationId":"matrixProbe","responses":{
code.to_string(): if has_body {json!({"description":"success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"}}}}}})} else {json!({"description":"success"})}
}}}}
})
};
let source = serde_json::to_string(&source).unwrap();
let ir = normalize(&source)
.unwrap_or_else(|error| panic!("{version} {construct} probe rejected: {error}"));
validate_normalized_ir(&ir).unwrap_or_else(|error| {
panic!("{version} {construct} probe has invalid ledger: {error}")
});
let response = ir.operations[0]
.response_variants
.iter()
.find(|variant| variant.status_code == code)
.unwrap_or_else(|| panic!("{version} {construct} was not preserved"));
assert_eq!(
response.schema.is_some(),
has_body,
"{version} {construct} body contract differs from 204/205 bodyless response semantics"
);
assert!(
!ir.operations[0]
.findings
.iter()
.any(|finding| finding.severity
== crank_import::rest::ImportFindingSeverity::Error),
"{version} {construct} unexpectedly blocked: {:?}",
ir.operations[0].findings
);
probed(&construct);
}
assert!(
unprobed.is_empty(),
"normative {version} rows lack an executed probe: {unprobed:?}"
);
}
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 00",
"version": "1.0"
},
"openapi": "3.0.3",
"paths": {
"/items/0": {
"get": {
"operationId": "corpusOperation00",
"parameters": [
{
"in": "query",
"name": "p00",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 00",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,65 @@
{
"info": {
"title": "Synthetic corpus 01",
"version": "1.0"
},
"openapi": "3.1.0",
"paths": {
"/items/{p01}": {
"post": {
"operationId": "corpusOperation01",
"parameters": [
{
"in": "path",
"name": "p01",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"201": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 01",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,67 @@
{
"basePath": "/v1",
"consumes": [
"application/json"
],
"host": "api.example.test",
"info": {
"title": "Synthetic corpus 02",
"version": "1.0"
},
"paths": {
"/items/2": {
"put": {
"operationId": "corpusOperation02",
"parameters": [
{
"in": "header",
"name": "p02",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"202": {
"description": "synthetic success",
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"summary": "Synthetic operation 02",
"tags": [
"corpus"
]
}
}
},
"produces": [
"application/json"
],
"schemes": [
"https"
],
"swagger": "2.0"
}
@@ -0,0 +1,65 @@
{
"info": {
"title": "Synthetic corpus 03",
"version": "1.0"
},
"openapi": "3.0.3",
"paths": {
"/items/3": {
"patch": {
"operationId": "corpusOperation03",
"parameters": [
{
"in": "cookie",
"name": "p03",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"204": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 03",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 04",
"version": "1.0"
},
"openapi": "3.1.0",
"paths": {
"/items/4": {
"delete": {
"operationId": "corpusOperation04",
"parameters": [
{
"in": "query",
"name": "p04",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 04",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,52 @@
{
"basePath": "/v1",
"consumes": [
"application/json"
],
"host": "api.example.test",
"info": {
"title": "Synthetic corpus 05",
"version": "1.0"
},
"paths": {
"/items/{p05}": {
"head": {
"operationId": "corpusOperation05",
"parameters": [
{
"in": "path",
"name": "p05",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"201": {
"description": "synthetic success",
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"summary": "Synthetic operation 05",
"tags": [
"corpus"
]
}
}
},
"produces": [
"application/json"
],
"schemes": [
"https"
],
"swagger": "2.0"
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 06",
"version": "1.0"
},
"openapi": "3.0.3",
"paths": {
"/items/6": {
"options": {
"operationId": "corpusOperation06",
"parameters": [
{
"in": "header",
"name": "p06",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"202": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 06",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 07",
"version": "1.0"
},
"openapi": "3.1.0",
"paths": {
"/items/7": {
"get": {
"operationId": "corpusOperation07",
"parameters": [
{
"in": "cookie",
"name": "p07",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 07",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,67 @@
{
"basePath": "/v1",
"consumes": [
"application/json"
],
"host": "api.example.test",
"info": {
"title": "Synthetic corpus 08",
"version": "1.0"
},
"paths": {
"/items/8": {
"post": {
"operationId": "corpusOperation08",
"parameters": [
{
"in": "query",
"name": "p08",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "synthetic success",
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"summary": "Synthetic operation 08",
"tags": [
"corpus"
]
}
}
},
"produces": [
"application/json"
],
"schemes": [
"https"
],
"swagger": "2.0"
}
@@ -0,0 +1,65 @@
{
"info": {
"title": "Synthetic corpus 09",
"version": "1.0"
},
"openapi": "3.0.3",
"paths": {
"/items/{p09}": {
"put": {
"operationId": "corpusOperation09",
"parameters": [
{
"in": "path",
"name": "p09",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"201": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 09",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,65 @@
{
"info": {
"title": "Synthetic corpus 10",
"version": "1.0"
},
"openapi": "3.1.0",
"paths": {
"/items/10": {
"patch": {
"operationId": "corpusOperation10",
"parameters": [
{
"in": "header",
"name": "p10",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"202": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 10",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,52 @@
{
"basePath": "/v1",
"consumes": [
"application/json"
],
"host": "api.example.test",
"info": {
"title": "Synthetic corpus 11",
"version": "1.0"
},
"paths": {
"/items/11": {
"delete": {
"operationId": "corpusOperation11",
"parameters": [
{
"in": "header",
"name": "p11",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"description": "synthetic success",
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"summary": "Synthetic operation 11",
"tags": [
"corpus"
]
}
}
},
"produces": [
"application/json"
],
"schemes": [
"https"
],
"swagger": "2.0"
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 12",
"version": "1.0"
},
"openapi": "3.0.3",
"paths": {
"/items/12": {
"head": {
"operationId": "corpusOperation12",
"parameters": [
{
"in": "query",
"name": "p12",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 12",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 13",
"version": "1.0"
},
"openapi": "3.1.0",
"paths": {
"/items/{p13}": {
"options": {
"operationId": "corpusOperation13",
"parameters": [
{
"in": "path",
"name": "p13",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"201": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 13",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,52 @@
{
"basePath": "/v1",
"consumes": [
"application/json"
],
"host": "api.example.test",
"info": {
"title": "Synthetic corpus 14",
"version": "1.0"
},
"paths": {
"/items/14": {
"get": {
"operationId": "corpusOperation14",
"parameters": [
{
"in": "header",
"name": "p14",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"202": {
"description": "synthetic success",
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"summary": "Synthetic operation 14",
"tags": [
"corpus"
]
}
}
},
"produces": [
"application/json"
],
"schemes": [
"https"
],
"swagger": "2.0"
}
@@ -0,0 +1,65 @@
{
"info": {
"title": "Synthetic corpus 15",
"version": "1.0"
},
"openapi": "3.0.3",
"paths": {
"/items/15": {
"post": {
"operationId": "corpusOperation15",
"parameters": [
{
"in": "cookie",
"name": "p15",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"204": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 15",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,65 @@
{
"info": {
"title": "Synthetic corpus 16",
"version": "1.0"
},
"openapi": "3.1.0",
"paths": {
"/items/16": {
"put": {
"operationId": "corpusOperation16",
"parameters": [
{
"in": "query",
"name": "p16",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 16",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,67 @@
{
"basePath": "/v1",
"consumes": [
"application/json"
],
"host": "api.example.test",
"info": {
"title": "Synthetic corpus 17",
"version": "1.0"
},
"paths": {
"/items/{p17}": {
"patch": {
"operationId": "corpusOperation17",
"parameters": [
{
"in": "path",
"name": "p17",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"201": {
"description": "synthetic success",
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"summary": "Synthetic operation 17",
"tags": [
"corpus"
]
}
}
},
"produces": [
"application/json"
],
"schemes": [
"https"
],
"swagger": "2.0"
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 18",
"version": "1.0"
},
"openapi": "3.0.3",
"paths": {
"/items/18": {
"delete": {
"operationId": "corpusOperation18",
"parameters": [
{
"in": "header",
"name": "p18",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"202": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 18",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 19",
"version": "1.0"
},
"openapi": "3.1.0",
"paths": {
"/items/19": {
"head": {
"operationId": "corpusOperation19",
"parameters": [
{
"in": "cookie",
"name": "p19",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 19",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,52 @@
{
"basePath": "/v1",
"consumes": [
"application/json"
],
"host": "api.example.test",
"info": {
"title": "Synthetic corpus 20",
"version": "1.0"
},
"paths": {
"/items/20": {
"options": {
"operationId": "corpusOperation20",
"parameters": [
{
"in": "query",
"name": "p20",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "synthetic success",
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"summary": "Synthetic operation 20",
"tags": [
"corpus"
]
}
}
},
"produces": [
"application/json"
],
"schemes": [
"https"
],
"swagger": "2.0"
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 21",
"version": "1.0"
},
"openapi": "3.0.3",
"paths": {
"/items/{p21}": {
"get": {
"operationId": "corpusOperation21",
"parameters": [
{
"in": "path",
"name": "p21",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"201": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 21",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,65 @@
{
"info": {
"title": "Synthetic corpus 22",
"version": "1.0"
},
"openapi": "3.1.0",
"paths": {
"/items/22": {
"post": {
"operationId": "corpusOperation22",
"parameters": [
{
"in": "header",
"name": "p22",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"202": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 22",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,67 @@
{
"basePath": "/v1",
"consumes": [
"application/json"
],
"host": "api.example.test",
"info": {
"title": "Synthetic corpus 23",
"version": "1.0"
},
"paths": {
"/items/23": {
"put": {
"operationId": "corpusOperation23",
"parameters": [
{
"in": "header",
"name": "p23",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"204": {
"description": "synthetic success",
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"summary": "Synthetic operation 23",
"tags": [
"corpus"
]
}
}
},
"produces": [
"application/json"
],
"schemes": [
"https"
],
"swagger": "2.0"
}
@@ -0,0 +1,65 @@
{
"info": {
"title": "Synthetic corpus 24",
"version": "1.0"
},
"openapi": "3.0.3",
"paths": {
"/items/24": {
"patch": {
"operationId": "corpusOperation24",
"parameters": [
{
"in": "query",
"name": "p24",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 24",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 25",
"version": "1.0"
},
"openapi": "3.1.0",
"paths": {
"/items/{p25}": {
"delete": {
"operationId": "corpusOperation25",
"parameters": [
{
"in": "path",
"name": "p25",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"201": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 25",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,52 @@
{
"basePath": "/v1",
"consumes": [
"application/json"
],
"host": "api.example.test",
"info": {
"title": "Synthetic corpus 26",
"version": "1.0"
},
"paths": {
"/items/26": {
"head": {
"operationId": "corpusOperation26",
"parameters": [
{
"in": "header",
"name": "p26",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"202": {
"description": "synthetic success",
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"summary": "Synthetic operation 26",
"tags": [
"corpus"
]
}
}
},
"produces": [
"application/json"
],
"schemes": [
"https"
],
"swagger": "2.0"
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 27",
"version": "1.0"
},
"openapi": "3.0.3",
"paths": {
"/items/27": {
"options": {
"operationId": "corpusOperation27",
"parameters": [
{
"in": "cookie",
"name": "p27",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 27",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 28",
"version": "1.0"
},
"openapi": "3.1.0",
"paths": {
"/items/28": {
"get": {
"operationId": "corpusOperation28",
"parameters": [
{
"in": "query",
"name": "p28",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 28",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,67 @@
{
"basePath": "/v1",
"consumes": [
"application/json"
],
"host": "api.example.test",
"info": {
"title": "Synthetic corpus 29",
"version": "1.0"
},
"paths": {
"/items/{p29}": {
"post": {
"operationId": "corpusOperation29",
"parameters": [
{
"in": "path",
"name": "p29",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"201": {
"description": "synthetic success",
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"summary": "Synthetic operation 29",
"tags": [
"corpus"
]
}
}
},
"produces": [
"application/json"
],
"schemes": [
"https"
],
"swagger": "2.0"
}
@@ -0,0 +1,65 @@
{
"info": {
"title": "Synthetic corpus 30",
"version": "1.0"
},
"openapi": "3.0.3",
"paths": {
"/items/30": {
"put": {
"operationId": "corpusOperation30",
"parameters": [
{
"in": "header",
"name": "p30",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"202": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 30",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,65 @@
{
"info": {
"title": "Synthetic corpus 31",
"version": "1.0"
},
"openapi": "3.1.0",
"paths": {
"/items/31": {
"patch": {
"operationId": "corpusOperation31",
"parameters": [
{
"in": "cookie",
"name": "p31",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"204": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 31",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,52 @@
{
"basePath": "/v1",
"consumes": [
"application/json"
],
"host": "api.example.test",
"info": {
"title": "Synthetic corpus 32",
"version": "1.0"
},
"paths": {
"/items/32": {
"delete": {
"operationId": "corpusOperation32",
"parameters": [
{
"in": "query",
"name": "p32",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "synthetic success",
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"summary": "Synthetic operation 32",
"tags": [
"corpus"
]
}
}
},
"produces": [
"application/json"
],
"schemes": [
"https"
],
"swagger": "2.0"
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 33",
"version": "1.0"
},
"openapi": "3.0.3",
"paths": {
"/items/{p33}": {
"head": {
"operationId": "corpusOperation33",
"parameters": [
{
"in": "path",
"name": "p33",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"201": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 33",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 34",
"version": "1.0"
},
"openapi": "3.1.0",
"paths": {
"/items/34": {
"options": {
"operationId": "corpusOperation34",
"parameters": [
{
"in": "header",
"name": "p34",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"202": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 34",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,52 @@
{
"basePath": "/v1",
"consumes": [
"application/json"
],
"host": "api.example.test",
"info": {
"title": "Synthetic corpus 35",
"version": "1.0"
},
"paths": {
"/items/35": {
"get": {
"operationId": "corpusOperation35",
"parameters": [
{
"in": "header",
"name": "p35",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"description": "synthetic success",
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"summary": "Synthetic operation 35",
"tags": [
"corpus"
]
}
}
},
"produces": [
"application/json"
],
"schemes": [
"https"
],
"swagger": "2.0"
}
@@ -0,0 +1,65 @@
{
"info": {
"title": "Synthetic corpus 36",
"version": "1.0"
},
"openapi": "3.0.3",
"paths": {
"/items/36": {
"post": {
"operationId": "corpusOperation36",
"parameters": [
{
"in": "query",
"name": "p36",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 36",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,65 @@
{
"info": {
"title": "Synthetic corpus 37",
"version": "1.0"
},
"openapi": "3.1.0",
"paths": {
"/items/{p37}": {
"put": {
"operationId": "corpusOperation37",
"parameters": [
{
"in": "path",
"name": "p37",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"201": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 37",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,67 @@
{
"basePath": "/v1",
"consumes": [
"application/json"
],
"host": "api.example.test",
"info": {
"title": "Synthetic corpus 38",
"version": "1.0"
},
"paths": {
"/items/38": {
"patch": {
"operationId": "corpusOperation38",
"parameters": [
{
"in": "header",
"name": "p38",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"202": {
"description": "synthetic success",
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"summary": "Synthetic operation 38",
"tags": [
"corpus"
]
}
}
},
"produces": [
"application/json"
],
"schemes": [
"https"
],
"swagger": "2.0"
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 39",
"version": "1.0"
},
"openapi": "3.0.3",
"paths": {
"/items/39": {
"delete": {
"operationId": "corpusOperation39",
"parameters": [
{
"in": "cookie",
"name": "p39",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 39",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 40",
"version": "1.0"
},
"openapi": "3.1.0",
"paths": {
"/items/40": {
"head": {
"operationId": "corpusOperation40",
"parameters": [
{
"in": "query",
"name": "p40",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 40",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,52 @@
{
"basePath": "/v1",
"consumes": [
"application/json"
],
"host": "api.example.test",
"info": {
"title": "Synthetic corpus 41",
"version": "1.0"
},
"paths": {
"/items/{p41}": {
"options": {
"operationId": "corpusOperation41",
"parameters": [
{
"in": "path",
"name": "p41",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"201": {
"description": "synthetic success",
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"summary": "Synthetic operation 41",
"tags": [
"corpus"
]
}
}
},
"produces": [
"application/json"
],
"schemes": [
"https"
],
"swagger": "2.0"
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 42",
"version": "1.0"
},
"openapi": "3.0.3",
"paths": {
"/items/42": {
"get": {
"operationId": "corpusOperation42",
"parameters": [
{
"in": "header",
"name": "p42",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"202": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 42",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,65 @@
{
"info": {
"title": "Synthetic corpus 43",
"version": "1.0"
},
"openapi": "3.1.0",
"paths": {
"/items/43": {
"post": {
"operationId": "corpusOperation43",
"parameters": [
{
"in": "cookie",
"name": "p43",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"204": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 43",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,67 @@
{
"basePath": "/v1",
"consumes": [
"application/json"
],
"host": "api.example.test",
"info": {
"title": "Synthetic corpus 44",
"version": "1.0"
},
"paths": {
"/items/44": {
"put": {
"operationId": "corpusOperation44",
"parameters": [
{
"in": "query",
"name": "p44",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "synthetic success",
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"summary": "Synthetic operation 44",
"tags": [
"corpus"
]
}
}
},
"produces": [
"application/json"
],
"schemes": [
"https"
],
"swagger": "2.0"
}
@@ -0,0 +1,65 @@
{
"info": {
"title": "Synthetic corpus 45",
"version": "1.0"
},
"openapi": "3.0.3",
"paths": {
"/items/{p45}": {
"patch": {
"operationId": "corpusOperation45",
"parameters": [
{
"in": "path",
"name": "p45",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"name": {
"type": "string"
}
},
"type": "object"
}
}
},
"required": true
},
"responses": {
"201": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 45",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 46",
"version": "1.0"
},
"openapi": "3.1.0",
"paths": {
"/items/46": {
"delete": {
"operationId": "corpusOperation46",
"parameters": [
{
"in": "header",
"name": "p46",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"202": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 46",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,52 @@
{
"basePath": "/v1",
"consumes": [
"application/json"
],
"host": "api.example.test",
"info": {
"title": "Synthetic corpus 47",
"version": "1.0"
},
"paths": {
"/items/47": {
"head": {
"operationId": "corpusOperation47",
"parameters": [
{
"in": "header",
"name": "p47",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"description": "synthetic success",
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"summary": "Synthetic operation 47",
"tags": [
"corpus"
]
}
}
},
"produces": [
"application/json"
],
"schemes": [
"https"
],
"swagger": "2.0"
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 48",
"version": "1.0"
},
"openapi": "3.0.3",
"paths": {
"/items/48": {
"options": {
"operationId": "corpusOperation48",
"parameters": [
{
"in": "query",
"name": "p48",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 48",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,50 @@
{
"info": {
"title": "Synthetic corpus 49",
"version": "1.0"
},
"openapi": "3.1.0",
"paths": {
"/items/{p49}": {
"get": {
"operationId": "corpusOperation49",
"parameters": [
{
"in": "path",
"name": "p49",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"201": {
"content": {
"application/json": {
"schema": {
"properties": {
"id": {
"type": "string"
}
},
"type": "object"
}
}
},
"description": "synthetic success"
}
},
"summary": "Synthetic operation 49",
"tags": [
"corpus"
]
}
}
},
"servers": [
{
"url": "https://api.example.test/v1"
}
]
}
@@ -0,0 +1,67 @@
use crank_import::rest::{NormalizationConfig, SourceDigest, normalize_verified_document};
use serde_json::{Value, json};
use sha2::{Digest, Sha256};
#[test]
fn path_item_parameters_are_inherited_and_operation_parameters_override_by_name_and_location() {
for version in ["3.0.3", "3.1.0", "2.0"] {
let parameter = |name: &str, location: &str, kind: &str| {
if version == "2.0" {
json!({"name":name,"in":location,"required":location == "path","type":kind})
} else {
json!({"name":name,"in":location,"required":location == "path","schema":{"type":kind}})
}
};
let mut document = if version == "2.0" {
json!({"swagger":"2.0","info":{"title":"Path parameters","version":"1"}})
} else {
json!({"openapi":version,"info":{"title":"Path parameters","version":"1"},"servers":[{"url":"https://example.test"}]})
};
document["paths"] = json!({
"/items/{id}": {
"parameters": [parameter("id", "path", "string"), parameter("filter", "query", "string")],
"get": {"operationId":"readItem","responses":{"200":{"description":"ok"}}},
"post": {"operationId":"updateItem","parameters":[parameter("filter", "query", "integer")],
"responses":{"200":{"description":"ok"}}}
}
});
let source = serde_json::to_string(&document).unwrap();
let digest =
SourceDigest::parse(format!("{:x}", Sha256::digest(source.as_bytes()))).unwrap();
let ir =
normalize_verified_document(&source, digest, &NormalizationConfig::default()).unwrap();
for (key, expected_kind) in [
("GET /items/{id}", "string"),
("POST /items/{id}", "integer"),
] {
let operation = ir
.operations
.iter()
.find(|operation| operation.key == key)
.unwrap();
assert_eq!(
operation.parameters.len(),
2,
"{version} {key}: {:?}",
operation.parameters
);
let id = operation
.parameters
.iter()
.find(|parameter| parameter.name == "id")
.unwrap();
assert_eq!(id.location, crank_import::rest::RestParameterLocation::Path);
let filter = operation
.parameters
.iter()
.find(|parameter| parameter.name == "filter")
.unwrap();
let schema = serde_json::to_value(filter.schema.as_ref().unwrap()).unwrap();
assert_eq!(
schema["kind"]["scalar_type"],
Value::String(expected_kind.to_owned()),
"{version} {key}: {schema}"
);
}
}
}
+689
View File
@@ -0,0 +1,689 @@
//! Focused regressions for the effective security scope
//! (story 2.14 review findings):
//!
//! - an OR array with an empty requirement object `{}` exposes the public
//! alternative and must keep the affected operation actionable, without
//! touching other operations;
//! - a single non-empty requirement must remain a blocker (regression anchor);
//! - malformed security shapes (non-array value, non-object array item) must
//! produce a source-located operation blocker instead of silently
//! disappearing.
use crank_import::rest::{
ImportFindingSeverity, ImportOperationCandidate, NormalizationConfig, NormalizedFinding,
SourceDigest, normalize_verified_document, preview_from_ir,
};
use serde_json::{Value, json};
use sha2::{Digest, Sha256};
fn hex(bytes: impl AsRef<[u8]>) -> String {
Sha256::digest(bytes)
.iter()
.map(|b| format!("{b:02x}"))
.collect()
}
fn run(
source: &Value,
) -> (
crank_import::rest::NormalizedIr,
crank_import::rest::ImportPreview,
) {
let text = serde_json::to_string(source).unwrap();
let source_digest = SourceDigest::parse(hex(text.as_bytes())).expect("sha256 is valid");
let ir = normalize_verified_document(&text, source_digest, &NormalizationConfig::default())
.expect("security-scope fixture parses");
let preview = preview_from_ir(&ir);
(ir, preview)
}
fn candidate<'a>(
preview: &'a crank_import::rest::ImportPreview,
key: &str,
) -> &'a ImportOperationCandidate {
preview
.groups
.iter()
.flat_map(|group| &group.operations)
.find(|candidate| candidate.key == key)
.unwrap_or_else(|| panic!("{key} candidate missing in {preview:?}"))
}
fn security_findings<'a>(
findings: &'a [NormalizedFinding],
key: &str,
) -> Vec<&'a NormalizedFinding> {
findings
.iter()
.filter(|finding| {
finding.code == "unsupported_security_requirement"
&& finding.severity == ImportFindingSeverity::Error
&& finding.operation_key.as_deref() == Some(key)
})
.collect()
}
#[test]
fn empty_or_alternative_makes_the_operation_public() {
// Document-level OR array: [{"probe": []}, {}] offers an explicit public
// alternative, so the inherited operation must stay actionable.
let source = json!({
"openapi": "3.0.3",
"info": { "title": "Security scope regression", "version": "1" },
"servers": [{ "url": "https://security-scope.example.test" }],
"components": {
"securitySchemes": { "probe": { "type": "http", "scheme": "basic" } }
},
"security": [{ "probe": [] }, {}],
"paths": {
"/public": { "get": { "operationId": "publicInherit",
"responses": { "200": { "description": "ok" } } } }
}
});
let (ir, preview) = run(&source);
let public = candidate(&preview, "GET /public");
assert!(
public
.findings
.iter()
.all(|finding| finding.severity != ImportFindingSeverity::Error),
"empty OR alternative must keep the inherited operation public: {:?}",
public.findings
);
assert!(
security_findings(&ir.findings, "GET /public").is_empty(),
"no security blocker may belong to the public operation: {:?}",
ir.findings
);
assert!(
preview.findings.iter().all(|finding| {
!(finding.severity == ImportFindingSeverity::Error && finding.operation_key.is_none())
}),
"no document-global blocker may be produced: {preview:?}"
);
}
#[test]
fn or_alternative_keeps_only_that_operation_public() {
let source = json!({
"openapi": "3.0.3",
"info": { "title": "Security scope regression", "version": "1" },
"servers": [{ "url": "https://security-scope.example.test" }],
"components": {
"securitySchemes": { "probe": { "type": "http", "scheme": "basic" } }
},
"paths": {
"/open": { "get": { "security": [{ "probe": [] }, {}], "operationId": "openOp",
"responses": { "200": { "description": "ok" } } } },
"/closed": { "get": { "security": [{ "probe": [] }], "operationId": "closedOp",
"responses": { "200": { "description": "ok" } } } }
}
});
let (ir, preview) = run(&source);
let open = candidate(&preview, "GET /open");
assert!(
open.findings
.iter()
.all(|finding| { finding.severity != ImportFindingSeverity::Error }),
"operation with a public OR alternative must stay actionable: {:?}",
open.findings
);
let closed = candidate(&preview, "GET /closed");
assert!(
closed.findings.iter().any(|finding| {
finding.code == "unsupported_security_requirement"
&& finding.severity == ImportFindingSeverity::Error
}),
"non-empty requirement must still block the candidate: {:?}",
closed.findings
);
let ir_blocker = security_findings(&ir.findings, "GET /closed")[0];
assert_eq!(
ir_blocker.location.pointer, "/paths/~1closed/get/security/0",
"blocker must point at the local requirement: {:?}",
ir_blocker
);
assert!(
security_findings(&ir.findings, "GET /closed").len() == 1,
"exactly one blocker for the closed operation: {:?}",
ir.findings
);
assert!(
security_findings(&ir.findings, "GET /open").is_empty(),
"the public alternative must not leak into the open operation: {:?}",
ir.findings
);
}
#[test]
fn nonempty_requirement_still_blocks_with_auth_profile_contract() {
let source = json!({
"openapi": "3.0.3",
"info": { "title": "Security scope regression", "version": "1" },
"servers": [{ "url": "https://security-scope.example.test" }],
"components": {
"securitySchemes": { "probe": { "type": "http", "scheme": "basic" } }
},
"security": [{ "probe": [] }],
"paths": {
"/secured": { "get": { "operationId": "securedOp",
"responses": { "200": { "description": "ok" } } } }
}
});
let (ir, preview) = run(&source);
let blocker = security_findings(&ir.findings, "GET /secured")
.into_iter()
.next()
.cloned()
.unwrap_or_else(|| panic!("non-empty requirement must block: {:?}", ir.findings));
assert_eq!(blocker.location.pointer, "/security/0");
assert_eq!(
blocker.message,
"Требование безопасности должно быть привязано к настроенному Auth Profile перед публикацией этой операции; остальные операции не блокируются.",
"Auth Profile contract message must be stable"
);
let secured = candidate(&preview, "GET /secured");
assert!(
secured.findings.iter().any(|finding| {
finding.code == "unsupported_security_requirement"
&& finding.severity == ImportFindingSeverity::Error
}),
"blocked candidate must expose the blocker: {:?}",
secured.findings
);
}
#[test]
fn malformed_security_shapes_block_the_affected_operation() {
// Non-array security value: both inherited operations are affected.
let source = json!({
"openapi": "3.0.3",
"info": { "title": "Security scope regression", "version": "1" },
"servers": [{ "url": "https://security-scope.example.test" }],
"security": "basic",
"paths": {
"/one": { "get": { "operationId": "oneOp",
"responses": { "200": { "description": "ok" } } } },
"/two": { "get": { "operationId": "twoOp",
"responses": { "200": { "description": "ok" } } } }
}
});
let (ir, preview) = run(&source);
for key in ["GET /one", "GET /two"] {
let blocker = security_findings(&ir.findings, key)
.into_iter()
.next()
.cloned()
.unwrap_or_else(|| panic!("non-array security must block {key}: {:?}", ir.findings));
assert_eq!(
blocker.location.pointer, "/security",
"blocker must point at the malformed root security: {:?}",
blocker
);
assert!(
candidate(&preview, key).findings.iter().any(|finding| {
finding.code == "unsupported_security_requirement"
&& finding.severity == ImportFindingSeverity::Error
}),
"{key} candidate must be blocked"
);
}
// Non-object array item: the item pointer must be preserved.
let source = json!({
"openapi": "3.0.3",
"info": { "title": "Security scope regression", "version": "1" },
"servers": [{ "url": "https://security-scope.example.test" }],
"security": ["basic"],
"paths": {
"/one": { "get": { "operationId": "oneOp",
"responses": { "200": { "description": "ok" } } } }
}
});
let (ir, _) = run(&source);
let blocker = security_findings(&ir.findings, "GET /one")
.into_iter()
.next()
.cloned()
.unwrap_or_else(|| panic!("non-object security item must block: {:?}", ir.findings));
assert_eq!(
blocker.location.pointer, "/security/0",
"blocker must point at the malformed item: {:?}",
blocker
);
// Malformed operation-level security must not affect the neighbour.
let source = json!({
"openapi": "3.0.3",
"info": { "title": "Security scope regression", "version": "1" },
"servers": [{ "url": "https://security-scope.example.test" }],
"paths": {
"/bad": { "get": { "security": "basic", "operationId": "badOp",
"responses": { "200": { "description": "ok" } } } },
"/fine": { "get": { "operationId": "fineOp",
"responses": { "200": { "description": "ok" } } } }
}
});
let (ir, preview) = run(&source);
let blocker = security_findings(&ir.findings, "GET /bad")
.into_iter()
.next()
.cloned()
.unwrap_or_else(|| panic!("malformed local security must block: {:?}", ir.findings));
assert_eq!(
blocker.location.pointer, "/paths/~1bad/get/security",
"blocker must point at the malformed local security: {:?}",
blocker
);
assert!(
security_findings(&ir.findings, "GET /fine").is_empty(),
"the neighbour operation must not inherit a local defect: {:?}",
ir.findings
);
assert!(
candidate(&preview, "GET /fine")
.findings
.iter()
.all(|finding| finding.severity != ImportFindingSeverity::Error),
"neighbour operation must stay actionable"
);
}
#[test]
fn empty_alternative_needs_a_well_formed_array() {
// A malformed item in the same array invalidates the public
// alternative: every alternative is reported, and the operation
// stays blocked instead of silently becoming public.
let source = json!({
"openapi": "3.0.3",
"info": { "title": "Security scope regression", "version": "1" },
"servers": [{ "url": "https://security-scope.example.test" }],
"components": {
"securitySchemes": { "probe": { "type": "http", "scheme": "basic" } }
},
"security": [{ "probe": [] }, {}, "basic"],
"paths": {
"/mixed": { "get": { "operationId": "mixedOp",
"responses": { "200": { "description": "ok" } } } }
}
});
let (ir, preview) = run(&source);
let at_item = |pointer: &str| {
ir.findings
.iter()
.find(|finding| {
finding.code == "unsupported_security_requirement"
&& finding.operation_key.as_deref() == Some("GET /mixed")
&& finding.location.pointer == pointer
})
.unwrap_or_else(|| panic!("blocker at {pointer} missing: {:?}", ir.findings))
};
let secured = at_item("/security/0");
assert_eq!(
secured.message,
"Требование безопасности должно быть привязано к настроенному Auth Profile перед публикацией этой операции; остальные операции не блокируются."
);
let malformed = at_item("/security/2");
assert_eq!(
malformed.message,
"security содержит альтернативу без объекта требований: формат не поддерживается, операция не публикуется."
);
assert!(
candidate(&preview, "GET /mixed")
.findings
.iter()
.any(|finding| finding.severity == ImportFindingSeverity::Error),
"the operation must not become public because of a malformed sibling: {preview:?}"
);
}
fn security_fixture_31() -> serde_json::Map<String, Value> {
security_fixture_openapi("3.1.0")
}
#[test]
fn object_instead_of_security_array_has_scoped_coverage() {
for version in ["3.0.3", "3.1.0", "2.0"] {
for local in [false, true] {
let mut fixture = if version == "2.0" {
security_fixture_swagger2()
} else {
security_fixture_openapi(version)
};
if !local {
fixture.insert("security".to_owned(), json!({}));
}
fixture.insert(
"paths".to_owned(),
json!({
"/bad": get200("badObject", local.then(|| json!({}))),
"/public": get200("publicObject", Some(json!([])))
}),
);
let (ir, preview) = run(&Value::Object(fixture));
let expected = if local {
"/paths/~1bad/get/security"
} else {
"/security"
};
let blocker = security_findings(&ir.findings, "GET /bad");
assert_eq!(blocker.len(), 1, "{version} {local}: {:?}", ir.findings);
assert_eq!(blocker[0].location.pointer, expected);
assert!(security_findings(&ir.findings, "GET /public").is_empty());
assert!(
candidate(&preview, "GET /public")
.findings
.iter()
.all(|finding| finding.severity != ImportFindingSeverity::Error)
);
crank_import::rest::validate_normalized_ir(&ir).unwrap();
}
}
}
fn security_fixture_openapi(version: &str) -> serde_json::Map<String, Value> {
let mut fixture = serde_json::Map::new();
fixture.insert("openapi".to_owned(), json!(version));
fixture.insert(
"info".to_owned(),
json!({ "title": "Security scope regression", "version": "1" }),
);
fixture.insert(
"servers".to_owned(),
json!([{ "url": "https://security-scope.example.test" }]),
);
fixture
}
fn security_fixture_swagger2() -> serde_json::Map<String, Value> {
let mut fixture = serde_json::Map::new();
fixture.insert("swagger".to_owned(), json!("2.0"));
fixture.insert(
"info".to_owned(),
json!({ "title": "Security scope regression" }),
);
fixture.insert("host".to_owned(), json!("security-scope.example.test"));
fixture.insert("schemes".to_owned(), json!(["https"]));
fixture
}
fn get200(operation_id: &str, security: Option<Value>) -> Value {
let mut get = serde_json::Map::from_iter([
("operationId".to_owned(), json!(operation_id)),
(
"responses".to_owned(),
json!({ "200": { "description": "ok" } }),
),
]);
if let Some(security) = security {
get.insert("security".to_owned(), security);
}
let mut path_item = serde_json::Map::new();
path_item.insert("get".to_owned(), Value::Object(get));
Value::Object(path_item)
}
#[test]
fn openapi_31_non_array_root_security_blocks_inherited_operations() {
let mut fixture = security_fixture_31();
fixture.insert("security".to_owned(), json!("basic"));
fixture.insert(
"paths".to_owned(),
json!({
"/one": get200("oneOp31", None),
"/two": get200("twoOp31", None)
}),
);
let (ir, preview) = run(&Value::Object(fixture));
for key in ["GET /one", "GET /two"] {
let blockers = security_findings(&ir.findings, key);
assert_eq!(
blockers.len(),
1,
"exactly one blocker for {key}: {:?}",
ir.findings
);
let blocker = &blockers[0];
assert_eq!(
blocker.code, "unsupported_security_requirement",
"stable finding code: {blocker:?}"
);
assert_eq!(
blocker.severity,
ImportFindingSeverity::Error,
"stable finding severity: {blocker:?}"
);
assert_eq!(
blocker.location.pointer, "/security",
"blocker must point at the malformed root security: {blocker:?}"
);
assert!(
candidate(&preview, key).findings.iter().any(|finding| {
finding.code == "unsupported_security_requirement"
&& finding.severity == ImportFindingSeverity::Error
}),
"{key} candidate must be blocked"
);
}
}
#[test]
fn openapi_31_malformed_local_security_affects_only_that_operation() {
let mut fixture = security_fixture_31();
// A well-formed root requirement proves priority: the malformed local
// security wins for /bad (no root blocker may be added), while /public
// relies on an explicit empty override to stay public.
fixture.insert("security".to_owned(), json!([{ "probe": [] }]));
fixture.insert(
"paths".to_owned(),
json!({
"/bad": get200("badOp31", Some(json!("basic"))),
"/public": get200("publicOp31", Some(json!([])))
}),
);
let (ir, preview) = run(&Value::Object(fixture));
let blockers = security_findings(&ir.findings, "GET /bad");
assert_eq!(blockers.len(), 1, "exactly one blocker: {:?}", ir.findings);
assert_eq!(
blockers[0].code, "unsupported_security_requirement",
"stable finding code"
);
assert_eq!(
blockers[0].severity,
ImportFindingSeverity::Error,
"stable finding severity"
);
assert_eq!(
blockers[0].location.pointer, "/paths/~1bad/get/security",
"blocker must point at the malformed local security: {:?}",
blockers[0]
);
assert!(
security_findings(&ir.findings, "GET /public").is_empty(),
"the public neighbour must not inherit a local defect: {:?}",
ir.findings
);
assert!(
candidate(&preview, "GET /public")
.findings
.iter()
.all(|finding| finding.severity != ImportFindingSeverity::Error),
"public neighbour must stay actionable: {preview:?}"
);
}
#[test]
fn openapi_31_public_alternative_with_malformed_sibling_does_not_go_public() {
let mut fixture = security_fixture_31();
fixture.insert("security".to_owned(), json!([{}, "basic"]));
fixture.insert(
"paths".to_owned(),
json!({ "/mixed": get200("mixedOp31", None) }),
);
let (ir, preview) = run(&Value::Object(fixture));
let blockers = security_findings(&ir.findings, "GET /mixed");
assert_eq!(
blockers.len(),
1,
"only the malformed sibling blocks: {:?}",
ir.findings
);
assert_eq!(
blockers[0].location.pointer, "/security/1",
"blocker must point at the non-object item: {:?}",
blockers[0]
);
assert_eq!(
blockers[0].message,
"security содержит альтернативу без объекта требований: формат не поддерживается, операция не публикуется."
);
assert!(
candidate(&preview, "GET /mixed")
.findings
.iter()
.any(|finding| finding.severity == ImportFindingSeverity::Error),
"the operation must not become public because of a malformed sibling: {preview:?}"
);
}
#[test]
fn swagger2_non_array_root_security_blocks_inherited_operations() {
let mut fixture = security_fixture_swagger2();
fixture.insert("security".to_owned(), json!("apikey"));
fixture.insert(
"paths".to_owned(),
json!({
"/one": get200("oneOpS2", None),
"/two": get200("twoOpS2", None)
}),
);
let (ir, preview) = run(&Value::Object(fixture));
for key in ["GET /one", "GET /two"] {
let blockers = security_findings(&ir.findings, key);
assert_eq!(
blockers.len(),
1,
"exactly one blocker for {key}: {:?}",
ir.findings
);
let blocker = &blockers[0];
assert_eq!(
blocker.code, "unsupported_security_requirement",
"stable finding code: {blocker:?}"
);
assert_eq!(
blocker.severity,
ImportFindingSeverity::Error,
"stable finding severity: {blocker:?}"
);
assert_eq!(
blocker.location.pointer, "/security",
"blocker must point at the malformed root security: {blocker:?}"
);
assert!(
candidate(&preview, key).findings.iter().any(|finding| {
finding.code == "unsupported_security_requirement"
&& finding.severity == ImportFindingSeverity::Error
}),
"{key} candidate must be blocked"
);
}
}
#[test]
fn swagger2_malformed_local_security_affects_only_that_operation() {
let mut fixture = security_fixture_swagger2();
// A well-formed root requirement proves priority: the malformed local
// security wins for /bad (no root blocker may be added), while /public
// relies on an explicit empty override to stay public.
fixture.insert("security".to_owned(), json!([{ "apiKey": [] }]));
fixture.insert(
"paths".to_owned(),
json!({
"/bad": get200("badOpS2", Some(json!("apikey"))),
"/public": get200("publicOpS2", Some(json!([])))
}),
);
let (ir, preview) = run(&Value::Object(fixture));
let blockers = security_findings(&ir.findings, "GET /bad");
assert_eq!(blockers.len(), 1, "exactly one blocker: {:?}", ir.findings);
assert_eq!(blockers[0].code, "unsupported_security_requirement");
assert_eq!(blockers[0].severity, ImportFindingSeverity::Error);
assert_eq!(
blockers[0].location.pointer, "/paths/~1bad/get/security",
"blocker must point at the malformed local security: {:?}",
blockers[0]
);
assert!(
security_findings(&ir.findings, "GET /public").is_empty(),
"the public neighbour must not inherit a local defect: {:?}",
ir.findings
);
assert!(
candidate(&preview, "GET /public")
.findings
.iter()
.all(|finding| finding.severity != ImportFindingSeverity::Error),
"public neighbour must stay actionable: {preview:?}"
);
}
#[test]
fn swagger2_public_alternative_with_malformed_sibling_does_not_go_public() {
let mut fixture = security_fixture_swagger2();
fixture.insert("security".to_owned(), json!([{}, "apikey"]));
fixture.insert(
"paths".to_owned(),
json!({ "/mixed": get200("mixedOpS2", None) }),
);
let (ir, preview) = run(&Value::Object(fixture));
let blockers = security_findings(&ir.findings, "GET /mixed");
assert_eq!(
blockers.len(),
1,
"only the malformed sibling blocks: {:?}",
ir.findings
);
assert_eq!(
blockers[0].location.pointer, "/security/1",
"blocker must point at the non-object item: {:?}",
blockers[0]
);
assert_eq!(
blockers[0].message,
"security содержит альтернативу без объекта требований: формат не поддерживается, операция не публикуется."
);
assert!(
candidate(&preview, "GET /mixed")
.findings
.iter()
.any(|finding| finding.severity == ImportFindingSeverity::Error),
"the operation must not become public because of a malformed sibling: {preview:?}"
);
}
#[test]
fn empty_security_array_stays_public() {
let source = json!({
"openapi": "3.0.3",
"info": { "title": "Security scope regression", "version": "1" },
"servers": [{ "url": "https://security-scope.example.test" }],
"security": [{ "probe": [] }],
"paths": {
"/public": { "get": { "security": [], "operationId": "publicOp",
"responses": { "200": { "description": "ok" } } } }
}
});
let (ir, preview) = run(&source);
assert!(
security_findings(&ir.findings, "GET /public").is_empty(),
"explicit empty override must stay public: {:?}",
ir.findings
);
assert!(
candidate(&preview, "GET /public")
.findings
.iter()
.all(|finding| finding.severity != ImportFindingSeverity::Error),
"overridden operation must remain actionable"
);
}
File diff suppressed because it is too large. Load diff
+19
View File
@@ -81,3 +81,22 @@ Semantic loss получает blocker с source location: такой candidate
Новые imports используют `normalized-ir-v4` / `preview-v4`. Сохранённые v2/v3 jobs воспроизводят сохранённый preview, а legacy-v1 использует отдельную историческую projection. Обновление importer не меняет inputs существующих jobs.
Другие форматы спецификаций и протоколов в Community-импорт не входят.
## Нормативная матрица и regression corpus
Машинная матрица версии `1.0.2` хранится в [`crates/crank-import/tests/support-matrix.yaml`](../crates/crank-import/tests/support-matrix.yaml); corpus version — `1.0.3`. Матрица фиксирует контракт отдельно для OpenAPI 3.0, OpenAPI 3.1 и Swagger 2.0. Acceptance test запускает нормализатор на отдельном probe для каждой строки, включая все 100 успешных кодов в каждом формате, и сверяет сохранённую semantics или точный blocker; выполненные probes списываются со всех строк версии, поэтому неподвергнутая проверкой строка матрицы падает gate. Версия corpus `1.0.3` добавляет hostile fixture `hostile-security-scope.json`: document-level требование безопасности блокирует только унаследовавшего его secured candidate (`GET /secure`, location `/security/0`), а операция с явным `security: []` (`GET /public`) остаётся actionable без глобального blocker; oversized hostile JSON остаётся тем же canonical JSON с ожидаемым parser rejection.
| Конструкция | OpenAPI 3.0/3.1 | Swagger 2.0 | Сохраняемый контракт или finding |
|---|---|---|---|
| `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `HEAD`, `OPTIONS` | Поддерживается | Поддерживается | Метод и исходный path переходят в Operation |
| `path`, `query`, `header`, `cookie` параметры | Поддерживается | `path`, `query`, `header` поддерживаются; `cookie` явно unsupported | Имя, schema, required и source location сохраняются; Swagger cookie получает `unsupported_cookie_parameter` |
| JSON, urlencoded, multipart | Поддерживается | Поддерживается по `consumes`/body parameter | Schema и content type остаются частью request contract |
| Успешные `2xx`, включая `204` | Поддерживается | Поддерживается | Каждая строка 200–299 проверяется отдельным probe; status сохраняется, а 204/205 остаются bodyless |
| Локальные и allowlisted external `$ref` | Поддерживается | Поддерживается | Разрешение только из загруженного документа или digest-проверенного snapshot; тесты не загружают fixture по сети |
| `allOf`, `oneOf`, `anyOf` | Поддерживается | Поддерживается | Совместимые `allOf` ветви объединяются; `oneOf` и `anyOf` остаются вариантами schema |
| bearer/basic/API key security requirements | Blocker до выбора Auth Profile | Blocker до выбора Auth Profile | `unsupported_security_requirement`; requirement вычисляется per-operation с наследованием document-уровня; credentials не импортируются и не попадают в preview |
| security override: operation-level `security: []` | Поддерживается | Поддерживается | Явный пустой массив отключает наследование: только operations с эффективным requirement получают source-located blocker, связанные операции остаются actionable |
| Микс public/secured operations | Поддерживается | Подвергается проверке | Blocker принадлежит только затронутому candidate; global blocker не создаётся для требований одного operation |
| XML, `TRACE`, `CONNECT` | Unsupported | Unsupported | Source-located finding; blocker не становится actionable Draft |
Offline corpus в `crates/crank-import/tests/corpus/` содержит 50 synthetic representative документов и hostile subset. Manifest фиксирует SHA-256 исходных файлов, canonical digest JSON, происхождение и лицензию; для representative документов он также фиксирует полный canonical preview и frozen candidates (schemas, mappings, actionable/blocker), а для hostile — ожидаемые отказы и findings. Команда `just openapi-corpus` прогоняет настоящий normalizer, сравнивает независимо перечисленные raw source pointers с canonical source tree и coverage ledger, проверяет порог 95% actionable от всех representative Operations и отдельно нулевой silent loss. Evidence связывает digest manifest и matrix, включает content digest и создаётся без перезаписи; конфликт содержимого для того же identity останавливает gate. CI прикладывает `crates/crank-import/target/openapi-corpus/evidence-<identity>.json`. Artifact не содержит загруженный исходник или значения secret-like examples.
+6
View File
@@ -44,6 +44,12 @@ clippy:
test:
cargo test --workspace --all-targets -- --test-threads=1
openapi-corpus:
cargo test -p crank-import --test corpus -- --test-threads=1
openapi-matrix-compat base:
python3 scripts/check-openapi-matrix-compatibility.py --base "{{base}}"
sqlx-prepare database_url:
DATABASE_URL={{database_url}} cargo sqlx prepare --workspace -- --all-targets
+189
View File
@@ -0,0 +1,189 @@
#!/usr/bin/env python3
"""Require versioned, explained compatibility changes to OpenAPI contracts."""
from __future__ import annotations
import argparse
import json
import re
import subprocess
import sys
from typing import Any
MATRIX_PATH = "crates/crank-import/tests/support-matrix.yaml"
MANIFEST_PATH = "crates/crank-import/tests/corpus/manifest.json"
DOCS_PATH = "docs/openapi-import.md"
def git_show(revision: str, path: str) -> str | None:
result = subprocess.run(
["git", "show", f"{revision}:{path}"],
check=False,
capture_output=True,
text=True,
)
return result.stdout if result.returncode == 0 else None
def matrix_version(contents: str | None) -> str | None:
if contents is None:
return None
match = re.search(r"(?m)^matrix_version:\s*['\"]?([^\s'\"]+)", contents)
return match.group(1) if match else None
def parse_manifest(contents: str | None, label: str) -> dict[str, Any] | None:
if contents is None:
return None
try:
value = json.loads(contents)
except json.JSONDecodeError as error:
raise ValueError(f"{label} is not valid JSON: {error}") from error
if not isinstance(value, dict):
raise ValueError(f"{label} must be a JSON object")
return value
def require(condition: bool, message: str, errors: list[str]) -> None:
if not condition:
errors.append(message)
def valid_version(value: Any) -> bool:
return isinstance(value, str) and re.fullmatch(
r"(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)", value
) is not None
def version_increases(old: Any, new: Any) -> bool:
"""Compare the numeric contract versions used by the matrix and corpus."""
if not valid_version(old) or not valid_version(new):
return False
return tuple(map(int, new.split("."))) > tuple(map(int, old.split(".")))
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--base", required=True, help="base commit or ref to compare against")
args = parser.parse_args()
try:
subprocess.run(
["git", "rev-parse", "--verify", f"{args.base}^{{commit}}"],
check=True,
capture_output=True,
text=True,
)
except subprocess.CalledProcessError:
print(f"OpenAPI compatibility guard: base revision {args.base!r} is unavailable", file=sys.stderr)
return 2
try:
old_matrix_text = git_show(args.base, MATRIX_PATH)
old_manifest_text = git_show(args.base, MANIFEST_PATH)
with open(MATRIX_PATH, encoding="utf-8") as matrix_file:
new_matrix_text = matrix_file.read()
with open(MANIFEST_PATH, encoding="utf-8") as manifest_file:
new_manifest_text = manifest_file.read()
with open(DOCS_PATH, encoding="utf-8") as docs_file:
new_docs_text = docs_file.read()
old_manifest = parse_manifest(old_manifest_text, "base manifest")
new_manifest = parse_manifest(new_manifest_text, "working manifest")
except (OSError, ValueError) as error:
print(f"OpenAPI compatibility guard: {error}", file=sys.stderr)
return 2
matrix_changed = old_matrix_text != new_matrix_text
manifest_changed = old_manifest_text != new_manifest_text
errors: list[str] = []
old_matrix_version = matrix_version(old_matrix_text)
new_matrix_version = matrix_version(new_matrix_text)
new_corpus_version = new_manifest.get("corpus_version")
new_impact = new_manifest.get("compatibility_impact")
require(bool(new_matrix_version), "support matrix must declare matrix_version", errors)
require(bool(new_corpus_version), "corpus manifest must declare corpus_version", errors)
require(valid_version(new_matrix_version), "matrix_version must be numeric SemVer", errors)
require(valid_version(new_corpus_version), "corpus_version must be numeric SemVer", errors)
require(
new_manifest.get("matrix_version") == new_matrix_version,
"manifest matrix_version must match support matrix",
errors,
)
require(
isinstance(new_impact, str) and bool(new_impact.strip()),
"corpus manifest must include a non-empty compatibility_impact note",
errors,
)
if matrix_changed and old_matrix_text is not None:
require(
version_increases(old_matrix_version, new_matrix_version),
"support-matrix.yaml changed without a matrix_version bump (must increase SemVer)",
errors,
)
old_matrix_was_present = old_matrix_text is not None
if matrix_changed and old_matrix_was_present:
old_impact = old_manifest.get("compatibility_impact") if old_manifest else None
require(
new_impact != old_impact,
"support matrix changed without updating compatibility_impact",
errors,
)
# The published documentation states concrete matrix/corpus versions;
# a stale or mixed version in docs must not outlive the machine source.
matrix_decls = re.findall(
r"матриц[аы] версии `([0-9]+\.[0-9]+\.[0-9]+)`", new_docs_text, re.IGNORECASE
)
corpus_decls = re.findall(
r"corpus version — `([0-9]+\.[0-9]+\.[0-9]+)`", new_docs_text, re.IGNORECASE
)
require(
bool(matrix_decls) and all(version == new_matrix_version for version in matrix_decls),
f"{DOCS_PATH} matrix version declaration must state matrix_version {new_matrix_version}",
errors,
)
require(
bool(corpus_decls) and all(version == new_corpus_version for version in corpus_decls),
f"{DOCS_PATH} corpus version declaration must state corpus_version {new_corpus_version}",
errors,
)
require(
bool(matrix_decls) and bool(corpus_decls)
and all(version == new_matrix_version for version in matrix_decls)
and all(version == new_corpus_version for version in corpus_decls),
f"{DOCS_PATH} must state the current support matrix and corpus versions",
errors,
)
if old_manifest is not None:
if old_manifest != new_manifest:
require(
version_increases(old_manifest.get("corpus_version"), new_corpus_version),
"corpus manifest changed without a corpus_version bump (must increase SemVer)",
errors,
)
require(
new_impact != old_manifest.get("compatibility_impact"),
"corpus manifest changed without updating compatibility_impact",
errors,
)
if errors:
print("OpenAPI compatibility guard failed:", file=sys.stderr)
for error in errors:
print(f"- {error}", file=sys.stderr)
return 1
print(
"OpenAPI compatibility guard passed: "
f"matrix {old_matrix_version or '<new>'} -> {new_matrix_version}; "
f"corpus {old_manifest.get('corpus_version') if old_manifest else '<new>'} -> {new_corpus_version}"
)
if not matrix_changed and not manifest_changed:
print("OpenAPI compatibility guard: matrix and corpus manifest are unchanged")
return 0
if __name__ == "__main__":
raise SystemExit(main())
@@ -0,0 +1,271 @@
import json
import subprocess
import tempfile
import unittest
from pathlib import Path
SCRIPT = Path(__file__).parents[2] / "scripts" / "check-openapi-matrix-compatibility.py"
MATRIX_PATH = "crates/crank-import/tests/support-matrix.yaml"
MANIFEST_PATH = "crates/crank-import/tests/corpus/manifest.json"
DOCS_PATH = "docs/openapi-import.md"
BASE_MATRIX = """matrix_version: '1.0.0'
constructs:
- id: baseline
"""
BASE_DOC = "Матрица версии `1.0.0`; corpus version — `1.0.0`.\n"
def base_manifest() -> dict:
return {
"corpus_version": "1.0.0",
"matrix_version": "1.0.0",
"compatibility_impact": "initial contract",
"documents": [
{
"id": "rep-00",
"file": "representative-00.json",
"sha256": "a" * 64,
"origin": "synthetic:cc0",
"license": "CC0-1.0",
"specification_version": "OpenAPI 3.0",
"classification": "representative",
"expected_preview": {},
}
],
}
class OpenApiMatrixCompatibilityGuardTests(unittest.TestCase):
def setUp(self) -> None:
self._directory = tempfile.TemporaryDirectory()
self.root = Path(self._directory.name)
subprocess.run(
["git", "init", "-q"], cwd=self.root, check=True, capture_output=True
)
for relative in (MATRIX_PATH, MANIFEST_PATH, DOCS_PATH):
target = self.root / relative
target.parent.mkdir(parents=True, exist_ok=True)
(self.root / MATRIX_PATH).write_text(BASE_MATRIX, encoding="utf-8")
(self.root / MANIFEST_PATH).write_text(
json.dumps(base_manifest()), encoding="utf-8"
)
(self.root / DOCS_PATH).write_text(BASE_DOC, encoding="utf-8")
self.commit("base")
self.base = self.head()
def tearDown(self) -> None:
self._directory.cleanup()
def self_git(self, *args: str) -> None:
subprocess.run(
["git", "-c", "user.email=guard@test", "-c", "user.name=guard", *args],
cwd=self.root,
check=True,
capture_output=True,
)
def commit(self, message: str) -> None:
self.self_git("add", "-A")
self.self_git("commit", "-m", message)
def head(self) -> str:
result = subprocess.run(
["git", "rev-parse", "HEAD"],
cwd=self.root,
check=True,
capture_output=True,
text=True,
)
return result.stdout.strip()
def run_guard(self) -> subprocess.CompletedProcess[str]:
return subprocess.run(
["python3", str(SCRIPT), "--base", self.base],
cwd=self.root,
text=True,
capture_output=True,
check=False,
)
def test_rejects_docs_only_edit_with_stale_version(self) -> None:
# matrix and manifest are untouched relative to the base, but a docs
# edit that pins a stale contract version must still be rejected
(self.root / DOCS_PATH).write_text(
"Матрица версии `0.9.0`; corpus version — `0.9.0`.\n", encoding="utf-8"
)
result = self.run_guard()
self.assertEqual(result.returncode, 1, result.stderr)
self.assertIn(
"must state the current support matrix and corpus versions", result.stderr
)
def test_rejects_docs_with_reversed_matrix_and_corpus_versions(self) -> None:
(self.root / MATRIX_PATH).write_text(
BASE_MATRIX.replace("'1.0.0'", "'1.1.0'") + " - id: addition\n",
encoding="utf-8",
)
manifest = base_manifest()
manifest["matrix_version"] = "1.1.0"
manifest["corpus_version"] = "1.0.1"
manifest["compatibility_impact"] = "bumped release"
(self.root / MANIFEST_PATH).write_text(json.dumps(manifest), encoding="utf-8")
(self.root / DOCS_PATH).write_text(
"Матрица версии `1.0.1`; corpus version — `1.1.0`.\n", encoding="utf-8"
)
result = self.run_guard()
self.assertEqual(result.returncode, 1, result.stderr)
self.assertIn(
"matrix version declaration must state matrix_version 1.1.0", result.stderr
)
def test_rejects_contract_change_without_version_bump_on_existing_base(self) -> None:
# The base already contains the contract: appending a matrix row must be
# rejected even though the versions and impact note stay untouched.
(self.root / MATRIX_PATH).write_text(
BASE_MATRIX + " - id: addition\n", encoding="utf-8"
)
result = self.run_guard()
self.assertEqual(result.returncode, 1, result.stderr)
self.assertIn("changed without a matrix_version bump", result.stderr)
self.assertIn("without updating compatibility_impact", result.stderr)
def test_rejects_matrix_version_downgrade(self) -> None:
(self.root / MATRIX_PATH).write_text(
BASE_MATRIX.replace("'1.0.0'", "'0.9.0'") + " - id: addition\n",
encoding="utf-8",
)
manifest = base_manifest()
manifest["matrix_version"] = "0.9.0"
manifest["compatibility_impact"] = "downgraded matrix"
(self.root / MANIFEST_PATH).write_text(json.dumps(manifest), encoding="utf-8")
(self.root / DOCS_PATH).write_text(
"Матрица версии `0.9.0`; corpus version — `1.0.0`.\n", encoding="utf-8"
)
result = self.run_guard()
self.assertEqual(result.returncode, 1, result.stderr)
self.assertIn("matrix_version bump (must increase SemVer)", result.stderr)
def test_rejects_manifest_change_without_corpus_bump_on_existing_base(self) -> None:
manifest = base_manifest()
manifest["documents"][0]["file"] = "representative-99.json"
(self.root / MANIFEST_PATH).write_text(json.dumps(manifest), encoding="utf-8")
result = self.run_guard()
self.assertEqual(result.returncode, 1, result.stderr)
self.assertIn("without a corpus_version bump", result.stderr)
self.assertIn("without updating compatibility_impact", result.stderr)
def test_rejects_corpus_version_downgrade(self) -> None:
manifest = base_manifest()
manifest["corpus_version"] = "0.9.0"
manifest["compatibility_impact"] = "downgraded corpus"
manifest["documents"][0]["file"] = "representative-99.json"
(self.root / MANIFEST_PATH).write_text(json.dumps(manifest), encoding="utf-8")
(self.root / DOCS_PATH).write_text(
"Матрица версии `1.0.0`; corpus version — `0.9.0`.\n", encoding="utf-8"
)
result = self.run_guard()
self.assertEqual(result.returncode, 1, result.stderr)
self.assertIn("corpus_version bump (must increase SemVer)", result.stderr)
def test_rejects_stale_versions_in_published_docs(self) -> None:
matrix = BASE_MATRIX.replace("'1.0.0'", "'1.1.0'") + " - id: addition\n"
(self.root / MATRIX_PATH).write_text(matrix, encoding="utf-8")
manifest = base_manifest()
manifest["matrix_version"] = "1.1.0"
manifest["corpus_version"] = "1.0.1"
manifest["compatibility_impact"] = "matrix 1.1.0 release"
(self.root / MANIFEST_PATH).write_text(json.dumps(manifest), encoding="utf-8")
# docs still pin the previous `1.0.0` release
result = self.run_guard()
self.assertEqual(result.returncode, 1, result.stderr)
self.assertIn("must state the current support matrix and corpus versions", result.stderr)
def test_rejects_docs_citing_versions_missing_from_release(self) -> None:
(self.root / MATRIX_PATH).write_text(
BASE_MATRIX + " - id: addition\n", encoding="utf-8"
)
manifest = base_manifest()
manifest["matrix_version"] = "1.1.0"
manifest["corpus_version"] = "1.1.0"
manifest["compatibility_impact"] = "matrix 1.1.0 release"
(self.root / MANIFEST_PATH).write_text(json.dumps(manifest), encoding="utf-8")
(self.root / DOCS_PATH).write_text(
"Матрица версии `1.1.0`; corpus version — `0.9.0`.\n", encoding="utf-8"
)
result = self.run_guard()
self.assertEqual(result.returncode, 1, result.stderr)
self.assertIn("must state the current support matrix and corpus versions", result.stderr)
def test_allows_other_semver_in_docs(self) -> None:
(self.root / DOCS_PATH).write_text(
"Матрица версии `1.0.0`; corpus version — `1.0.0`. OpenAPI `3.1.0`.\n",
encoding="utf-8",
)
result = self.run_guard()
self.assertEqual(result.returncode, 0, result.stderr)
def test_rejects_conflicting_second_version_declaration(self) -> None:
(self.root / DOCS_PATH).write_text(
BASE_DOC + "Матрица версии `0.9.0`; corpus version — `0.9.0`.\n",
encoding="utf-8",
)
result = self.run_guard()
self.assertEqual(result.returncode, 1, result.stderr)
self.assertIn("must state the current support matrix and corpus versions", result.stderr)
def test_rejects_leading_zero_in_contract_version(self) -> None:
(self.root / MATRIX_PATH).write_text(
BASE_MATRIX.replace("'1.0.0'", "'01.0.1'") + " - id: addition\n",
encoding="utf-8",
)
manifest = base_manifest()
manifest["matrix_version"] = "01.0.1"
manifest["compatibility_impact"] = "invalid version"
(self.root / MANIFEST_PATH).write_text(json.dumps(manifest), encoding="utf-8")
(self.root / DOCS_PATH).write_text(
"Матрица версии `01.0.1`; corpus version — `1.0.0`.\n",
encoding="utf-8",
)
result = self.run_guard()
self.assertEqual(result.returncode, 1, result.stderr)
self.assertIn("matrix_version bump (must increase SemVer)", result.stderr)
def test_rejects_manifest_metadata_change_without_bump(self) -> None:
manifest = base_manifest()
manifest["canonical_digest_definition"] = "changed contract"
(self.root / MANIFEST_PATH).write_text(json.dumps(manifest), encoding="utf-8")
result = self.run_guard()
self.assertEqual(result.returncode, 1, result.stderr)
self.assertIn("without a corpus_version bump", result.stderr)
def test_rejects_corpus_version_only_downgrade(self) -> None:
manifest = base_manifest()
manifest["corpus_version"] = "0.9.0"
manifest["compatibility_impact"] = "downgrade"
(self.root / MANIFEST_PATH).write_text(json.dumps(manifest), encoding="utf-8")
result = self.run_guard()
self.assertEqual(result.returncode, 1, result.stderr)
self.assertIn("corpus_version bump (must increase SemVer)", result.stderr)
def test_passes_consistent_bumped_release_with_updated_docs(self) -> None:
(self.root / MATRIX_PATH).write_text(
BASE_MATRIX.replace("'1.0.0'", "'1.1.0'") + " - id: addition\n",
encoding="utf-8",
)
manifest = base_manifest()
manifest["matrix_version"] = "1.1.0"
manifest["corpus_version"] = "1.0.1"
manifest["compatibility_impact"] = "matrix 1.1.0 release"
(self.root / MANIFEST_PATH).write_text(json.dumps(manifest), encoding="utf-8")
(self.root / DOCS_PATH).write_text(
"Матрица версии `1.1.0`; corpus version — `1.0.1`.\n", encoding="utf-8"
)
result = self.run_guard()
self.assertEqual(result.returncode, 0, result.stderr)
if __name__ == "__main__":
unittest.main()