Project: KICS (Provisioning / Security & Compliance)
File: 20a482d5-c5d9-4a7a-b7a4-60d0805047b4.md

title: Security Operation Field Undefined hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 20a482d5-c5d9-4a7a-b7a4-60d0805047b4 Query name: Security Operation Field Undefined Platform: OpenAPI Severity: <span style="color:#5bc0de">Info</span> Category: Structure and Semantics URL: Security operation field should be defined in '#/components/securitySchemes'<br> ```json title="Positive test num. 1 - json file" hl_lines="14" { "openapi": "3.0.0", "info": { "title": "Simple API overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "security": [ { "petstore_auth": [ "write:pets", "read:pets" ] } ], "responses": { "200": { "description": "200 response", "content": { "application/json": { "examples": { "foo": { "value": { "versions": [ { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0", "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" } ] } ] } } } } } } } } } } } ``` ```json title="Positive test num. 2 - json file" hl_lines="14" { "openapi": "3.0.0", "info": { "title": "Simple API overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "security": [ { "petstore_auth": [ "write:pets", "read:pets" ] } ], "responses": { "200": { "description": "200 response", "content": { "application/json": { "examples": { "foo": { "value": { "versions": [ { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0", "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" } ] } ] } } } } } } } } } }, "components": { "securitySchemes": { "regularSecurity": { "type": "http", "scheme": "basic" } } } } ``` ```yaml title="Positive test num. 3 - yaml file" hl_lines="11" openapi: 3.0.0 info: title: Simple API overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions security: petstore_auth: write:pets read:pets responses: "200": description: 200 response content: application/json: examples: foo: value: versions: status: CURRENT updated: "2011-01-21T11:33:21Z" id: v2.0 links: href: http://127.0.0.1:8774/v2/ rel: self ``` <details><summary>Positive test num. 4 - yaml file</summary> ```yaml hl_lines="11" openapi: 3.0.0 info: title: Simple API overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions security: petstore_auth: write:pets read:pets responses: "200": description: 200 response content: application/json: examples: foo: value: versions: status: CURRENT updated: "2011-01-21T11:33:21Z" id: v2.0 links: href: http://127.0.0.1:8774/v2/ rel: self components: securitySchemes: regularSecurity: type: http scheme: basic ``` </details> ```json title="Negative test num. 1 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "security": [ { "petstore_auth": [ "write:pets", "read:pets" ] } ], "responses": { "200": { "description": "200 response", "content": { "application/json": { "examples": { "foo": { "value": { "versions": [ { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0", "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" } ] } ] } } } } } } } } } }, "components": { "securitySchemes": { "regularSecurity": { "type": "http", "scheme": "basic" }, "petstore_auth": { "type": "oauth2", "flows": { "implicit": { "scopes": { "write:pets": "modify pets in your account", "read:pets": "read your pets" }, "authorizationUrl": "http://example.org/api/oauth/dialog" } } } } } } ``` ```yaml title="Negative test num. 2 - yaml file" openapi: 3.0.0 info: title: Simple API overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions security: petstore_auth: write:pets read:pets responses: "200": description: 200 response content: application/json: examples: foo: value: versions: status: CURRENT updated: "2011-01-21T11:33:21Z" id: v2.0 links: href: http://127.0.0.1:8774/v2/ rel: self components: securitySchemes: regularSecurity: type: http scheme: basic petstore_auth: type: oauth2 flows: implicit: authorizationUrl: http://example.org/api/oauth/dialog scopes: write:pets: modify pets in your account read:pets: read your pets ```