openclarity / apiclarity

An API security tool to capture and analyze API traffic, test API endpoints, reconstruct Open API specification, and identify API security risks. 
https://apiclarity.io
Apache License 2.0
498 stars 64 forks source link

spec validation failed #374

Open nbelchug opened 6 months ago

nbelchug commented 6 months ago

What happened:

Impossible to reconstruct API

What you expected to happen:

reconstruct API

How to reproduce it (as minimally and precisely as possible):

A sandbox will be provided to reproduce the issue.

Are there any error messages in API Clarity logs?

(e.g. kubectl logs -n apiclarity --selector=app=apiclarity)

time="2023-12-21T11:37:44Z" level=error msg="provided spec is not valid OpenAPI 3.0: {\"components\":{\"schemas\":{\"amfInstanceId_deregCallbackUri_guami_ratType\":{\"properties\":{\"amfInstanceId\":{\"format\":\"uuid\",\"type\":\"string\"},\"deregCallbackUri\":{\"type\":\"string\"},\"guami\":{\"$ref\":\"#/components/schemas/guami\"},\"ratType\":{\"type\":\"string\"}},\"type\":\"object\"},\"dnnInfo\":{\"properties\":{\"defaultDnnIndicator\":{\"type\":\"boolean\"},\"dnn\":{\"type\":\"string\"}},\"type\":\"object\"},\"guami\":{\"properties\":{\"amfId\":{\"type\":\"string\"},\"plmnId\":{\"$ref\":\"#/components/schemas/plmnId\"}},\"type\":\"object\"},\"plmnId\":{\"properties\":{\"mcc\":{\"type\":\"string\"},\"mnc\":{\"type\":\"string\"}},\"type\":\"object\"},\"subscribedSnssaiInfos\":{\"properties\":{\"{\\n\\t\\\\\\\"sst\\\\\\\":\\t1,\\n\\t\\\\\\\"sd\\\\\\\":\\t\\\\\\\"111111\\\\\\\"\\n}\":{\"$ref\":\"#/components/schemas/{\\n\\t\\\\\\\"sst\\\\\\\":\\t1,\\n\\t\\\\\\\"sd\\\\\\\":\\t\\\\\\\"111111\\\\\\\"\\n}\"}},\"type\":\"object\"},\"subscribedSnssaiInfos_0\":{\"properties\":{\"subscribedSnssaiInfos\":{\"$ref\":\"#/components/schemas/subscribedSnssaiInfos\"}},\"type\":\"object\"},\"{\\n\\t\\\\\\\"sst\\\\\\\":\\t1,\\n\\t\\\\\\\"sd\\\\\\\":\\t\\\\\\\"111111\\\\\\\"\\n}\":{\"properties\":{\"dnnInfos\":{\"items\":{\"$ref\":\"#/components/schemas/dnnInfo\"},\"type\":\"array\"}},\"type\":\"object\"}}},\"info\":{\"contact\":{\"email\":\"apiteam@swagger.io\"},\"description\":\"This is a generated Open API Spec\",\"license\":{\"name\":\"Apache 2.0\",\"url\":\"https://www.apache.org/licenses/LICENSE-2.0.html\"},\"termsOfService\":\"https://swagger.io/terms/\",\"title\":\"Swagger\",\"version\":\"1.0.0\"},\"openapi\":\"3.0.3\",\"paths\":{\"/nudm-sdm/v2/{param1}/smf-select-data\":{\"get\":{\"parameters\":[{\"in\":\"header\",\"name\":\"3gpp-sbi-sender-timestamp\",\"schema\":{\"type\":\"string\"}},{\"in\":\"header\",\"name\":\"3gpp-sbi-max-rsp-time\",\"schema\":{\"format\":\"int64\",\"type\":\"integer\"}}],\"responses\":{\"200\":{\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/components/schemas/subscribedSnssaiInfos_0\"}}},\"description\":\"response\"},\"default\":{\"description\":\"default\"}}},\"parameters\":[{\"in\":\"path\",\"name\":\"param1\",\"required\":true,\"schema\":{\"type\":\"string\"}}]},\"/nudm-uecm/v1/{param1}/registrations/amf-3gpp-access\":{\"parameters\":[{\"in\":\"path\",\"name\":\"param1\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"put\":{\"parameters\":[{\"in\":\"header\",\"name\":\"3gpp-sbi-sender-timestamp\",\"schema\":{\"type\":\"string\"}},{\"in\":\"header\",\"name\":\"3gpp-sbi-callback\",\"schema\":{\"type\":\"string\"}},{\"in\":\"header\",\"name\":\"3gpp-sbi-max-rsp-time\",\"schema\":{\"format\":\"int64\",\"type\":\"integer\"}}],\"requestBody\":{\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/components/schemas/amfInstanceId_deregCallbackUri_guami_ratType\"}}}},\"responses\":{\"201\":{\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/components/schemas/amfInstanceId_deregCallbackUri_guami_ratType\"}}},\"description\":\"response\"},\"default\":{\"description\":\"default\"}}}}},\"servers\":[{\"url\":\"http://open5gs-udm-sbi.open5gs:7777\"}]}. spec validation failed. invalid components: schema \"{\\n\\t\\\\\\\"sst\\\\\\\":\\t1,\\n\\t\\\\\\\"sd\\\\\\\":\\t\\\\\\\"111111\\\\\\\"\\n}\": identifier \"{\\n\\t\\\\\\\"sst\\\\\\\":\\t1,\\n\\t\\\\\\\"sd\\\\\\\":\\t\\\\\\\"111111\\\\\\\"\\n}\" is not supported by OpenAPIv3 standard (regexp: \"^[a-zA-Z0-9._-]+$\"). spec validation failed" func=github.com/openclarity/speculator/pkg/spec.LoadAndValidateRawJSONSpec file="/go/pkg/mod/github.com/openclarity/speculator@v0.3.2/pkg/spec/provided_spec.go:90"
time="2023-12-21T11:37:44Z" level=error msg="Failed to validate the spec. provided spec is not valid OpenAPI 3.0: spec validation failed. invalid components: schema \"{\\n\\t\\\\\\\"sst\\\\\\\":\\t1,\\n\\t\\\\\\\"sd\\\\\\\":\\t\\\\\\\"111111\\\\\\\"\\n}\": identifier \"{\\n\\t\\\\\\\"sst\\\\\\\":\\t1,\\n\\t\\\\\\\"sd\\\\\\\":\\t\\\\\\\"111111\\\\\\\"\\n}\" is not supported by OpenAPIv3 standard (regexp: \"^[a-zA-Z0-9._-]+$\"). spec validation failed\n\nspec: {\"components\":{\"schemas\":{\"amfInstanceId_deregCallbackUri_guami_ratType\":{\"properties\":{\"amfInstanceId\":{\"format\":\"uuid\",\"type\":\"string\"},\"deregCallbackUri\":{\"type\":\"string\"},\"guami\":{\"$ref\":\"#/components/schemas/guami\"},\"ratType\":{\"type\":\"string\"}},\"type\":\"object\"},\"dnnInfo\":{\"properties\":{\"defaultDnnIndicator\":{\"type\":\"boolean\"},\"dnn\":{\"type\":\"string\"}},\"type\":\"object\"},\"guami\":{\"properties\":{\"amfId\":{\"type\":\"string\"},\"plmnId\":{\"$ref\":\"#/components/schemas/plmnId\"}},\"type\":\"object\"},\"plmnId\":{\"properties\":{\"mcc\":{\"type\":\"string\"},\"mnc\":{\"type\":\"string\"}},\"type\":\"object\"},\"subscribedSnssaiInfos\":{\"properties\":{\"{\\n\\t\\\\\\\"sst\\\\\\\":\\t1,\\n\\t\\\\\\\"sd\\\\\\\":\\t\\\\\\\"111111\\\\\\\"\\n}\":{\"$ref\":\"#/components/schemas/{\\n\\t\\\\\\\"sst\\\\\\\":\\t1,\\n\\t\\\\\\\"sd\\\\\\\":\\t\\\\\\\"111111\\\\\\\"\\n}\"}},\"type\":\"object\"},\"subscribedSnssaiInfos_0\":{\"properties\":{\"subscribedSnssaiInfos\":{\"$ref\":\"#/components/schemas/subscribedSnssaiInfos\"}},\"type\":\"object\"},\"{\\n\\t\\\\\\\"sst\\\\\\\":\\t1,\\n\\t\\\\\\\"sd\\\\\\\":\\t\\\\\\\"111111\\\\\\\"\\n}\":{\"properties\":{\"dnnInfos\":{\"items\":{\"$ref\":\"#/components/schemas/dnnInfo\"},\"type\":\"array\"}},\"type\":\"object\"}}},\"info\":{\"contact\":{\"email\":\"apiteam@swagger.io\"},\"description\":\"This is a generated Open API Spec\",\"license\":{\"name\":\"Apache 2.0\",\"url\":\"https://www.apache.org/licenses/LICENSE-2.0.html\"},\"termsOfService\":\"https://swagger.io/terms/\",\"title\":\"Swagger\",\"version\":\"1.0.0\"},\"openapi\":\"3.0.3\",\"paths\":{\"/nudm-sdm/v2/{param1}/smf-select-data\":{\"get\":{\"parameters\":[{\"in\":\"header\",\"name\":\"3gpp-sbi-sender-timestamp\",\"schema\":{\"type\":\"string\"}},{\"in\":\"header\",\"name\":\"3gpp-sbi-max-rsp-time\",\"schema\":{\"format\":\"int64\",\"type\":\"integer\"}}],\"responses\":{\"200\":{\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/components/schemas/subscribedSnssaiInfos_0\"}}},\"description\":\"response\"},\"default\":{\"description\":\"default\"}}},\"parameters\":[{\"in\":\"path\",\"name\":\"param1\",\"required\":true,\"schema\":{\"type\":\"string\"}}]},\"/nudm-uecm/v1/{param1}/registrations/amf-3gpp-access\":{\"parameters\":[{\"in\":\"path\",\"name\":\"param1\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"put\":{\"parameters\":[{\"in\":\"header\",\"name\":\"3gpp-sbi-sender-timestamp\",\"schema\":{\"type\":\"string\"}},{\"in\":\"header\",\"name\":\"3gpp-sbi-callback\",\"schema\":{\"type\":\"string\"}},{\"in\":\"header\",\"name\":\"3gpp-sbi-max-rsp-time\",\"schema\":{\"format\":\"int64\",\"type\":\"integer\"}}],\"requestBody\":{\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/components/schemas/amfInstanceId_deregCallbackUri_guami_ratType\"}}}},\"responses\":{\"201\":{\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/components/schemas/amfInstanceId_deregCallbackUri_guami_ratType\"}}},\"description\":\"response\"},\"default\":{\"description\":\"default\"}}}}},\"servers\":[{\"url\":\"http://open5gs-udm-sbi.open5gs:7777\"}]}" func="github.com/openclarity/speculator/pkg/spec.(*Spec).GenerateOASJson" file="/go/pkg/mod/github.com/openclarity/speculator@v0.3.2/pkg/spec/spec.go:285"
time="2023-12-21T11:37:44Z" level=error msg="Failed to apply the approved review. failed to apply approved review for spec: open5gs-udm-sbi.open5gs:7777. failed to generate Open API Spec. failed to validate the spec. provided spec is not valid OpenAPI 3.0: spec validation failed. invalid components: schema \"{\\n\\t\\\\\\\"sst\\\\\\\":\\t1,\\n\\t\\\\\\\"sd\\\\\\\":\\t\\\\\\\"111111\\\\\\\"\\n}\": identifier \"{\\n\\t\\\\\\\"sst\\\\\\\":\\t1,\\n\\t\\\\\\\"sd\\\\\\\":\\t\\\\\\\"111111\\\\\\\"\\n}\" is not supported by OpenAPIv3 standard (regexp: \"^[a-zA-Z0-9._-]+$\"). spec validation failed" func="github.com/openclarity/apiclarity/backend/pkg/rest.(*Server).PostAPIInventoryReviewIDApprovedReview" file="/build/backend/pkg/rest/review_controller.go:66"
time="2023-12-21T11:37:45Z" level=error msg="BFLA error: unable to process trace: event 124913 cannot resolve to a spec path" func=github.com/openclarity/apiclarity/backend/pkg/modules/internal/bfla/bfladetector.NewBFLADetector.func1 file="/build/backend/pkg/modules/internal/bfla/bfladetector/learn_and_detect_bfla.go:127"

Anything else we need to know?:

Environment: