Project: KICS (Provisioning / Security & Compliance)
File: 543e38f4-1eee-479e-8eb0-15257013aa0a.md

title: Global security field has an empty object (v3) hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 543e38f4-1eee-479e-8eb0-15257013aa0a Query name: Global security field has an empty object (v3) Platform: OpenAPI Severity: <span style="color:#bb2124">High</span> Category: Access Control URL: Global security definition must not have empty objects<br> ```json title="Positive test num. 1 - json file" hl_lines="43" { "openapi": "3.0.0", "info": { "title": "Simple API overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "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" } ] } ] } } } } } } } } } }, "security": [ {} ] } ``` ```json title="Positive test num. 2 - json file" hl_lines="60" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "schema": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" } }, "required": [ "code", "message" ] }, "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" } ] } ] } } } } } } } }, "security": [ { "exampleSecurity": [] }, {} ] } ``` ```yaml title="Positive test num. 3 - yaml file" hl_lines="38" swagger: "2.0" info: title: Simple API Overview version: 1.0.0 contact: name: contact url: https://www.google.com/ email: user@gmail.com paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response schema: type: object properties: code: type: integer format: int32 message: type: string required: code message 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 security: {} ``` <details><summary>Positive test num. 4 - json file</summary> ```json hl_lines="60" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "schema": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" } }, "required": [ "code", "message" ] }, "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" } ] } ] } } } } } } } }, "security": {} } ``` </details> <details><summary>Positive test num. 5 - json file</summary> ```json hl_lines="43" { "openapi":

"info": { "title": "Simple API overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "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" } ] } ] } } } } } } } } } }, "security": [ {}, { "exampleSecurity": [] } ], "components": { "exampleSecurity": { "type": "http", "scheme": "basic" } } } ``` </details> <details><summary>Positive test num. 6 - json file</summary> ```json hl_lines="43" { "openapi": "3.0.0", "info": { "title": "Simple API overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "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" } ] } ] } } } } } } } } } }, "security": [ { "exampleSecurity": [] }, {} ], "components": { "exampleSecurity": { "type": "http", "scheme": "basic" } } } ``` </details> <details><summary>Positive test num. 7 - json file</summary> ```json hl_lines="43" { "openapi": "3.0.0", "info": { "title": "Simple API overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "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" } ] } ] } } } } } } } } } }, "security": {} } ``` </details> <details><summary>Positive test num. 8 - yaml file</summary> ```yaml hl_lines="25" openapi: 3.0.0 info: title: Simple API overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions 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 security: {} ``` </details> <details><summary>Positive test num. 9 - yaml file</summary> ```yaml hl_lines="25" openapi: 3.0.0 info: title: Simple API overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions 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 security: {} exampleSecurity: [] components: exampleSecurity: type: http scheme: basic ``` </details> <details><summary>Positive test num. 10 - yaml file</summary> ```yaml hl_lines="25" openapi: 3.0.0 info: title: Simple API overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions 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 security: exampleSecurity: [] {} components: exampleSecurity: type: http scheme: basic ``` </details> <details><summary>Positive test num. 11 - yaml file</summary> ```yaml hl_lines="25" openapi:

info: title: Simple API overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions 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 security: {} ``` </details> <details><summary>Positive test num. 12 - yaml file</summary> ```yaml hl_lines="38" swagger: "2.0" info: title: Simple API Overview version: 1.0.0 contact: name: contact url: https://www.google.com/ email: user@gmail.com paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response schema: type: object properties: code: type: integer format: int32 message: type: string required: code message 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 security: exampleSecurity: [] {} ``` </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", "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" } ] } ] } } } } } } } } } }, "security":[ { "exampleSecurity": [] } ], "components": { "exampleSecurity": { "type": "http", "scheme": "basic" } } } ``` ```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 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 security: exampleSecurity: [] components: exampleSecurity: type: http scheme: basic ``` ```yaml title="Negative test num. 3 - yaml file" swagger: "2.0" info: title: Simple API Overview version: 1.0.0 contact: name: contact url: https://www.google.com/ email: user@gmail.com paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response schema: type: object properties: code: type: integer format: int32 message: type: string required: code message 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 security: exampleSecurity: [] ``` <details><summary>Negative test num. 4 - json file</summary> ```json { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "schema": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" } }, "required": [ "code", "message" ] }, "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" } ] } ] } } } } } } } }, "security": [ { "exampleSecurity": [] } ] } ``` </details>