Skip to content

Commit c7cc350

Browse files
authored
Merge pull request #92 from apiaddicts/develop
Develop
2 parents 6290b53 + d334192 commit c7cc350

8 files changed

Lines changed: 357 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.3.3] - 2026-03-20
9+
10+
### Fixed
11+
- OAR113 - CustomField Documentation
12+
- OAR114 - HttpResponseHeaders Documentation
13+
- OAR115 - VerifyRequiredFields Documentation
14+
815
## [1.3.2] - 2026-03-05
916

1017
### Fixed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.apiaddicts.apitools.dosonarapi</groupId>
55
<artifactId>sonaropenapi-rules-community</artifactId>
6-
<version>1.3.2</version>
6+
<version>1.3.3</version>
77
<packaging>sonar-plugin</packaging>
88

99
<name>SonarQube OpenAPI Community Rules</name>
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
<p>El campo o extensión debe estar en la ubicación asignada</p>
2+
<h2>Solución compatible (OpenAPI 2)</h2>
3+
<pre>
4+
swagger: "2.0"
5+
info:
6+
version: "1.0.0"
7+
title: "Sample API"
8+
x-custom-example: "example value"
9+
paths:
10+
/example:
11+
get:
12+
description: "Get example"
13+
responses:
14+
"200":
15+
description: "Successful response"
16+
schema:
17+
$ref: "#/definitions/ExampleObject"
18+
definitions:
19+
ExampleObject:
20+
type: object
21+
properties:
22+
id:
23+
type: string
24+
name:
25+
type: string
26+
x-extension-field: "example"
27+
</pre>
28+
<h2>Ejemplo de código no compatible (OpenAPI 2)</h2>
29+
<pre>
30+
swagger: "2.0"
31+
info:
32+
version: "1.0.0"
33+
title: "Sample API"
34+
paths:
35+
/example:
36+
get:
37+
description: "Get example"
38+
responses:
39+
"200":
40+
description: "Successful response"
41+
content:
42+
application/json:
43+
schema:
44+
$ref: "#/components/schemas/ExampleObject"
45+
definitions: # Noncompliant {{OAR113: Field or extension x-custom-example must be at the assigned location}}
46+
schemas:
47+
ExampleObject:
48+
type: object
49+
properties:
50+
id:
51+
type: string
52+
name:
53+
type: string
54+
x-extension-field: "example"
55+
</pre>
56+
<h2>Ejemplo de ubicación de código no compatible (OpenAPI 2)</h2>
57+
<pre>
58+
swagger: "2.0"
59+
info:
60+
version: "1.0.0"
61+
title: "Sample API"
62+
paths:
63+
/example:
64+
get:
65+
description: "Get example"
66+
responses:
67+
"200":
68+
description: "Successful response"
69+
content:
70+
application/json:
71+
schema:
72+
$ref: "#/components/schemas/ExampleObject"
73+
</pre>
74+
<h2>Solución compatible (OpenAPI 3)</h2>
75+
<pre>
76+
openapi: "3.0.0"
77+
info:
78+
version: "1.0.0"
79+
title: "Sample API"
80+
x-extension-example: "example value"
81+
paths:
82+
/example:
83+
get:
84+
description: "Get example"
85+
responses:
86+
"200":
87+
description: "Successful response"
88+
content:
89+
application/json:
90+
schema:
91+
$ref: "#/components/schemas/ExampleObject"
92+
components:
93+
schemas:
94+
ExampleObject:
95+
type: object
96+
properties:
97+
id:
98+
type: string
99+
name:
100+
type: string
101+
x-extension-field: "example"
102+
</pre>
103+
<h2>Ejemplo de código no compatible (OpenAPI 3)</h2>
104+
<pre>
105+
openapi: "3.0.0"
106+
info:
107+
version: "1.0.0"
108+
title: "Sample API"
109+
paths:
110+
/example:
111+
get:
112+
description: "Get example"
113+
responses:
114+
"200":
115+
description: "Successful response"
116+
content:
117+
application/json:
118+
schema:
119+
$ref: "#/components/schemas/ExampleObject"
120+
components:
121+
schemas:
122+
ExampleObject:
123+
type: object
124+
properties:
125+
id:
126+
type: string
127+
name:
128+
type: string
129+
x-extension-field: "example"
130+
</pre>
131+
<h2>Ejemplo de ubicación de código no compatible (OpenAPI 3)</h2>
132+
<pre>
133+
openapi: "3.0.0" # Noncompliant {{OAR113: The location components is not present.}}
134+
info:
135+
version: "1.0.0"
136+
title: "Sample API"
137+
paths:
138+
/example:
139+
get:
140+
description: "Get example"
141+
responses:
142+
"200":
143+
description: "Successful response"
144+
145+
</pre>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"title": "OAR113 - CustomField - El campo o extensión debe estar en la ubicación asignada",
3+
"type": "BUG",
4+
"status": "ready",
5+
"remediation": {
6+
"func": "Constant\/Issue",
7+
"constantCost": "30min"
8+
},
9+
"tags": [
10+
"format"
11+
],
12+
"defaultSeverity": "MINOR"
13+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<p>Los datos en el campo requerido deben existir en los parámetros del esquema</p>
2+
<h2>Ejemplo de código no compatible (OpenAPI 2)</h2>
3+
<pre>
4+
swagger: "2.0"
5+
info:
6+
title: API de ejemplo
7+
version: "1.0.0"
8+
paths: {}
9+
definitions:
10+
ErrorResponse:
11+
type: object
12+
properties:
13+
code:
14+
type: integer
15+
message:
16+
type: string
17+
required:
18+
- code
19+
- message
20+
- otherfield # Noncompliant {{OAR115: This value does not exist, it must be defined in the schema properties}}
21+
22+
</pre>
23+
<h2>Solución compatible (OpenAPI 2)</h2>
24+
<pre>
25+
swagger: "2.0"
26+
info:
27+
title: API de ejemplo
28+
version: "1.0.0"
29+
paths: {}
30+
definitions:
31+
ErrorResponse:
32+
type: object
33+
properties:
34+
code:
35+
type: integer
36+
message:
37+
type: string
38+
required:
39+
- code
40+
- message
41+
</pre>
42+
<h2>Ejemplo de código no compatible (OpenAPI 3)</h2>
43+
<pre>
44+
openapi: 3.0.0
45+
info:
46+
title: API de ejemplo
47+
version: "1.0.0"
48+
paths: {}
49+
components:
50+
schemas:
51+
ErrorResponse:
52+
type: object
53+
properties:
54+
code:
55+
type: integer
56+
message:
57+
type: string
58+
required:
59+
- code
60+
- message
61+
- otherfield # Noncompliant {{OAR115: This value does not exist, it must be defined in the schema properties}}
62+
63+
</pre>
64+
<h2>Solución compatible (OpenAPI 3)</h2>
65+
<pre>
66+
openapi: 3.0.3
67+
info:
68+
title: API de ejemplo
69+
version: "1.0.0"
70+
paths: {}
71+
components:
72+
schemas:
73+
ErrorResponse:
74+
type: object
75+
properties:
76+
code:
77+
type: integer
78+
message:
79+
type: string
80+
required:
81+
- code
82+
- message
83+
</pre>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"title": "OAR115 - VerifyRequiredFields - Los datos en el campo requerido deben existir en los parámetros del esquema",
3+
"type": "BUG",
4+
"status": "ready",
5+
"remediation": {
6+
"func": "Constant\/Issue",
7+
"constantCost": "30min"
8+
},
9+
"tags": [
10+
"format"
11+
],
12+
"defaultSeverity": "MINOR"
13+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<h2>Normativa - Definición de API</h2>
2+
<p>Sobrescribir ciertas cabeceras, permitir el uso de cualquier cabecera sin restricción o no especificar las cabeceras obligatorias puede causar vulnerabilidades en la API.</p>
3+
<h2>Ejemplo de código no compatible (OpenAPI 2)</h2>
4+
<pre>
5+
swagger: "2.0"
6+
info:
7+
version: 1.0.0
8+
title: Swagger Petstore
9+
paths:
10+
/pets:
11+
get:
12+
responses:
13+
200:
14+
description: Ok
15+
headers:
16+
Authorization: <span class="error-info" style="color: #FD8E18;"># Noncompliant {{OAR033: Header not allowed}}</span>
17+
description: Forbidden header
18+
schema:
19+
type: string
20+
</pre>
21+
<h2>Solución compatible (OpenAPI 2)</h2>
22+
<pre>
23+
swagger: "2.0"
24+
info:
25+
version: 1.0.0
26+
title: Swagger Petstore
27+
paths:
28+
/pets:
29+
get:
30+
responses:
31+
200:
32+
description: Ok
33+
headers:
34+
x-api-key:
35+
description: Mandatory header
36+
schema:
37+
type: string
38+
traceId:
39+
description: Optional but allowed
40+
schema:
41+
type: string
42+
</pre>
43+
<h2>Ejemplo de código no compatible (OpenAPI 3)</h2>
44+
<pre>
45+
openapi: "3.0.0"
46+
info:
47+
version: 1.0.0
48+
title: Swagger Petstore
49+
paths:
50+
/pets:
51+
get:
52+
responses:
53+
200:
54+
description: Ok
55+
headers:
56+
Authorization: <span class="error-info" style="color: #FD8E18;"># Noncompliant {{OAR033: Header not allowed}}</span>
57+
description: Forbidden header
58+
schema:
59+
type: string
60+
</pre>
61+
<h2>Solución compatible (OpenAPI 3)</h2>
62+
<pre>
63+
openapi: "3.0.0"
64+
info:
65+
version: 1.0.0
66+
title: Swagger Petstore
67+
paths:
68+
/pets:
69+
get:
70+
responses:
71+
200:
72+
description: Ok
73+
headers:
74+
x-api-key:
75+
description: Mandatory header
76+
schema:
77+
type: string
78+
traceId:
79+
description: Optional but allowed
80+
schema:
81+
type: string
82+
</pre>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"title": "OAR114 - HttpResponseHeaders - Existen cabeceras de petición obligatorias y otras que no están permitidas",
3+
"type": "VULNERABILITY",
4+
"status": "ready",
5+
"remediation": {
6+
"func": "Constant\/Issue",
7+
"constantCost": "15min"
8+
},
9+
"tags": [
10+
"safety"
11+
],
12+
"defaultSeverity": "CRITICAL"
13+
}

0 commit comments

Comments
 (0)