Skip to content

Commit 9c56c2c

Browse files
author
Phoebe Schmidt
authored
fix(webhooks): exclude secret headers (#115)
For security reasons, the value of secret headers are not exported with webhooks. This was causing an invalid webhook body on the import (and a 500 error). The fix is to exclude secret headers from the import.
1 parent 39e6cc1 commit 9c56c2c

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ The data to import should be structured like this:
179179
- This tool currently does **not** support the import of roles.
180180
- This tool is expecting the target space to have the same default locale as your previously exported space.
181181
- Imported webhooks with credentials will be imported as normal webhooks. Credentials should be added manually afterwards.
182+
- Imported webhooks with secret headers will be imported without these headers. Secret headers should be added manuall afterwards.
182183
- If you have custom UI extensions, you need to reinstall them manually in the new space.
183184

184185
## :memo: Changelog

lib/transform/transformers.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ export function webhooks (webhook) {
2020
if (webhook.httpBasicUsername) {
2121
delete webhook.httpBasicUsername
2222
}
23+
24+
// Workaround for webhooks with secret headers
25+
if (webhook.headers) {
26+
webhook.headers = webhook.headers.filter(header => !header.secret)
27+
}
28+
2329
return webhook
2430
}
2531

test/unit/transform/transformers.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ test('It should transform webhook with credentials to normal webhook', () => {
6969
expect(transformedWebhook.httpBasicUsername).toBeFalsy()
7070
})
7171

72+
test('It should transform webhook with secret headers', () => {
73+
const webhookMock = cloneMock('webhook')
74+
const secretHeader = {key: 'Authorization', secret: true}
75+
const nonSecretHeader = {key: 'headerkey', value: 'headerval'}
76+
const headers = [secretHeader, nonSecretHeader]
77+
webhookMock.headers = headers
78+
const transformedWebhook = transformers.webhooks(webhookMock)
79+
expect(transformedWebhook.headers).toHaveLength(headers.length - 1)
80+
})
81+
7282
test('It should transform a locale and return it', () => {
7383
const localeMock = cloneMock('locale')
7484
localeMock.code = 'de-DE'

0 commit comments

Comments
 (0)