From cc6d637369ba693a107093aa6559f16547f9738d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rog=C3=A9rio=20Peixoto?= Date: Wed, 14 Apr 2021 17:36:18 +0100 Subject: [PATCH] adding linters for OpenAPI samples closes #2831 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rogério Peixoto --- .github/validators/openapi-skip-list | 0 .../workflows/validate-ansible-samples.yml | 2 +- .../workflows/validate-openapi-samples.yaml | 45 +++++++++++++++++++ .github/yamllint.yml | 2 - .github/yamllint_ansible.yml | 10 +++++ .../security_empty_array/test/negative1.json | 2 +- 6 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 .github/validators/openapi-skip-list create mode 100644 .github/workflows/validate-openapi-samples.yaml create mode 100644 .github/yamllint_ansible.yml diff --git a/.github/validators/openapi-skip-list b/.github/validators/openapi-skip-list new file mode 100644 index 00000000000..e69de29bb2d diff --git a/.github/workflows/validate-ansible-samples.yml b/.github/workflows/validate-ansible-samples.yml index 582de38ef1a..43d39d5001a 100644 --- a/.github/workflows/validate-ansible-samples.yml +++ b/.github/workflows/validate-ansible-samples.yml @@ -19,5 +19,5 @@ jobs: uses: ibiqlik/action-yamllint@v3 with: file_or_dir: assets/queries/ansible/ - config_file: .github/yamllint.yml + config_file: .github/yamllint_ansible.yml strict: true diff --git a/.github/workflows/validate-openapi-samples.yaml b/.github/workflows/validate-openapi-samples.yaml new file mode 100644 index 00000000000..b54811a67c2 --- /dev/null +++ b/.github/workflows/validate-openapi-samples.yaml @@ -0,0 +1,45 @@ +name: validate-openapi-samples + +on: + pull_request: + paths: + - "assets/queries/openapi/**/test/*.yaml" + - "assets/queries/openapi/**/test/*.json" + +jobs: + lint-yaml-samples: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + persist-credentials: false + - name: yaml-lint + uses: ibiqlik/action-yamllint@v3 + with: + file_or_dir: assets/queries/openAPI/ + config_file: .github/yamllint.yml + strict: true + lint-json-samples: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + persist-credentials: false + - uses: actions/setup-node@v2 + with: + node-version: '14' + - name: Installing jsonlint + run: | + npm install -g jsonlint + npm show jsonlint + which jsonlint + - name: Running JSON lint + run: | + python3 -u ".github/validators/validate-syntax.py" \ + "assets/queries/openapi/**/test/*.json" \ + --linter jsonlint \ + --skip ".github/validators/openapi-skip-list" -vv + + diff --git a/.github/yamllint.yml b/.github/yamllint.yml index 73a1e1c9611..1774aa0f778 100644 --- a/.github/yamllint.yml +++ b/.github/yamllint.yml @@ -6,5 +6,3 @@ rules: indentation: indent-sequences: consistent comments-indentation: disable -ignore: | - **/kms_key_with_vulnerable_policy/test/positive.yaml diff --git a/.github/yamllint_ansible.yml b/.github/yamllint_ansible.yml new file mode 100644 index 00000000000..73a1e1c9611 --- /dev/null +++ b/.github/yamllint_ansible.yml @@ -0,0 +1,10 @@ +extends: relaxed +rules: + line-length: + max: 180 + level: warning + indentation: + indent-sequences: consistent + comments-indentation: disable +ignore: | + **/kms_key_with_vulnerable_policy/test/positive.yaml diff --git a/assets/queries/openAPI/security_empty_array/test/negative1.json b/assets/queries/openAPI/security_empty_array/test/negative1.json index f951e2cd801..dbab5839763 100644 --- a/assets/queries/openAPI/security_empty_array/test/negative1.json +++ b/assets/queries/openAPI/security_empty_array/test/negative1.json @@ -1,7 +1,7 @@ { "openapi": "3.0.0", "info": { - "title": "Simple API overview", + "title": "Simple API Overview", "version": "1.0.0" }, "paths": {