Link Object Incorrect Ref
- Query id: b9db8a10-020c-49ca-88c6-780e5fdb4328
- Query name: Link Object Incorrect Ref
- Platform: OpenAPI
- Severity: Info
- Category: Structure and Semantics
- URL: Github
Description¶
Link object reference must always point to '#/components/links'
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": {
"responses": {
"200": {
"description": "the user being returned",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"format": "uuid"
}
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Pet": {
"$ref": "../models/pet.yaml"
},
"User": {
"$ref": "https://api.example.com/v2/openapi.yaml#/components/schemas/User"
}
},
"responses": {
"NotFound": {
"description": "The specified resource was not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
},
"links": {
"l": {
"$ref": "#components/linfks/address"
}
}
}
},
"links": {
"address": {
"operationId": "getUssssserAddress",
"parameters": {
"userId": "$request.path.id"
}
}
}
}
}
Positive test num. 2 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"format": "uuid"
}
}
}
}
},
"links": {
"l": {
"$ref": "#components/linfks/address"
}
},
"description": "the user being returned"
}
}
}
}
},
"components": {
"responses": {
"GenericError": {
"$ref": "../template-api.yaml#/components/responses/GenericError"
}
},
"links": {
"address": {
"operationId": "getUssssserAddress",
"parameters": {
"userId": "$request.path.id"
}
}
},
"schemas": {
"Pet": {
"$ref": "../models/pet.yaml"
},
"User": {
"$ref": "https://api.example.com/v2/openapi.yaml#/components/schemas/User"
}
}
}
}
Positive test num. 3 - yaml file
openapi: 3.0.0
info:
title: Simple API overview
version: 1.0.0
paths:
"/":
get:
responses:
"200":
description: the user being returned
content:
application/json:
schema:
type: object
properties:
uuid:
type: string
format: uuid
components:
schemas:
Pet:
$ref: "../models/pet.yaml"
User:
$ref: "https://api.example.com/v2/openapi.yaml#/components/schemas/User"
responses:
NotFound:
description: The specified resource was not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
links:
l:
$ref: "#components/linfks/address"
links:
address:
operationId: getUssssserAddress
parameters:
userId: $request.path.id
Positive test num. 4 - yaml file
openapi: 3.0.0
info:
title: Simple API overview
version: 1.0.0
paths:
"/":
get:
responses:
"200":
description: the user being returned
content:
application/json:
schema:
type: object
properties:
uuid:
type: string
format: uuid
links:
l:
$ref: "#components/linfks/address"
components:
schemas:
Pet:
$ref: "../models/pet.yaml"
User:
$ref: "https://api.example.com/v2/openapi.yaml#/components/schemas/User"
responses:
GenericError:
$ref: "../template-api.yaml#/components/responses/GenericError"
links:
address:
operationId: getUssssserAddress
parameters:
userId: $request.path.id
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": {
"responses": {
"200": {
"description": "the user being returned",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"format": "uuid"
}
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Pet": {
"$ref": "../models/pet.yaml"
},
"User": {
"$ref": "https://api.example.com/v2/openapi.yaml#/components/schemas/User"
}
},
"responses": {
"NotFound": {
"description": "The specified resource was not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
},
"links": {
"l": {
"$ref": "#/components/links/address"
}
}
}
},
"links": {
"address": {
"operationId": "getUssssserAddress",
"parameters": {
"userId": "$request.path.id"
}
}
}
}
}
Negative test num. 2 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"format": "uuid"
}
}
}
}
},
"links": {
"l": {
"$ref": "#/components/links/address"
}
},
"description": "the user being returned"
}
}
}
}
},
"components": {
"responses": {
"GenericError": {
"$ref": "../template-api.yaml#/components/responses/GenericError"
}
},
"links": {
"address": {
"operationId": "getUssssserAddress",
"parameters": {
"userId": "$request.path.id"
}
}
},
"schemas": {
"Pet": {
"$ref": "../models/pet.yaml"
},
"User": {
"$ref": "https://api.example.com/v2/openapi.yaml#/components/schemas/User"
}
}
}
}
Negative test num. 3 - yaml file
openapi: 3.0.0
info:
title: Simple API overview
version: 1.0.0
paths:
"/":
get:
responses:
"200":
description: the user being returned
content:
application/json:
schema:
type: object
properties:
uuid:
type: string
format: uuid
components:
schemas:
Pet:
$ref: "../models/pet.yaml"
User:
$ref: "https://api.example.com/v2/openapi.yaml#/components/schemas/User"
responses:
NotFound:
description: The specified resource was not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
links:
l:
$ref: "#/components/links/address"
links:
address:
operationId: getUssssserAddress
parameters:
userId: $request.path.id
Negative test num. 4 - yaml file
openapi: 3.0.0
info:
title: Simple API overview
version: 1.0.0
paths:
"/":
get:
responses:
"200":
description: the user being returned
content:
application/json:
schema:
type: object
properties:
uuid:
type: string
format: uuid
links:
l:
$ref: "#/components/links/address"
components:
schemas:
Pet:
$ref: "../models/pet.yaml"
User:
$ref: "https://api.example.com/v2/openapi.yaml#/components/schemas/User"
responses:
GenericError:
$ref: "../template-api.yaml#/components/responses/GenericError"
links:
address:
operationId: getUssssserAddress
parameters:
userId: $request.path.id