Components Link Definition Is Unused
- Query id: c19779a9-5774-4d2f-a3a1-a99831730375
- Query name: Components Link Definition Is Unused
- Platform: OpenAPI
- Severity: Info
- Category: Best Practices
- CWE: 710
- URL: Github
Description¶
Components links definitions should be referenced or removed from Open API definition
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Positive 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": "success",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/MyObject"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"MyObject": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
}
},
"links": {
"APIRepository": {
"operationId": "listVersionsv2"
}
}
}
}
Positive 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: success
content:
application/json:
schema:
type: array
items:
"$ref": "#/components/schemas/MyObject"
components:
schemas:
MyObject:
type: object
properties:
id:
type: string
name:
type: string
links:
APIRepository:
operationId: listVersionsv2
Code samples without security vulnerabilities¶
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": "success",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/MyObject"
}
}
}
},
"links": {
"$ref": "#/components/links/APIRepository"
}
}
}
}
}
},
"components": {
"schemas": {
"MyObject": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
}
},
"links": {
"APIRepository": {
"operationId": "listVersionsv2"
}
}
}
}
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: success
content:
application/json:
schema:
type: array
items:
"$ref": "#/components/schemas/MyObject"
links:
"$ref": "#/components/links/APIRepository"
components:
schemas:
MyObject:
type: object
properties:
id:
type: string
name:
type: string
links:
APIRepository:
operationId: listVersionsv2