@backstage/plugin-events-backend-module-github 0.2.14-next.2 → 0.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @backstage/plugin-events-backend-module-github
|
|
2
2
|
|
|
3
|
+
## 0.2.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9816f51: Fix the event request validation for incoming requests for GitHub webhook events
|
|
8
|
+
by using the raw body when verifying the signature.
|
|
9
|
+
- 9816f51: Add raw body information to `RequestDetails`
|
|
10
|
+
and use the raw body when validating incoming event requests.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/config@1.3.0
|
|
13
|
+
- @backstage/plugin-events-node@0.4.5
|
|
14
|
+
- @backstage/backend-plugin-api@1.0.2
|
|
15
|
+
|
|
16
|
+
## 0.2.14-next.3
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 9816f51: Fix the event request validation for incoming requests for GitHub webhook events
|
|
21
|
+
by using the raw body when verifying the signature.
|
|
22
|
+
- 9816f51: Add raw body information to `RequestDetails`
|
|
23
|
+
and use the raw body when validating incoming event requests.
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
- @backstage/plugin-events-node@0.4.5-next.3
|
|
26
|
+
- @backstage/backend-plugin-api@1.0.2-next.2
|
|
27
|
+
- @backstage/config@1.2.0
|
|
28
|
+
|
|
3
29
|
## 0.2.14-next.2
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
|
@@ -6,7 +6,11 @@ function createGithubSignatureValidator(config) {
|
|
|
6
6
|
const secret = config.getString("events.modules.github.webhookSecret");
|
|
7
7
|
return async (request, context) => {
|
|
8
8
|
const signature = request.headers["x-hub-signature-256"];
|
|
9
|
-
if (!signature || !await webhooksMethods.verify(
|
|
9
|
+
if (!signature || !await webhooksMethods.verify(
|
|
10
|
+
secret,
|
|
11
|
+
request.raw.body.toString(request.raw.encoding),
|
|
12
|
+
signature
|
|
13
|
+
)) {
|
|
10
14
|
context.reject({
|
|
11
15
|
status: 403,
|
|
12
16
|
payload: { message: "invalid signature" }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGithubSignatureValidator.cjs.js","sources":["../../src/http/createGithubSignatureValidator.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport {\n RequestDetails,\n RequestValidationContext,\n RequestValidator,\n} from '@backstage/plugin-events-node';\nimport { verify } from '@octokit/webhooks-methods';\n\n/**\n * Validates that the request received is the expected GitHub request\n * using the signature received with the `x-hub-signature-256` header\n * which is based on a secret token configured at GitHub and here.\n *\n * See https://docs.github.com/en/developers/webhooks-and-events/webhooks/securing-your-webhooks\n * for more details.\n *\n * @param config - root config\n * @public\n */\nexport function createGithubSignatureValidator(\n config: Config,\n): RequestValidator {\n const secret = config.getString('events.modules.github.webhookSecret');\n\n return async (\n request: RequestDetails,\n context: RequestValidationContext,\n ): Promise<void> => {\n const signature = request.headers['x-hub-signature-256'] as\n | string\n | undefined;\n\n if (\n !signature ||\n !(await verify(secret
|
|
1
|
+
{"version":3,"file":"createGithubSignatureValidator.cjs.js","sources":["../../src/http/createGithubSignatureValidator.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport {\n RequestDetails,\n RequestValidationContext,\n RequestValidator,\n} from '@backstage/plugin-events-node';\nimport { verify } from '@octokit/webhooks-methods';\n\n/**\n * Validates that the request received is the expected GitHub request\n * using the signature received with the `x-hub-signature-256` header\n * which is based on a secret token configured at GitHub and here.\n *\n * See https://docs.github.com/en/developers/webhooks-and-events/webhooks/securing-your-webhooks\n * for more details.\n *\n * @param config - root config\n * @public\n */\nexport function createGithubSignatureValidator(\n config: Config,\n): RequestValidator {\n const secret = config.getString('events.modules.github.webhookSecret');\n\n return async (\n request: RequestDetails,\n context: RequestValidationContext,\n ): Promise<void> => {\n const signature = request.headers['x-hub-signature-256'] as\n | string\n | undefined;\n\n if (\n !signature ||\n !(await verify(\n secret,\n request.raw.body.toString(request.raw.encoding),\n signature,\n ))\n ) {\n context.reject({\n status: 403,\n payload: { message: 'invalid signature' },\n });\n }\n };\n}\n"],"names":["verify"],"mappings":";;;;AAmCO,SAAS,+BACd,MACkB,EAAA;AAClB,EAAM,MAAA,MAAA,GAAS,MAAO,CAAA,SAAA,CAAU,qCAAqC,CAAA;AAErE,EAAO,OAAA,OACL,SACA,OACkB,KAAA;AAClB,IAAM,MAAA,SAAA,GAAY,OAAQ,CAAA,OAAA,CAAQ,qBAAqB,CAAA;AAIvD,IACE,IAAA,CAAC,SACD,IAAA,CAAE,MAAMA,sBAAA;AAAA,MACN,MAAA;AAAA,MACA,QAAQ,GAAI,CAAA,IAAA,CAAK,QAAS,CAAA,OAAA,CAAQ,IAAI,QAAQ,CAAA;AAAA,MAC9C;AAAA,KAEF,EAAA;AACA,MAAA,OAAA,CAAQ,MAAO,CAAA;AAAA,QACb,MAAQ,EAAA,GAAA;AAAA,QACR,OAAA,EAAS,EAAE,OAAA,EAAS,mBAAoB;AAAA,OACzC,CAAA;AAAA;AACH,GACF;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-events-backend-module-github",
|
|
3
|
-
"version": "0.2.14
|
|
3
|
+
"version": "0.2.14",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "backend-plugin-module",
|
|
6
6
|
"pluginId": "events",
|
|
@@ -31,10 +31,19 @@
|
|
|
31
31
|
},
|
|
32
32
|
"main": "./dist/index.cjs.js",
|
|
33
33
|
"types": "./dist/index.d.ts",
|
|
34
|
+
"typesVersions": {
|
|
35
|
+
"*": {
|
|
36
|
+
"index": [
|
|
37
|
+
"dist/index.d.ts"
|
|
38
|
+
],
|
|
39
|
+
"alpha": [
|
|
40
|
+
"dist/alpha.d.ts"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
34
44
|
"files": [
|
|
35
45
|
"config.d.ts",
|
|
36
|
-
"dist"
|
|
37
|
-
"alpha"
|
|
46
|
+
"dist"
|
|
38
47
|
],
|
|
39
48
|
"scripts": {
|
|
40
49
|
"build": "backstage-cli package build",
|
|
@@ -46,15 +55,15 @@
|
|
|
46
55
|
"test": "backstage-cli package test"
|
|
47
56
|
},
|
|
48
57
|
"dependencies": {
|
|
49
|
-
"@backstage/backend-plugin-api": "1.0.2
|
|
50
|
-
"@backstage/config": "1.
|
|
51
|
-
"@backstage/plugin-events-node": "0.4.5
|
|
58
|
+
"@backstage/backend-plugin-api": "^1.0.2",
|
|
59
|
+
"@backstage/config": "^1.3.0",
|
|
60
|
+
"@backstage/plugin-events-node": "^0.4.5",
|
|
52
61
|
"@octokit/webhooks-methods": "^3.0.0"
|
|
53
62
|
},
|
|
54
63
|
"devDependencies": {
|
|
55
|
-
"@backstage/backend-test-utils": "1.1.0
|
|
56
|
-
"@backstage/cli": "0.29.0
|
|
57
|
-
"@backstage/plugin-events-backend-test-utils": "0.1.38
|
|
64
|
+
"@backstage/backend-test-utils": "^1.1.0",
|
|
65
|
+
"@backstage/cli": "^0.29.0",
|
|
66
|
+
"@backstage/plugin-events-backend-test-utils": "^0.1.38"
|
|
58
67
|
},
|
|
59
68
|
"configSchema": "config.d.ts"
|
|
60
69
|
}
|