kics icon indicating copy to clipboard operation
kics copied to clipboard

bug(cicd): yaml parser transform number to string

Open jycamier opened this issue 11 months ago • 0 comments

KICS : 1.7.13

In Github Action, we've encounter side-effect about parsing.

name: parser test
on:
  pull_request: {}
jobs:
  matrix-fail:
    strategy:
      max-parallel: 8
      matrix:
        - name: foo
        - name: bar
    runs-on: [self-hosted, linter]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: 1.20    

Go version 1.20 is parsed by Github as a number so, 1.20 is considered as 1.2 (and that's wrong). We want to create a query to check this.

However, the yaml perser of kics transform this number to a string, so it become impossible to check.

{
    "file": "/test/positive1.yaml",
    "id": "a30b26aa-f7ae-4864-a20d-443a361f7f00",
    "jobs": {
        "matrix-fail": {
            "runs-on": [
                "self-hosted",
                "linter"
            ],
            "steps": [
                {
                    "uses": "actions/checkout@v4"
                },
                {
                    "uses": "actions/setup-go@v5",
                    "with": {
                        "go-version": "1.20"
                    }
                }
            ],
            "strategy": {
                "matrix": [
                    {
                        "name": "foo"
                    },
                    {
                        "name": "bar"
                    }
                ],
                "max-parallel": 8
            }
        },
        "matrix-ok": {
            "runs-on": [
                "self-hosted",
                "linter"
            ],
            "steps": [
                {
                    "uses": "actions/checkout@v2"
                }
            ],
            "strategy": {
                "matrix": [
                    {
                        "name": "foo"
                    },
                    {
                        "name": "bar"
                    }
                ],
                "max-parallel": 7
            }
        }
    },
    "name": "parser test",
    "on": {
        "pull_request": {}
    }
}

jycamier avatar Mar 06 '24 14:03 jycamier