Skip to content

Commit 15f1045

Browse files
authored
Add webhooks Open API Specification (#748)
* feat: add owasp validation rules * chore: add validator package.json task and update GHA * chore: ignore API lint rule - no property description * feat: refine OWASP lint rules * feat: add xero webhooks open api specification * chore: update linting and workflows for xero-webhooks.yaml
1 parent c4cc9d1 commit 15f1045

File tree

9 files changed

+2169
-113
lines changed

9 files changed

+2169
-113
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
- name: yaml-lint
99
uses: ibiqlik/action-yamllint@v3
1010
with:
11-
file_or_dir: xero_accounting.yaml xero_assets.yaml xero_bankfeeds.yaml xero_files.yaml xero-app-store.yaml xero-identity.yaml xero-payroll-au.yaml xero-payroll-nz.yaml xero-payroll-uk.yaml xero-projects.yaml
11+
file_or_dir: xero_accounting.yaml xero_assets.yaml xero_bankfeeds.yaml xero_files.yaml xero-app-store.yaml xero-identity.yaml xero-payroll-au.yaml xero-payroll-nz.yaml xero-payroll-uk.yaml xero-projects.yaml xero-webhooks.yaml
1212
config_data: |
1313
extends: default
1414
rules:

.github/workflows/spectral-lint.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ jobs:
44
lint:
55
runs-on: ubuntu-latest
66
steps:
7-
- uses: actions/checkout@v3
8-
- uses: actions/setup-node@v3
9-
- name: spectral-lint
10-
run: ./validator/scripts/validate-all.sh
7+
- uses: actions/checkout@v3
8+
- uses: actions/setup-node@v3
9+
- name: Install yarn
10+
run: npm install -g yarn
11+
- name: yarn
12+
working-directory: ./validator
13+
run: yarn install --immutable
14+
- name: spectral-lint
15+
working-directory: ./validator
16+
run: yarn lint

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.DS_Store
22

3+
node_modules
4+
35
# JetBrains generated files
46
.idea

validator/package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "xero-openapi-validator",
3+
"version": "1.0.0",
4+
"description": "Validation for Xero OpenAPI specifications using Spectral",
5+
"type": "module",
6+
"scripts": {
7+
"lint": "spectral lint '../xero*.yaml'"
8+
},
9+
"dependencies": {
10+
"@stoplight/spectral-cli": "^6.0.0",
11+
"@stoplight/spectral-owasp-ruleset": "2.0.1"
12+
}
13+
}

validator/scripts/validate-all.sh

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

validator/spectral.yaml

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,2 @@
1-
extends: ["spectral:oas", "./xero-spectral.yaml"]
2-
3-
rules:
4-
# Override default rules to be more lenient for existing Xero API specs
5-
6-
# Re-enabled: operation-description (produces warnings only - acceptable for documentation improvement)
7-
# operation-description: off
8-
9-
# Disabled: info-description (xero_accounting.yaml missing description)
10-
info-description: off
11-
12-
# Disabled: operation-tag-defined (many APIs use undeclared tags)
13-
operation-tag-defined: off
14-
15-
# Disabled: no-$ref-siblings (xero_accounting.yaml uses this pattern with type field)
16-
no-$ref-siblings: off
17-
18-
# Disabled: example validation rules (legacy string examples would cause many errors)
19-
oas3-valid-media-example: off
20-
oas3-valid-schema-example: off
21-
22-
# Re-enabled: oas3-unused-component (produces warnings only - helps identify unused schemas)
23-
# oas3-unused-component: off
24-
25-
# Re-enabled: oas3-server-trailing-slash (produces warnings only - helps clean up URLs)
26-
# oas3-server-trailing-slash: off
27-
28-
# Disabled: path-params (FileId/FolderId path conflicts in xero_files.yaml)
29-
path-params: off
30-
31-
# Re-enabled: oas3-operation-security-defined (produces warnings only - helps identify security gaps)
32-
# oas3-operation-security-defined: off
1+
extends:
2+
- "./xero-spectral.yaml"

validator/xero-spectral.yaml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
extends:
2+
- "spectral:oas" # Base OpenAPI validation
3+
- "@stoplight/spectral-owasp-ruleset" # OWASP API security ruleset
4+
15
rules:
26
# Custom rules specific to Xero APIs
37
xero-info-required-fields:
@@ -85,7 +89,7 @@ rules:
8589
xero-schema-properties-description:
8690
description: "Schema properties should have descriptions for better documentation"
8791
given: "$.components.schemas[*].properties[*]"
88-
severity: info
92+
severity: off
8993
then:
9094
field: "description"
9195
function: truthy
@@ -118,3 +122,40 @@ rules:
118122
then:
119123
field: "description"
120124
function: truthy
125+
operation-description: off # Disable operation description rule for now
126+
operation-tags: off # Disable operation tags rule for now
127+
oas3-schema: warn # Re-enable schema validation with reduced severity
128+
info-contact:
129+
severity: warn # Re-enabled with reduced severity
130+
given: $.info.contact # Scope: info.contact field
131+
then:
132+
function: truthy # Ensure the field is truthy
133+
info-license:
134+
severity: warn # Re-enabled with reduced severity
135+
given: $.info.license # Scope: info.license field
136+
then:
137+
function: truthy # Ensure the field is truthy
138+
139+
140+
# OWASP Rules
141+
owasp:api2:2023-no-http-basic: off # Disable HTTP Basic authentication rule
142+
owasp:api4:2023-string-limit: off # Disable string length limit checks
143+
owasp:api4:2023-array-limit: off # Disable array size limit checks
144+
owasp:api4:2023-integer-limit-legacy: off # Disable integer limit checks
145+
owasp:api4:2023-rate-limit: off # Disable rate limiting headers check
146+
owasp:api2:2023-jwt-best-practices: off # Disable JWT best practices check
147+
owasp:api8:2023-define-error-responses-401: off # Disable missing 401 response rule
148+
owasp:api8:2023-define-error-responses-500: off # Disable missing 500 response rule
149+
owasp:api4:2023-rate-limit-responses-429: off # Disable missing 429 rate limit response rule
150+
oas3-valid-media-example: off # Disable media example validation
151+
owasp:api4:2023-integer-format: off # Disable integer format validation
152+
no-$ref-siblings: off # Disable $ref sibling validation
153+
oas3-valid-schema-example: off # Disable schema example validation
154+
owasp:api9:2023-inventory-access: off # Disable server audience declaration rule
155+
owasp:api9:2023-inventory-environment: off # Disable server environment declaration rule
156+
owasp:api2:2023-short-lived-access-tokens: off # Disable short-lived access tokens rule
157+
owasp:api8:2023-define-error-validation: off # Disable missing error response validation rule
158+
operation-tag-defined: off # Disable operation tags defined in global tags rule
159+
owasp:api4:2023-string-restricted: off # Disable string restricted rule to address warnings
160+
path-params: off # Disable path parameter validation to address mapping key issues
161+
owasp:api8:2023-define-cors-origin: off # Disable CORS origin header requirement

0 commit comments

Comments
 (0)