-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(openapi): Take into account that security is at the root level of…
… your OpenAPI specification. (#5603) * Fix CKV_OPENAPI_5 to take into account that security is at the root level of your OpenAPI specification. * fix indentation * add a test for the CKV_OPENAPI_5 * fix failing check * fix logic * fix test cases and logic --------- Co-authored-by: gruebel <[email protected]>
- Loading branch information
Showing
6 changed files
with
106 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/openapi/checks/resource/generic/example_SecurityOperations/pass2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"swagger": "2.0", | ||
"openapi": "3.0.0", | ||
"info": { | ||
"title": "example", | ||
"version": "1.0.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
tests/openapi/checks/resource/generic/example_SecurityOperations/pass3.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"openapi": "3.0.3", | ||
"info": { | ||
"title": "example", | ||
"version": "1.0.0", | ||
"contact": { | ||
"name": "contact", | ||
"url": "https://www.google.com/", | ||
"email": "[email protected]" | ||
} | ||
}, | ||
"security": [ | ||
{ | ||
"ApiKeyAuth": [] | ||
} | ||
], | ||
"paths": { | ||
"/": { | ||
"get": { | ||
"operationId": "id", | ||
"summary": "example", | ||
"responses": { | ||
"200": { | ||
"description": "200 response", | ||
"schema": { | ||
"type": "object", | ||
"properties": { | ||
"code": { | ||
"type": "integer", | ||
"format": "int32" | ||
}, | ||
"message": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"code", | ||
"message" | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": { | ||
"securitySchemes": { | ||
"ApiKeyAuth": { | ||
"type": "apiKey", | ||
"in": "header", | ||
"name": "X-API-KEY" | ||
} | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
tests/openapi/checks/resource/generic/example_SecurityOperations/pass3.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
openapi: "3.0.3" | ||
info: | ||
title: example | ||
version: 1.0.0 | ||
contact: | ||
name: contact | ||
url: https://www.google.com/ | ||
email: [email protected] | ||
security: | ||
- ApiKeyAuth: [] | ||
paths: | ||
"/": | ||
get: | ||
operationId: id | ||
summary: example | ||
responses: | ||
"200": | ||
description: 200 response | ||
schema: | ||
type: object | ||
properties: | ||
code: | ||
type: integer | ||
format: int32 | ||
message: | ||
type: string | ||
required: | ||
- code | ||
- message | ||
components: | ||
securitySchemes: | ||
ApiKeyAuth: | ||
type: apiKey | ||
in: header | ||
name: X-API-KEY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters