step-security / secure-repo

Orchestrate GitHub Actions Security
https://app.stepsecurity.io
GNU Affero General Public License v3.0
253 stars 41 forks source link

.pre-commit-config.yaml is not valid yaml #2402

Open konstruktoid opened 8 months ago

konstruktoid commented 8 months ago

https://github.com/konstruktoid/ansible-role-hardening/pull/456/files#diff-63a9c44a44acf85fea213a857769990937107cf072831e1a26808cfde9d096b9

$ yamllint .pre-commit-config.yaml
.pre-commit-config.yaml
  1:1       warning  missing document start "---"  (document-start)
  2:1       error    wrong indentation: expected at least 1  (indentation)
  5:3       error    wrong indentation: expected at least 3  (indentation)
  9:3       error    wrong indentation: expected at least 3  (indentation)
  13:3      error    wrong indentation: expected at least 3  (indentation)
konstruktoid commented 8 months ago

Related https://github.com/step-security/secure-repo/issues/2232

varunsh-coder commented 8 months ago

Thanks @konstruktoid for creating the issue!

I tried to validate the YAML online and it shows it as valid YAML.

I believe this is failing yamllint checks for indentation and I am wondering if different repos/ users might have different config for yamllint or is this a standard check which is failing?

konstruktoid commented 8 months ago

Yeah, as all linters it's a bit opinionated and this issue should probably be low priority.

But using eg https://www.yamllint.com, will turn the file from

repos:
- repo: https://github.com/gitleaks/gitleaks
  rev: v8.16.3
  hooks:
  - id: gitleaks
- repo: https://github.com/jumanjihouse/pre-commit-hooks
  rev: 3.0.0
  hooks:
  - id: shellcheck
- repo: https://github.com/pre-commit/pre-commit-hooks
  rev: v4.4.0
  hooks:
  - id: end-of-file-fixer
  - id: trailing-whitespace

and into

---
repos:
  - repo: https://github.com/gitleaks/gitleaks
    rev: v8.16.3
    hooks:
      - id: gitleaks
  - repo: https://github.com/jumanjihouse/pre-commit-hooks
    rev: 3.0.0
    hooks:
      - id: shellcheck
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.4.0
    hooks:
      - id: end-of-file-fixer
      - id: trailing-whitespace

yamllint indentation rules: https://yamllint.readthedocs.io/en/stable/rules.html#module-yamllint.rules.indentation The --- isn't required.