probot / smee-client

🔴 Receives payloads then sends them to your local server
https://smee.io
ISC License
440 stars 135 forks source link

remove rawdata header #321

Open Dancho80 opened 1 month ago

wolfy1339 commented 1 month ago

We don't send rawdata in the headers, only in the payload. (At least not from what I see)

https://github.com/probot/smee.io/commit/8c33d74f250c910b3deda2e498b11ade5645c580

Dancho80 commented 1 month ago

to debug it, we deployed a simple listener that will print the json received: while true; do { echo -e "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World!"; } | nc -l -p 8080; done and forwarded GitHub webhook by the smee-client to that listener. Once receiving the json, we noticed that rawdata is there as a header. After applying the change as in my PR, the error 431 resolved and the received json looks OK

wolfy1339 commented 1 month ago

Can you provide the full complete reproduction steps?

Start with how you set up the server, how did you set up the client, what version of Node are you using?

Any details that can help me debug this, because i would prefer it to be fixed in the server

Dancho80 commented 1 month ago

Server: ubuntu22.04 nvm use 12

git clone https://github.com/probot/smee.io smee-probot
cd smee-probot
npm install
npm build
pm2 start index.js --name smee-server

Client:

docker run -it node:22 ./bin/bash
git clone https://github.com/probot/smee-client.git
cd smee-client/ && git checkout beta
npm install
npm run build

to overcome self signed Jenkins:

export NODE_TLS_REJECT_UNAUTHORIZED='0'
node bin/smee.js --url https://<my-smee-server>/<my_channel> --target https://<JenkinsURL>:443/github-webhook/

In Github, editing webhook on any event to send application/json to https://<my-smee-server>/<my_channel> Webhooks is sent with reply code 200. https://<my-smee-server>/<my_channel> accepted the webhook properly. smee-client accepts 431 from Jenkins.

for debugging, instead of sending to Jenkins, I sent to some machine with nc command running (as described above), so I could print the received json: node bin/smee.js --url https://<my-smee-server>/<my_channel> --target http://myMachine:8080

wolfy1339 commented 1 month ago

Thanks for that. I see how this ended up in the headers.

https://github.com/probot/smee-client/blob/cc2cf2f4a5a0f5d467e838d97a6cc0594f95a445/index.ts#L64-L66

This solution unfortunately does not fix the root cause.

A new solution will have to be found in order to include the raw payload.

https://github.com/probot/smee.io/blob/9fe8e5caf49d6f25887accebae7576206ad770a8/lib%2Fserver.js#L107-L119

GitHub
smee.io/lib/server.js at 9fe8e5caf49d6f25887accebae7576206ad770a8 · probot/smee.io
☁️📦 Webhook payload delivery service. Contribute to probot/smee.io development by creating an account on GitHub.