screwdriver-api 8.0.67 → 8.0.69

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.
@@ -361,32 +361,32 @@ scms:
361
361
  # # SCM clone type (https or ssh)
362
362
  # cloneType: SCM_GITLAB_RO_CLONE_TYPE
363
363
  webhooks:
364
- # Object keyed by scm name with value webhook settings.
365
- # Value of webhook settings is an object with the following properties:
366
- # Example:
367
- # {
368
- # "github": {
369
- # # Obtains the SCM token for a given user. If a user does not have a valid SCM token registered with Screwdriver, it will use this user's token instead.
370
- # "username": "sd-buildbot",
371
- # # Ignore commits made by these users
372
- # "ignoreCommitsBy": [],
373
- # # Restrict PR: all, none, branch, or fork
374
- # "restrictPR": "none",
375
- # # Chain PR: true or false
376
- # "chainPR": false,
377
- # # Upper limit on incoming uploads to builds
378
- # "maxBytes": 1048576 #1MB
379
- # },
380
- # "github.example.com": {
381
- # "username": "someuser",
382
- # "ignoreCommitsBy": ["someuser", "anotheruser"],
383
- # "restrictPR": "branch",
384
- # "chainPR": true,
385
- # "maxBytes": 2097152 #2MB
386
- # }
387
- # }
388
- __name: WEBHOOK_SETTINGS
389
- __format: json
364
+ scms:
365
+ # Object keyed by scm name with value webhook settings.
366
+ # Value of webhook settings is an object with the following properties:
367
+ # Example:
368
+ # {
369
+ # "github": {
370
+ # # Obtains the SCM token for a given user. If a user does not have a valid SCM token registered with Screwdriver, it will use this user's token instead.
371
+ # "username": "sd-buildbot",
372
+ # # Ignore commits made by these users
373
+ # "ignoreCommitsBy": [],
374
+ # # Restrict PR: all, none, branch, or fork
375
+ # "restrictPR": "none",
376
+ # # Chain PR: true or false
377
+ # "chainPR": false
378
+ # },
379
+ # "github.example.com": {
380
+ # "username": "someuser",
381
+ # "ignoreCommitsBy": ["someuser", "anotheruser"],
382
+ # "restrictPR": "branch",
383
+ # "chainPR": true
384
+ # }
385
+ # }
386
+ __name: WEBHOOK_SETTINGS
387
+ __format: json
388
+ maxBytes: WEBHOOK_MAX_BYTES
389
+
390
390
 
391
391
  bookends:
392
392
  # Object keyed by cluster name with value setup/teardown bookend.
@@ -277,42 +277,40 @@ scms: {}
277
277
  # accessToken: headlesstoken
278
278
  # # SCM clone type (https or ssh)
279
279
  # cloneType: https
