Skip to content

Commit 5ae644f

Browse files
[PETOSS-829] Update megalinter and spectral confg
1 parent 8a063d3 commit 5ae644f

File tree

3 files changed

+145
-147
lines changed

3 files changed

+145
-147
lines changed

.github/workflows/pr-validation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: actions/checkout@v4
1717

1818
- name: MegaLinter
19-
uses: oxsecurity/megalinter@v9
19+
uses: oxsecurity/megalinter/flavors/documentation@v9
2020
env:
2121
ENABLE_LINTERS: YAML_YAMLLINT,ACTION_ACTIONLINT,API_SPECTRAL
2222
YAML_YAMLLINT_CONFIG_FILE: .yamllint.yml

.spectral/spectral.yaml

Lines changed: 144 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,145 @@
11
extends:
2-
- "./xero-spectral.yaml"
2+
- "spectral:oas"
3+
- "@stoplight/spectral-owasp-ruleset"
4+
5+
rules:
6+
xero-info-required-fields:
7+
description: "Ensure required info fields are present"
8+
given: "$.info"
9+
severity: error
10+
then:
11+
- field: "title"
12+
function: truthy
13+
- field: "version"
14+
function: truthy
15+
- field: "termsOfService"
16+
function: truthy
17+
- field: "contact"
18+
function: truthy
19+
xero-contact-required-fields:
20+
description: "Ensure contact has required fields"
21+
given: "$.info.contact"
22+
severity: error
23+
then:
24+
- field: "name"
25+
function: truthy
26+
- field: "email"
27+
function: truthy
28+
- field: "url"
29+
function: truthy
30+
xero-servers-required:
31+
description: "Ensure servers are defined"
32+
given: "$"
33+
severity: error
34+
then:
35+
field: "servers"
36+
function: truthy
37+
xero-server-description:
38+
description: "Each server should have a description"
39+
given: "$.servers[*]"
40+
severity: warn
41+
then:
42+
field: "description"
43+
function: truthy
44+
xero-operation-summary:
45+
description: "Operations should have summaries"
46+
given: "$.paths[*][get,post,put,patch,delete,head,options,trace]"
47+
severity: warn
48+
then:
49+
field: "summary"
50+
function: truthy
51+
xero-operation-id:
52+
description: "Operations must have operationId"
53+
given: "$.paths[*][get,post,put,patch,delete,head,options,trace]"
54+
severity: error
55+
then:
56+
field: "operationId"
57+
function: truthy
58+
xero-operation-tags:
59+
description: "Operations should have tags"
60+
given: "$.paths[*][get,post,put,patch,delete,head,options,trace]"
61+
severity: warn
62+
then:
63+
field: "tags"
64+
function: truthy
65+
xero-operation-security:
66+
description: "Operations should have security defined"
67+
given: "$.paths[*][get,post,put,patch,delete,head,options,trace]"
68+
severity: info
69+
then:
70+
field: "security"
71+
function: truthy
72+
xero-response-200-description:
73+
description: "200 responses should have descriptions"
74+
given: "$.paths[*][get,post,put,patch,delete,head,options,trace].responses.200"
75+
severity: warn
76+
then:
77+
field: "description"
78+
function: truthy
79+
xero-schema-properties-description:
80+
description: "Schema properties should have descriptions for better documentation"
81+
given: "$.components.schemas[*].properties[*]"
82+
severity: off
83+
then:
84+
field: "description"
85+
function: truthy
86+
xero-openapi-version:
87+
description: "Should use OpenAPI 3.0.0 or higher"
88+
given: "$.openapi"
89+
severity: error
90+
then:
91+
function: pattern
92+
functionOptions:
93+
match: "^3\\.[0-9]+\\.[0-9]+$"
94+
xero-path-parameters:
95+
description: "Path parameters should be properly defined"
96+
given: "$.paths[*][get,post,put,patch,delete,head,options,trace].parameters[?(@.in === 'path')]"
97+
severity: error
98+
then:
99+
- field: "name"
100+
function: truthy
101+
- field: "required"
102+
function: truthy
103+
- field: "schema"
104+
function: truthy
105+
xero-consistent-error-responses:
106+
description: "Should have consistent error response structure"
107+
given: "$.paths[*][get,post,put,patch,delete,head,options,trace].responses[?(@property >= '400')]"
108+
severity: info
109+
then:
110+
field: "description"
111+
function: truthy
112+
operation-description: off
113+
operation-tags: off
114+
oas3-schema: warn
115+
info-contact:
116+
severity: warn
117+
given: $.info.contact
118+
then:
119+
function: truthy
120+
info-license:
121+
severity: warn
122+
given: $.info.license
123+
then:
124+
function: truthy
125+
owasp:api2:2023-no-http-basic: off
126+
owasp:api4:2023-string-limit: off
127+
owasp:api4:2023-array-limit: off
128+
owasp:api4:2023-integer-limit-legacy: off
129+
owasp:api4:2023-rate-limit: off
130+
owasp:api2:2023-jwt-best-practices: off
131+
owasp:api8:2023-define-error-responses-401: off
132+
owasp:api8:2023-define-error-responses-500: off
133+
owasp:api4:2023-rate-limit-responses-429: off
134+
oas3-valid-media-example: off
135+
owasp:api4:2023-integer-format: off
136+
no-$ref-siblings: off
137+
oas3-valid-schema-example: off
138+
owasp:api9:2023-inventory-access: off
139+
owasp:api9:2023-inventory-environment: off
140+
owasp:api2:2023-short-lived-access-tokens: off
141+
owasp:api8:2023-define-error-validation: off
142+
operation-tag-defined: off
143+
owasp:api4:2023-string-restricted: off
144+
path-params: off
145+
owasp:api8:2023-define-cors-origin: off

.spectral/xero-spectral.yaml

Lines changed: 0 additions & 145 deletions
This file was deleted.

0 commit comments

Comments
 (0)