This repository was archived by the owner on Jan 22, 2026. It is now read-only.
Verify Slack webhook tokens - #776
Open
tadzik wants to merge 6 commits into
Open
Conversation
Signed-off-by: Tadeusz „tadzik” Sośnierz <tadeusz@sosnierz.com>
Signed-off-by: Tadeusz „tadzik” Sośnierz <tadeusz@sosnierz.com>
Half-Shot
suggested changes
Jun 5, 2024
| } | ||
|
|
||
| private onRequest(req: IncomingMessage, res: ServerResponse) { | ||
| public _onRequest(req: IncomingMessage, res: ServerResponse) { |
Contributor
There was a problem hiding this comment.
This seems quite cheeky. If you're mocking stuff, why not hookHandler["onRequest"] to get around the public/private check.
Contributor
Author
There was a problem hiding this comment.
Getting around the check seems dirtier to me, to be honest. I won't fight for it though, I'm fine with either.
| } | ||
| return new Promise<void>((resolve, reject) => { | ||
| const srv = createServer(this.onRequest.bind(this)); | ||
| const srv = createServer(this._onRequest.bind(this)); |
Contributor
There was a problem hiding this comment.
Not a huge fan of the underscore prefix, smells like snakes
| let room = new BridgedRoom(harness.main as unknown as Main, { | ||
| matrix_room_id: '!foo:bar.baz', | ||
| inbound_id: randomstring.generate(32), | ||
| slack_webhook_token: randomstring.generate(24), |
Contributor
There was a problem hiding this comment.
What about no token at all :). Or null, or true etc etc :)
Contributor
Author
There was a problem hiding this comment.
Added a few more in tadzik@4d312a3?diff=unified&w=1 :)
tadzik
commented
Jun 5, 2024
| @@ -0,0 +1 @@ | |||
| Verify Slack webhook tokens. | |||
Contributor
Author
There was a problem hiding this comment.
I figured bugfix is the closest this comes to, since it was arguably a bug that we never did this before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This will unfortunately require relinking all existing channels that use webhooks.
I pondered making this optional, but in the spirit of being secure by default, it's probably best if we mandate this.
Existing rooms will have to be unlinked and linked again (or have their database entries updated manually).
This also increases SlackHookHandler's test coverage by ~18% (from 9.39% to 27.51%) :)