280
- webhooks:
281
- github:
282
- # Obtains the SCM token for a given user. If a user does not have a valid SCM token registered with Screwdriver, it will use this user's token instead.
283
- username: sd-buildbot
284
- # Ignore commits made by these users
285
- ignoreCommitsBy: []
286
- # Restrict PR: all, none, branch, or fork
287
- restrictPR: none
288
- # Chain PR: true or false
289
- chainPR: false
290
- # Upper limit on incoming uploads to builds
291
- maxBytes: 1048576 #1MB
292
- # Object keyed by scm name with value webhook settings.
293
- # Value of webhook settings is an object with the following properties:
294
- # Example:
295
- # {
296
- # "github:github.com": {
297
- # # Obtains the SCM token for a given user. If a user does not have a valid SCM token registered with Screwdriver, it will use this user's token instead.
298
- # "username": "sd-buildbot",
299
- # # Ignore commits made by these users
300
- # "ignoreCommitsBy": [],
301
- # # Restrict PR: all, none, branch, or fork
302
- # "restrictPR": "none",
303
- # # Chain PR: true or false
304
- # "chainPR": false,
305
- # # Upper limit on incoming uploads to builds
306
- # "maxBytes": 1048576 #1MB
307
- # },
308
- # "github.example.com": {
309
- # "username": "someuser",
310
- # "ignoreCommitsBy": ["someuser", "anotheruser"],
311
- # "restrictPR": "branch",
312
- # "chainPR": true,
313
- # "maxBytes": 2097152 #2MB
314
- # }
315
- # }
280
+ webhooks:
281
+ scms:
282
+ github:
283
+ # Obtains the SCM token for a given user. If a user does not have a valid SCM token registered with Screwdriver, it will use this user's token instead.
284
+ username: sd-buildbot
285
+ # Ignore commits made by these users
286
+ ignoreCommitsBy: []
287
+ # Restrict PR: all, none, branch, or fork
288
+ restrictPR: none
289
+ # Chain PR: true or false
290
+ chainPR: false
291
+ # Object keyed by scm name with value webhook settings.
292
+ # Value of webhook settings is an object with the following properties:
293
+ # Example:
294
+ # {
295
+ # "github:github.com": {
296
+ # # Obtains the SCM token for a given user. If a user does not have a valid SCM token registered with Screwdriver, it will use this user's token instead.
297
+ # "username": "sd-buildbot",
298
+ # # Ignore commits made by these users
299
+ # "ignoreCommitsBy": [],
300
+ # # Restrict PR: all, none, branch, or fork
301
+ # "restrictPR": "none",
302
+ # # Chain PR: true or false
303
+ # "chainPR": false
304
+ # },
305
+ # "github.example.com": {
306
+ # "username": "someuser",
307
+ # "ignoreCommitsBy": ["someuser", "anotheruser"],
308
+ # "restrictPR": "branch",
309
+ # "chainPR": true
310
+ # }
311
+ # }
312
+ # Upper limit on incoming uploads to builds
313
+ maxBytes: 1048576 # 1MB
316
314
  coverage:
317
315
  default: "false"
318
316
  plugin: sonar
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-api",
3
- "version": "8.0.67",
3
+ "version": "8.0.69",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -6,8 +6,7 @@ const boom = require('@hapi/boom');
6
6
  const { ValidationError } = require('joi');
7
7
  const { startHookEvent } = require('./helper');
8
8
 
9
- const DEFAULT_MAX_BYTES = 1048576;
10
- const MAX_BYTES_UPPER_BOUND = 5242880; // 5MB
9
+ const DEFAULT_MAX_BYTES = 1048576; // 1MB
11
10
  const providerSchema = joi
12
11
  .object({
13
12
  username: joi.string().required(),
@@ -41,7 +40,7 @@ const webhooksPlugin = {
41
40
  name: 'webhooks',
42
41
  async register(server, options) {
43
42
  const pluginOptions = joi.attempt(
44
- options,
43
+ options.scms,
45
44
  joi.object().pattern(joi.string(), providerSchema).min(1).required(),
46
45
  'Invalid config for plugin-webhooks'
47
46
  );
@@ -59,7 +58,7 @@ const webhooksPlugin = {
59
58
  }
60
59
  },
61
60
  payload: {
62
- maxBytes: MAX_BYTES_UPPER_BOUND,
61
+ maxBytes: parseInt(pluginOptions.maxBytes, 10) || DEFAULT_MAX_BYTES,
63
62
  parse: false,
64
63
  output: 'stream'
65
64
  },
@@ -71,17 +70,10 @@ const webhooksPlugin = {
71
70
  let hookId;
72
71
 
73
72
  try {
74
- let size = 0;
75
73
  const chunks = [];
76
74
 
77
75
  for await (const chunk of request.payload) {
78
- size += chunk.length;
79
76
  chunks.push(chunk);
80
- if (size > DEFAULT_MAX_BYTES) {
81
- throw boom.entityTooLarge(
82
- `Payload size exceeds the maximum limit of ${DEFAULT_MAX_BYTES} bytes`
83
- );
84
- }
85
77
  }
86
78
 
87
79
  const data = Buffer.concat(chunks).toString();