feat(import): complete OpenAPI onboarding and verify delivery
This commit is contained in:
1 parent
bb3e376767
commit
e93de7015a
244 files changed
+57020
-5139
No files matched your search
@@ -4,9 +4,9 @@ use serde_json::Value;
|
||||
|
||||
use crate::rest::model::{
|
||||
CanonicalSourceNode, CanonicalSourceValue, CoverageDisposition, CoverageEntry,
|
||||
ImportSourcePreview, NORMALIZER_VERSION, NormalizedIr, NormalizedOperation, NormalizedPath,
|
||||
NormalizedReference, NormalizedSchema, NormalizedSchemaKind, PROJECTION_VERSION,
|
||||
SourceLocation,
|
||||
HISTORICAL_NORMALIZER_VERSION, HISTORICAL_PROJECTION_VERSION, ImportSourcePreview,
|
||||
NORMALIZER_VERSION, NormalizedIr, NormalizedOperation, NormalizedPath, NormalizedReference,
|
||||
NormalizedSchema, NormalizedSchemaKind, PROJECTION_VERSION, SourceLocation,
|
||||
};
|
||||
|
||||
use super::ImportParseError;
|
||||
@@ -16,11 +16,11 @@ pub(super) use super::normalize_schema::{
|
||||
};
|
||||
|
||||
pub(super) fn validate_coverage(ir: &NormalizedIr) -> Result<(), ImportParseError> {
|
||||
let current =
|
||||
ir.normalizer_version == NORMALIZER_VERSION && ir.projection_version == PROJECTION_VERSION;
|
||||
let historical_v4 = ir.normalizer_version == super::model::HISTORICAL_NORMALIZER_VERSION
|
||||
&& ir.projection_version == super::model::HISTORICAL_PROJECTION_VERSION;
|
||||
if !current && !historical_v4 {
|
||||
if !((ir.normalizer_version == NORMALIZER_VERSION
|
||||
&& ir.projection_version == PROJECTION_VERSION)
|
||||
|| (ir.normalizer_version == HISTORICAL_NORMALIZER_VERSION
|
||||
&& ir.projection_version == HISTORICAL_PROJECTION_VERSION))
|
||||
{
|
||||
return Err(ImportParseError::InvalidDocument);
|
||||
}
|
||||
let mut source_nodes = BTreeMap::new();
|
||||
@@ -98,15 +98,17 @@ pub(super) fn validate_coverage(ir: &NormalizedIr) -> Result<(), ImportParseErro
|
||||
.flat_map(|operation| &operation.findings),
|
||||
)
|
||||
.collect::<Vec<_>>();
|
||||
if findings.iter().any(|finding| {
|
||||
is_security_finding_code(&finding.code)
|
||||
&& !super::normalize_finding_validation::matches_source(finding, ir, &source_nodes)
|
||||
}) {
|
||||
return Err(ImportParseError::InvalidDocument);
|
||||
}
|
||||
for finding in &findings {
|
||||
if super::normalize_finding_validation::matches_source(finding, ir, &source_nodes)
|
||||
&& finding.construct_id == format!("{version}:{}", finding.location.pointer)
|
||||
let source_match =
|
||||
super::normalize_finding_validation::matches_source(finding, ir, &source_nodes);
|
||||
if matches!(
|
||||
finding.code.as_str(),
|
||||
"path_parameter_not_declared" | "unsupported_compound_default"
|
||||
) && !source_match
|
||||
{
|
||||
return Err(ImportParseError::InvalidDocument);
|
||||
}
|
||||
if source_match && finding.construct_id == format!("{version}:{}", finding.location.pointer)
|
||||
{
|
||||
insert_real_expected(
|
||||
&mut expected,
|
||||
@@ -155,20 +157,6 @@ pub(super) fn validate_coverage(ir: &NormalizedIr) -> Result<(), ImportParseErro
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn is_security_finding_code(code: &str) -> bool {
|
||||
matches!(
|
||||
code,
|
||||
"invalid_security_requirements"
|
||||
| "invalid_security_requirement"
|
||||
| "unresolved_security_scheme"
|
||||
| "unsupported_security_and_requirement"
|
||||
| "unsupported_security_scheme"
|
||||
| "unsupported_security_requirements"
|
||||
| "invalid_security_scopes"
|
||||
| "unexpected_security_scopes"
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
struct ExpectedCoverage {
|
||||
location: SourceLocation,
|
||||
|
||||
Reference in new issue
Block a user