From 7c7478ccc3c6b3ba263f2224b7d3cdba71122904 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Sat, 13 Jan 2024 14:06:13 +0700 Subject: [PATCH 01/19] feat: add openapi linter --- catalyst-gateway/.spectral.yml | 12 ++++++++++++ catalyst-gateway/Earthfile | 6 ++++++ 2 files changed, 18 insertions(+) create mode 100644 catalyst-gateway/.spectral.yml diff --git a/catalyst-gateway/.spectral.yml b/catalyst-gateway/.spectral.yml new file mode 100644 index 00000000000..d8667163a51 --- /dev/null +++ b/catalyst-gateway/.spectral.yml @@ -0,0 +1,12 @@ +# References to the rules +# OpenAPI: https://docs.stoplight.io/docs/spectral/4dec24461f3af-open-api-rules#openapi-rules +# OWASP Top 10: https://apistylebook.stoplight.io/docs/owasp-top-10 +# Documentations: https://github.com/stoplightio/spectral-documentation/blob/main/src/ruleset.ts + +# cspell: words OWASP owasp + +# Use CDN hosted version for spectral-documentation and spectral-owasp +extends: +- 'spectral:oas' +- 'https://unpkg.com/@stoplight/spectral-documentation/dist/ruleset.mjs' +- 'https://unpkg.com/@stoplight/spectral-owasp-ruleset/dist/ruleset.mjs' diff --git a/catalyst-gateway/Earthfile b/catalyst-gateway/Earthfile index e70fb1e480e..53d0c35040c 100644 --- a/catalyst-gateway/Earthfile +++ b/catalyst-gateway/Earthfile @@ -121,3 +121,9 @@ local-ci-run: # BUILD +package BUILD +test # BUILD +publish + +# check-lint-openapi - OpenAPI linting from a given directory +check-lint-openapi: + FROM busybox + COPY +hosted-build/doc ./work + DO github.com/input-output-hk/catalyst-ci/earthly/spectral:feat/openapi-lint+BUILD_SPECTRAL --dir="./work" --file_type="json" From add302db438db2e4bbd51d80869d9955cf0231cc Mon Sep 17 00:00:00 2001 From: bkioshn Date: Tue, 16 Jan 2024 13:15:41 +0700 Subject: [PATCH 02/19] fix(lint): openapi linting --- catalyst-gateway/Earthfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/catalyst-gateway/Earthfile b/catalyst-gateway/Earthfile index 53d0c35040c..ec91d09309a 100644 --- a/catalyst-gateway/Earthfile +++ b/catalyst-gateway/Earthfile @@ -122,8 +122,9 @@ local-ci-run: BUILD +test # BUILD +publish -# check-lint-openapi - OpenAPI linting from a given directory -check-lint-openapi: - FROM busybox - COPY +hosted-build/doc ./work - DO github.com/input-output-hk/catalyst-ci/earthly/spectral:feat/openapi-lint+BUILD_SPECTRAL --dir="./work" --file_type="json" +check-lint-openapi: + FROM github.com/input-output-hk/catalyst-ci/earthly/spectral:feat/openapi-lint+spectral-base + # Copy the doc artifact. + COPY +hosted-build/doc ./doc + # Scan the doc directory where type of file is JSON. + DO github.com/input-output-hk/catalyst-ci/earthly/spectral:feat/openapi-lint+BUILD_SPECTRAL --dir=./doc --file_type="json" From e7b6d3ba8bdb5a9efb6abbc18781d3d360e49f86 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Tue, 16 Jan 2024 20:11:59 +0700 Subject: [PATCH 03/19] fix(spectral): add version for CDN --- catalyst-gateway/.spectral.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/catalyst-gateway/.spectral.yml b/catalyst-gateway/.spectral.yml index d8667163a51..556d9a008d4 100644 --- a/catalyst-gateway/.spectral.yml +++ b/catalyst-gateway/.spectral.yml @@ -8,5 +8,5 @@ # Use CDN hosted version for spectral-documentation and spectral-owasp extends: - 'spectral:oas' -- 'https://unpkg.com/@stoplight/spectral-documentation/dist/ruleset.mjs' -- 'https://unpkg.com/@stoplight/spectral-owasp-ruleset/dist/ruleset.mjs' +- 'https://unpkg.com/@stoplight/spectral-documentation@1.3.1/dist/ruleset.mjs' +- 'https://unpkg.com/@stoplight/spectral-owasp-ruleset@1.4.3/dist/ruleset.mjs' From 9272740d6d9e9ab5e2f68affe818c618b9a36877 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Tue, 16 Jan 2024 20:16:49 +0700 Subject: [PATCH 04/19] fix(openapi): linting openAPI files in test stage --- catalyst-gateway/Earthfile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/catalyst-gateway/Earthfile b/catalyst-gateway/Earthfile index ec91d09309a..8e8b7a4660a 100644 --- a/catalyst-gateway/Earthfile +++ b/catalyst-gateway/Earthfile @@ -108,6 +108,15 @@ test: BUILD --platform=linux/amd64 ./tests+integration-test END +# test-lint-openapi - OpenAPI linting from an artifact +# testing whether the OpenAPI generated during build stage follows good practice. +test-lint-openapi: + FROM github.com/input-output-hk/catalyst-ci/earthly/spectral:feat/openapi-lint+spectral-base + # Copy the doc artifact. + COPY +hosted-build/doc ./doc + # Scan the doc directory where type of file is JSON. + DO github.com/input-output-hk/catalyst-ci/earthly/spectral:feat/openapi-lint+BUILD_SPECTRAL --dir=./doc --file_type="json" + # Publish packages if all integration tests have passed. (Failure to pass tests will prevent packages being published.) # publish: # FROM scratch @@ -122,9 +131,3 @@ local-ci-run: BUILD +test # BUILD +publish -check-lint-openapi: - FROM github.com/input-output-hk/catalyst-ci/earthly/spectral:feat/openapi-lint+spectral-base - # Copy the doc artifact. - COPY +hosted-build/doc ./doc - # Scan the doc directory where type of file is JSON. - DO github.com/input-output-hk/catalyst-ci/earthly/spectral:feat/openapi-lint+BUILD_SPECTRAL --dir=./doc --file_type="json" From 05c7241a6280715fe1557f8d0d68868861558ff5 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Thu, 25 Jan 2024 20:34:44 +0700 Subject: [PATCH 05/19] fix: update rules and ref to doc --- catalyst-gateway/.spectral.yml | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/catalyst-gateway/.spectral.yml b/catalyst-gateway/.spectral.yml index 556d9a008d4..93925430d26 100644 --- a/catalyst-gateway/.spectral.yml +++ b/catalyst-gateway/.spectral.yml @@ -1,7 +1,7 @@ # References to the rules # OpenAPI: https://docs.stoplight.io/docs/spectral/4dec24461f3af-open-api-rules#openapi-rules -# OWASP Top 10: https://apistylebook.stoplight.io/docs/owasp-top-10 -# Documentations: https://github.com/stoplightio/spectral-documentation/blob/main/src/ruleset.ts +# OWASP Top 10: https://github.com/stoplightio/spectral-owasp-ruleset/blob/v1.4.3/src/ruleset.ts +# Documentations: https://github.com/stoplightio/spectral-documentation/blob/v1.3.1/src/ruleset.ts # cspell: words OWASP owasp @@ -10,3 +10,32 @@ extends: - 'spectral:oas' - 'https://unpkg.com/@stoplight/spectral-documentation@1.3.1/dist/ruleset.mjs' - 'https://unpkg.com/@stoplight/spectral-owasp-ruleset@1.4.3/dist/ruleset.mjs' + +aliases: + PathItem: + - $.paths[*] + OperationObject: + - $.paths[*][get,put,post,delete,options,head,patch,trace] + DescribableObjects: + - $.info + - $.tags[*] + - '#OperationObject' + - '#OperationObject.responses[*]' + - '#PathItem.parameters[?(@ && @.in)]' + - '#OperationObject.parameters[?(@ && @.in)]' + +overrides: +- files: ['*'] + rules: + # Override documnent description rule + # - No limitations on the characters that can start or end a sentence. + # - Length should be >= 20 characters + docs-description: + given: '#DescribableObjects' + then: + - field: 'description' + function: 'truthy' + - field: 'description' + function: 'length' + functionOptions: + min: 20 From a8341bf2bf983d771c7a433bf6435662fc1bdae8 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Thu, 25 Jan 2024 20:42:01 +0700 Subject: [PATCH 06/19] fix: typo --- catalyst-gateway/.spectral.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst-gateway/.spectral.yml b/catalyst-gateway/.spectral.yml index 93925430d26..04468b5f8bd 100644 --- a/catalyst-gateway/.spectral.yml +++ b/catalyst-gateway/.spectral.yml @@ -27,7 +27,7 @@ aliases: overrides: - files: ['*'] rules: - # Override documnent description rule + # Override document description rule # - No limitations on the characters that can start or end a sentence. # - Length should be >= 20 characters docs-description: From fb746adbdcea46759ca3c2f02fd017d0fa3c064c Mon Sep 17 00:00:00 2001 From: bkioshn Date: Thu, 25 Jan 2024 21:22:48 +0700 Subject: [PATCH 07/19] fix: openapi lint cat-ci version --- catalyst-gateway/Earthfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/catalyst-gateway/Earthfile b/catalyst-gateway/Earthfile index 8e8b7a4660a..42cc3ecea0c 100644 --- a/catalyst-gateway/Earthfile +++ b/catalyst-gateway/Earthfile @@ -111,11 +111,11 @@ test: # test-lint-openapi - OpenAPI linting from an artifact # testing whether the OpenAPI generated during build stage follows good practice. test-lint-openapi: - FROM github.com/input-output-hk/catalyst-ci/earthly/spectral:feat/openapi-lint+spectral-base + FROM github.com/input-output-hk/catalyst-ci/earthly/spectral:v2.4.0+spectral-base # Copy the doc artifact. COPY +hosted-build/doc ./doc # Scan the doc directory where type of file is JSON. - DO github.com/input-output-hk/catalyst-ci/earthly/spectral:feat/openapi-lint+BUILD_SPECTRAL --dir=./doc --file_type="json" + DO github.com/input-output-hk/catalyst-ci/earthly/spectral:v2.4.0+BUILD_SPECTRAL --dir=./doc --file_type="json" # Publish packages if all integration tests have passed. (Failure to pass tests will prevent packages being published.) # publish: From 5b411bbd5d5bc6b9762747a556c11602489d749d Mon Sep 17 00:00:00 2001 From: bkioshn Date: Wed, 31 Jan 2024 04:49:23 +0700 Subject: [PATCH 08/19] fix: update spectral rules --- catalyst-gateway/.spectral.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/catalyst-gateway/.spectral.yml b/catalyst-gateway/.spectral.yml index 04468b5f8bd..d4dd90a3ca8 100644 --- a/catalyst-gateway/.spectral.yml +++ b/catalyst-gateway/.spectral.yml @@ -39,3 +39,15 @@ overrides: function: 'length' functionOptions: min: 20 + + # Severity + # warn: Should be implemented, but is blocked by a technical issue. + # info: Good to be implemented. + + # Rate limit + owasp:api4:2019-rate-limit: warn + owasp:api4:2019-rate-limit-responses-429: warn + # Public API + owasp:api2:2019-protection-global-unsafe: info + owasp:api2:2019-protection-global-unsafe-strict: info + owasp:api3:2019-define-error-responses-401: off From ac97315e07334cdcb29ee191100aa10a1d7c4d9f Mon Sep 17 00:00:00 2001 From: bkioshn Date: Fri, 2 Feb 2024 18:13:47 +0700 Subject: [PATCH 09/19] fix: update spectral rules --- catalyst-gateway/.spectral.yml | 59 +++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/catalyst-gateway/.spectral.yml b/catalyst-gateway/.spectral.yml index d4dd90a3ca8..3ec3faa642a 100644 --- a/catalyst-gateway/.spectral.yml +++ b/catalyst-gateway/.spectral.yml @@ -48,6 +48,63 @@ overrides: owasp:api4:2019-rate-limit: warn owasp:api4:2019-rate-limit-responses-429: warn # Public API + owasp:api2:2019-protection-global-safe: info owasp:api2:2019-protection-global-unsafe: info owasp:api2:2019-protection-global-unsafe-strict: info - owasp:api3:2019-define-error-responses-401: off + owasp:api3:2019-define-error-responses-401: warn + +- files: + - '**#/paths/~1api~1health~1live/get/responses' + - '**#/paths/~1api~1health~1started/get/responses' + - '**#/paths/~1api~1health~1ready/get/responses' + - '**#/paths/~1api~1test~1test~1%7Bid%7D~1test~1%7Baction%7D/post/responses' + - '**#/paths/~1api~1test~1test~1%7Bid%7D~1test~1%7Baction%7D/get/responses' + # Recheck this, already apply validator but does not work "FragmentId" + - '**#/paths/~1api~1v1~1fragments~1statuses/get/parameters/0/schema' + # Recheck this, already apply validator but does not work "AccountId" + - '**#/paths/~1api~1v1~1votes~1plan~1account-votes~1%7Baccount_id%7D/get/parameters/0/schema' + rules: + owasp:api4:2019-string-restricted: off + +- files: + - '**#/paths/~1api~1health~1live/get/responses' + - '**#/paths/~1api~1health~1started/get/responses' + - '**#/paths/~1api~1health~1ready/get/responses' + - '**#/paths/~1api~1v0~1message/post/requestBody/content' + - '**#/paths/~1api~1test~1test~1%7Bid%7D~1test~1%7Baction%7D/post/responses' + - '**#/paths/~1api~1test~1test~1%7Bid%7D~1test~1%7Baction%7D/get/responses' + - '**#/components/schemas/ServerErrorPayload/properties/id' + - '**#/components/schemas/VoterRegistration/properties/as_at' + - '**#/components/schemas/VoterRegistration/properties/last_updated' + # Recheck this, already apply validator but does not work "FragmentId" + - '**#/paths/~1api~1v1~1fragments~1statuses/get/parameters/0/schema' + # Recheck this, already apply validator but does not work "AccountId" + - '**#/paths/~1api~1v1~1votes~1plan~1account-votes~1%7Baccount_id%7D/get/parameters/0/schema' + rules: + owasp:api4:2019-string-limit: off + +- files: + - '**#/paths/~1api~1v0~1vote~1active~1plans/get/responses' + - '**#/paths/~1api~1v1~1votes~1plan~1account-votes~1%7Baccount_id%7D/get/responses' + rules: + owasp:api4:2019-array-limit: off + +- files: + - '**#/components/schemas/FragmentStatus' + rules: + owasp:api6:2019-no-additionalProperties: off + +- files: + - '**#/paths/~1api~1v1~1fragments~1statuses/get/responses' + rules: + owasp:api6:2019-constrained-additionalProperties: off + +- files: + # Ignore event_id + - '**#/paths/~1api~1registration~1voter~1%7Bvoting_key%7D/get/parameters/1/schema' + # Ignore the test id + - '**#/paths/~1api~1test~1test~1%7Bid%7D~1test~1%7Baction%7D/post/parameters/0/schema' + - '**#/paths/~1api~1test~1test~1%7Bid%7D~1test~1%7Baction%7D/get/parameters/0/schema' + rules: + owasp:api1:2019-no-numeric-ids: off + From a6969010127bec9c4f7415536ac1aa0ebe17a170 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Fri, 2 Feb 2024 18:56:03 +0700 Subject: [PATCH 10/19] chore: add ref to the rule --- catalyst-gateway/.spectral.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/catalyst-gateway/.spectral.yml b/catalyst-gateway/.spectral.yml index 3ec3faa642a..6ec89c586db 100644 --- a/catalyst-gateway/.spectral.yml +++ b/catalyst-gateway/.spectral.yml @@ -30,6 +30,7 @@ overrides: # Override document description rule # - No limitations on the characters that can start or end a sentence. # - Length should be >= 20 characters + # Ref: https://github.com/stoplightio/spectral-documentation/blob/a34ca1b49cbd1ac5a75cfcb93c69d1d77bde341e/src/ruleset.ts#L173 docs-description: given: '#DescribableObjects' then: @@ -45,12 +46,18 @@ overrides: # info: Good to be implemented. # Rate limit + # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L436 owasp:api4:2019-rate-limit: warn + # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L484 owasp:api4:2019-rate-limit-responses-429: warn # Public API + # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L305 owasp:api2:2019-protection-global-safe: info + # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L269 owasp:api2:2019-protection-global-unsafe: info + # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L287 owasp:api2:2019-protection-global-unsafe-strict: info + # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L376 owasp:api3:2019-define-error-responses-401: warn - files: @@ -64,6 +71,7 @@ overrides: # Recheck this, already apply validator but does not work "AccountId" - '**#/paths/~1api~1v1~1votes~1plan~1account-votes~1%7Baccount_id%7D/get/parameters/0/schema' rules: + # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L551 owasp:api4:2019-string-restricted: off - files: @@ -81,22 +89,26 @@ overrides: # Recheck this, already apply validator but does not work "AccountId" - '**#/paths/~1api~1v1~1votes~1plan~1account-votes~1%7Baccount_id%7D/get/parameters/0/schema' rules: + # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L521 owasp:api4:2019-string-limit: off - files: - '**#/paths/~1api~1v0~1vote~1active~1plans/get/responses' - '**#/paths/~1api~1v1~1votes~1plan~1account-votes~1%7Baccount_id%7D/get/responses' rules: + # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L506 owasp:api4:2019-array-limit: off - files: - '**#/components/schemas/FragmentStatus' rules: + # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L678 owasp:api6:2019-no-additionalProperties: off - files: - '**#/paths/~1api~1v1~1fragments~1statuses/get/responses' rules: + # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L698 owasp:api6:2019-constrained-additionalProperties: off - files: @@ -106,5 +118,6 @@ overrides: - '**#/paths/~1api~1test~1test~1%7Bid%7D~1test~1%7Baction%7D/post/parameters/0/schema' - '**#/paths/~1api~1test~1test~1%7Bid%7D~1test~1%7Baction%7D/get/parameters/0/schema' rules: + # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L102 owasp:api1:2019-no-numeric-ids: off From b941bbb2254a7c9356985e5e9495feead596637a Mon Sep 17 00:00:00 2001 From: bkioshn Date: Mon, 5 Feb 2024 20:09:59 +0700 Subject: [PATCH 11/19] fix: server rules --- catalyst-gateway/.spectral.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/catalyst-gateway/.spectral.yml b/catalyst-gateway/.spectral.yml index 6ec89c586db..340c6fed1ec 100644 --- a/catalyst-gateway/.spectral.yml +++ b/catalyst-gateway/.spectral.yml @@ -121,3 +121,11 @@ overrides: # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L102 owasp:api1:2019-no-numeric-ids: off +- files: + - '**#/servers' + rules: + # Ref: https://github.com/stoplightio/spectral-documentation/blob/a34ca1b49cbd1ac5a75cfcb93c69d1d77bde341e/src/ruleset.ts#L173 + docs-description: off + # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L767 + owasp:api7:2019-security-hosts-https-oas3: off + From 5f3c8f34ea49e9f6cc754bae75c8f6fa897fc4e1 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Mon, 5 Feb 2024 20:44:05 +0700 Subject: [PATCH 12/19] fix: remove doc rule from server --- catalyst-gateway/.spectral.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/catalyst-gateway/.spectral.yml b/catalyst-gateway/.spectral.yml index 340c6fed1ec..4da8fda3aa7 100644 --- a/catalyst-gateway/.spectral.yml +++ b/catalyst-gateway/.spectral.yml @@ -124,8 +124,6 @@ overrides: - files: - '**#/servers' rules: - # Ref: https://github.com/stoplightio/spectral-documentation/blob/a34ca1b49cbd1ac5a75cfcb93c69d1d77bde341e/src/ruleset.ts#L173 - docs-description: off # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L767 owasp:api7:2019-security-hosts-https-oas3: off From c16fd9b94bb3f34537ad3325ee1f4ebdc278ed45 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Tue, 6 Feb 2024 19:18:11 +0700 Subject: [PATCH 13/19] fix: ignore id rule to all file --- catalyst-gateway/.spectral.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/catalyst-gateway/.spectral.yml b/catalyst-gateway/.spectral.yml index 4da8fda3aa7..b4ed77ee0c1 100644 --- a/catalyst-gateway/.spectral.yml +++ b/catalyst-gateway/.spectral.yml @@ -60,6 +60,10 @@ overrides: # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L376 owasp:api3:2019-define-error-responses-401: warn + # UUID rules for name containing "id" is ignored + # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L102 + owasp:api1:2019-no-numeric-ids: off + - files: - '**#/paths/~1api~1health~1live/get/responses' - '**#/paths/~1api~1health~1started/get/responses' @@ -111,16 +115,6 @@ overrides: # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L698 owasp:api6:2019-constrained-additionalProperties: off -- files: - # Ignore event_id - - '**#/paths/~1api~1registration~1voter~1%7Bvoting_key%7D/get/parameters/1/schema' - # Ignore the test id - - '**#/paths/~1api~1test~1test~1%7Bid%7D~1test~1%7Baction%7D/post/parameters/0/schema' - - '**#/paths/~1api~1test~1test~1%7Bid%7D~1test~1%7Baction%7D/get/parameters/0/schema' - rules: - # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L102 - owasp:api1:2019-no-numeric-ids: off - - files: - '**#/servers' rules: From 13934a709f467aa076afc815bbd861352088ebcb Mon Sep 17 00:00:00 2001 From: bkioshn Date: Tue, 6 Feb 2024 19:18:52 +0700 Subject: [PATCH 14/19] fix: remove server rules --- catalyst-gateway/.spectral.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/catalyst-gateway/.spectral.yml b/catalyst-gateway/.spectral.yml index b4ed77ee0c1..e20ed3b159b 100644 --- a/catalyst-gateway/.spectral.yml +++ b/catalyst-gateway/.spectral.yml @@ -114,10 +114,3 @@ overrides: rules: # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L698 owasp:api6:2019-constrained-additionalProperties: off - -- files: - - '**#/servers' - rules: - # Ref: https://github.com/stoplightio/spectral-owasp-ruleset/blob/2fd49c377794222352ff10dee99ed2a106c35199/src/ruleset.ts#L767 - owasp:api7:2019-security-hosts-https-oas3: off - From 9c37f196740c03470e182bdef46d90501c6f501d Mon Sep 17 00:00:00 2001 From: bkioshn Date: Tue, 6 Feb 2024 20:57:31 +0700 Subject: [PATCH 15/19] fix: cspell word --- catalyst-gateway/.spectral.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst-gateway/.spectral.yml b/catalyst-gateway/.spectral.yml index e20ed3b159b..c511c317834 100644 --- a/catalyst-gateway/.spectral.yml +++ b/catalyst-gateway/.spectral.yml @@ -3,7 +3,7 @@ # OWASP Top 10: https://github.com/stoplightio/spectral-owasp-ruleset/blob/v1.4.3/src/ruleset.ts # Documentations: https://github.com/stoplightio/spectral-documentation/blob/v1.3.1/src/ruleset.ts -# cspell: words OWASP owasp +# cspell: words OWASP owasp Baction # Use CDN hosted version for spectral-documentation and spectral-owasp extends: From 3a0c0b2ce892ab8eaf91aef47d505cdaa94337c0 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Tue, 6 Feb 2024 21:04:31 +0700 Subject: [PATCH 16/19] fix: cspell word --- catalyst-gateway/.spectral.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst-gateway/.spectral.yml b/catalyst-gateway/.spectral.yml index c511c317834..ab6b828e05b 100644 --- a/catalyst-gateway/.spectral.yml +++ b/catalyst-gateway/.spectral.yml @@ -3,7 +3,7 @@ # OWASP Top 10: https://github.com/stoplightio/spectral-owasp-ruleset/blob/v1.4.3/src/ruleset.ts # Documentations: https://github.com/stoplightio/spectral-documentation/blob/v1.3.1/src/ruleset.ts -# cspell: words OWASP owasp Baction +# cspell: words OWASP owasp Baction Baccount # Use CDN hosted version for spectral-documentation and spectral-owasp extends: From 72e2854df61535e5ef483ca9c4c314ecfd9d01c4 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Wed, 7 Feb 2024 09:20:41 +0700 Subject: [PATCH 17/19] fix: add regex for doc desc --- catalyst-gateway/.spectral.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/catalyst-gateway/.spectral.yml b/catalyst-gateway/.spectral.yml index ab6b828e05b..f6c799d0f03 100644 --- a/catalyst-gateway/.spectral.yml +++ b/catalyst-gateway/.spectral.yml @@ -40,6 +40,12 @@ overrides: function: 'length' functionOptions: min: 20 + - field: 'description' + function: 'pattern' + functionOptions: + # Matches any character that is #, *, uppercase or lowercase letters from A to Z, or digits from 0 to 9 at the beginning of the string. + # with zero or more occurences of any character except newline. + match: '^[#*A-Za-z0-9].*' # Severity # warn: Should be implemented, but is blocked by a technical issue. From 4f474e890b58b41ce53bc5ea06b3c76a073fe001 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Wed, 7 Feb 2024 09:25:02 +0700 Subject: [PATCH 18/19] fix: typo --- catalyst-gateway/.spectral.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst-gateway/.spectral.yml b/catalyst-gateway/.spectral.yml index f6c799d0f03..8a8c366e86b 100644 --- a/catalyst-gateway/.spectral.yml +++ b/catalyst-gateway/.spectral.yml @@ -44,7 +44,7 @@ overrides: function: 'pattern' functionOptions: # Matches any character that is #, *, uppercase or lowercase letters from A to Z, or digits from 0 to 9 at the beginning of the string. - # with zero or more occurences of any character except newline. + # with zero or more occurrences of any character except newline. match: '^[#*A-Za-z0-9].*' # Severity From abf9043e914d98046956db702fa38b68c9b8540c Mon Sep 17 00:00:00 2001 From: bkioshn Date: Wed, 7 Feb 2024 22:07:33 +0700 Subject: [PATCH 19/19] fix: doc build --- catalyst-gateway/Earthfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst-gateway/Earthfile b/catalyst-gateway/Earthfile index b53cf98ce47..872e1d103a8 100644 --- a/catalyst-gateway/Earthfile +++ b/catalyst-gateway/Earthfile @@ -52,7 +52,7 @@ all-hosts-build: test-lint-openapi: FROM github.com/input-output-hk/catalyst-ci/earthly/spectral:v2.4.0+spectral-base # Copy the doc artifact. - COPY +hosted-build/doc ./doc + COPY +build/doc ./doc # Scan the doc directory where type of file is JSON. DO github.com/input-output-hk/catalyst-ci/earthly/spectral:v2.4.0+BUILD_SPECTRAL --dir=./doc --file_type="json"