triggers icon indicating copy to clipboard operation
triggers copied to clipboard

cel eval is not validating json already validated

Open alansenairj opened this issue 1 year ago • 1 comments

Expected Behavior

cel-eval -e expressiont.txt -r payload.json: true or false

Actual Behavior

error making eval context: failed to parse the body as JSON: unexpected end of JSON input

body.object_kind == 'push' && (body.ref == 'refs/heads/develop' || body.ref == 'refs/heads/staging') or object_kind == 'push' && (ref == 'refs/heads/develop'

payload file:

POST / HTTP/1.1
Content-Type: application/json
User-Agent: insomnia/9.3.2
X-Gitlab-Event: Push Hook
X-Gitlab-Token: nononono
Host: localhost:8080
Content-Length: 4373

{
	"object_kind": "push",
	"event_name": "push",
	"before": "36988bdb67e6fc4df847c37c4b040823ffa401d8",
	"after": "143f0123a00e035a850b9f991a0214b5844b9e24",
	"ref": "refs/heads/develop",

<... bla bla bla validated>

}

Steps to Reproduce the Problem

  1. get webhook payload from gitlab
  2. validate paylod in insomnia or json lint at https://jsonlint.com/
  3. not filtering!
  4. error making eval context: failed to parse the body as JSON: unexpected end of JSON input (???)

Additional Info

  • Kubernetes version:

    Output of kubectl version:

    (paste your output here)
    
  • Tekton Pipeline version:

    Output of tkn version or kubectl get pods -n tekton-pipelines -l app=tekton-pipelines-controller -o=jsonpath='{.items[0].metadata.labels.version}'

alansenairj avatar Sep 08 '24 02:09 alansenairj

@alansenairj Are you changing the body from the original, if so, your Content-Length might be wrong which would cause the HTTP request reader to fail to parse the payload.

bigkevmcd avatar Oct 08 '24 06:10 bigkevmcd