screwdriver-api 4.1.297 → 5.0.1
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/bin/server +5 -2
- package/config/custom-environment-variables.yaml +25 -8
- package/config/default.yaml +14 -6
- package/lib/server.js +28 -0
- package/package.json +13 -13
- package/plugins/logging.js +6 -1
package/bin/server
CHANGED
|
@@ -44,6 +44,9 @@ ecosystem.api = httpdConfig.uri;
|
|
|
44
44
|
|
|
45
45
|
const release = config.get('release');
|
|
46
46
|
|
|
47
|
+
// Logging config
|
|
48
|
+
const log = config.get('log');
|
|
49
|
+
|
|
47
50
|
// Notification config
|
|
48
51
|
const notificationConfig = config.get('notifications');
|
|
49
52
|
|
|
@@ -116,8 +119,7 @@ const bookend = new Bookend(
|
|
|
116
119
|
'screwdriver-coverage-bookend': coverage,
|
|
117
120
|
'screwdriver-cache-bookend': cache
|
|
118
121
|
},
|
|
119
|
-
bookends
|
|
120
|
-
bookends.teardown || [] // plugins required for the teardown-steps
|
|
122
|
+
bookends
|
|
121
123
|
);
|
|
122
124
|
|
|
123
125
|
// Setup Pipeline Factory for Executor
|
|
@@ -262,6 +264,7 @@ datastore.setup(datastoreConfig.ddlSyncEnabled).then(() =>
|
|
|
262
264
|
scm
|
|
263
265
|
},
|
|
264
266
|
release,
|
|
267
|
+
log,
|
|
265
268
|
validator: {
|
|
266
269
|
externalJoin: true,
|
|
267
270
|
notificationsValidationErr
|
|
@@ -360,14 +360,21 @@ webhooks:
|
|
|
360
360
|
maxBytes: WEBHOOK_MAX_BYTES
|
|
361
361
|
|
|
362
362
|
bookends:
|
|
363
|
-
#
|
|
364
|
-
setup
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
#
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
363
|
+
# Object keyed by cluster name with value setup/teardown bookend.
|
|
364
|
+
# Value of setup/teardown is list of module names, or objects { name, config } for instantiation to use in sd-setup/sd-teardown.
|
|
365
|
+
# Example:
|
|
366
|
+
# {
|
|
367
|
+
# "default": {
|
|
368
|
+
# "setup": ["scm", "screwdriver-cache-bookend", "foo"],
|
|
369
|
+
# "teardown": ["screwdriver-artifact-bookend", "screwdriver-cache-bookend"]
|
|
370
|
+
# },
|
|
371
|
+
# "clusterA": {
|
|
372
|
+
# "setup": ["scm", "screwdriver-cache-bookend", "foo", "bar"],
|
|
373
|
+
# "teardown": ["screwdriver-cache-bookend", {"name": "baz", "config": {}, "alias": "qux"}]
|
|
374
|
+
# }
|
|
375
|
+
# }
|
|
376
|
+
__name: BOOKENDS
|
|
377
|
+
__format: json
|
|
371
378
|
|
|
372
379
|
notifications:
|
|
373
380
|
__name: NOTIFICATIONS
|
|
@@ -461,6 +468,16 @@ release:
|
|
|
461
468
|
__name: RELEASE_ENVIRONMENT_VARIABLES
|
|
462
469
|
__format: json
|
|
463
470
|
|
|
471
|
+
# Logging preferences
|
|
472
|
+
log:
|
|
473
|
+
audit:
|
|
474
|
+
# set true to enable audit logs for all API calls
|
|
475
|
+
enabled: LOG_AUDIT_ENABLED
|
|
476
|
+
# add target scope tokens(pipeline, build, temporal, admin, guest, user)
|
|
477
|
+
scope:
|
|
478
|
+
__name: LOG_AUDIT_SCOPE
|
|
479
|
+
__format: json
|
|
480
|
+
|
|
464
481
|
build:
|
|
465
482
|
environment:
|
|
466
483
|
__name: CLUSTER_ENVIRONMENT_VARIABLES
|
package/config/default.yaml
CHANGED
|
@@ -286,12 +286,13 @@ unzipArtifacts:
|
|
|
286
286
|
|
|
287
287
|
bookends:
|
|
288
288
|
# Plugins for build setup
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
289
|
+
default:
|
|
290
|
+
setup:
|
|
291
|
+
- scm
|
|
292
|
+
- screwdriver-cache-bookend
|
|
293
|
+
teardown:
|
|
294
|
+
- screwdriver-artifact-bookend
|
|
295
|
+
- screwdriver-cache-bookend
|
|
295
296
|
|
|
296
297
|
notifications:
|
|
297
298
|
options:
|
|
@@ -338,6 +339,13 @@ release:
|
|
|
338
339
|
headerName: release
|
|
339
340
|
headerValue: stable
|
|
340
341
|
|
|
342
|
+
# Logging preferences
|
|
343
|
+
log:
|
|
344
|
+
audit:
|
|
345
|
+
# set true to enable audit logs for all API calls
|
|
346
|
+
enabled: false
|
|
347
|
+
# add target scope tokens(pipeline, build, temporal, admin, guest, user)
|
|
348
|
+
scope: []
|
|
341
349
|
|
|
342
350
|
# default cluster environment variables to inject into builds
|
|
343
351
|
build:
|
package/lib/server.js
CHANGED
|
@@ -160,6 +160,34 @@ module.exports = async config => {
|
|
|
160
160
|
// Write prettier errors
|
|
161
161
|
server.ext('onPreResponse', prettyPrintErrors);
|
|
162
162
|
|
|
163
|
+
// Audit log
|
|
164
|
+
if (config.log && config.log.audit.enabled) {
|
|
165
|
+
server.ext('onCredentials', (request, h) => {
|
|
166
|
+
const { username, scope, pipelineId } = request.auth.credentials;
|
|
167
|
+
const validScope = config.log.audit.scope.filter(s => scope.includes(s));
|
|
168
|
+
|
|
169
|
+
if (Array.isArray(validScope) && validScope.length > 0) {
|
|
170
|
+
let context;
|
|
171
|
+
|
|
172
|
+
if (validScope.includes('admin')) {
|
|
173
|
+
context = `Admin ${username}`;
|
|
174
|
+
} else if (validScope.includes('user')) {
|
|
175
|
+
context = `User ${username}`;
|
|
176
|
+
} else if (validScope.includes('build') || validScope.includes('temporal')) {
|
|
177
|
+
context = `Build ${username}`;
|
|
178
|
+
} else if (validScope.includes('pipeline')) {
|
|
179
|
+
context = `Pipeline ${pipelineId}`;
|
|
180
|
+
} else {
|
|
181
|
+
context = `Guest ${username}`;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
logger.info(`[Login] ${context} ${request.method} ${request.path}`);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return h.continue;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
163
191
|
// Register events for notifications plugin
|
|
164
192
|
server.event(['build_status', 'job_status']);
|
|
165
193
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "screwdriver-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "API server for the Screwdriver.cd service",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -83,13 +83,13 @@
|
|
|
83
83
|
"badge-maker": "^3.3.1",
|
|
84
84
|
"config": "^1.31.0",
|
|
85
85
|
"date-fns": "^1.30.1",
|
|
86
|
-
"dayjs": "^1.11.
|
|
86
|
+
"dayjs": "^1.11.6",
|
|
87
87
|
"hapi-auth-bearer-token": "^8.0.0",
|
|
88
88
|
"hapi-auth-jwt2": "^10.2.0",
|
|
89
89
|
"hapi-rate-limit": "^5.0.1",
|
|
90
90
|
"hapi-swagger": "^14.5.5",
|
|
91
91
|
"ioredis": "^5.2.3",
|
|
92
|
-
"joi": "^17.
|
|
92
|
+
"joi": "^17.7.0",
|
|
93
93
|
"js-yaml": "^3.14.1",
|
|
94
94
|
"jsonwebtoken": "^8.5.1",
|
|
95
95
|
"license-checker": "^17.0.0",
|
|
@@ -98,14 +98,14 @@
|
|
|
98
98
|
"node-env-file": "^0.1.8",
|
|
99
99
|
"prom-client": "^12.0.0",
|
|
100
100
|
"redlock": "^4.1.0",
|
|
101
|
-
"screwdriver-artifact-bookend": "^1.
|
|
102
|
-
"screwdriver-build-bookend": "^
|
|
103
|
-
"screwdriver-cache-bookend": "^2.0
|
|
101
|
+
"screwdriver-artifact-bookend": "^1.4.0",
|
|
102
|
+
"screwdriver-build-bookend": "^3.0.0",
|
|
103
|
+
"screwdriver-cache-bookend": "^2.1.0",
|
|
104
104
|
"screwdriver-command-validator": "^2.1.0",
|
|
105
|
-
"screwdriver-config-parser": "^7.6.
|
|
106
|
-
"screwdriver-coverage-bookend": "^1.0
|
|
107
|
-
"screwdriver-coverage-sonar": "^3.4.
|
|
108
|
-
"screwdriver-data-schema": "^21.28.
|
|
105
|
+
"screwdriver-config-parser": "^7.6.1",
|
|
106
|
+
"screwdriver-coverage-bookend": "^1.1.0",
|
|
107
|
+
"screwdriver-coverage-sonar": "^3.4.1",
|
|
108
|
+
"screwdriver-data-schema": "^21.28.4",
|
|
109
109
|
"screwdriver-datastore-sequelize": "^7.2.7",
|
|
110
110
|
"screwdriver-executor-base": "^8.4.0",
|
|
111
111
|
"screwdriver-executor-docker": "^5.0.1",
|
|
@@ -114,18 +114,18 @@
|
|
|
114
114
|
"screwdriver-executor-queue": "^3.1.2",
|
|
115
115
|
"screwdriver-executor-router": "^2.3.0",
|
|
116
116
|
"screwdriver-logger": "^1.1.0",
|
|
117
|
-
"screwdriver-models": "^28.
|
|
117
|
+
"screwdriver-models": "^28.20.0",
|
|
118
118
|
"screwdriver-notifications-email": "^2.3.1",
|
|
119
119
|
"screwdriver-notifications-slack": "^3.3.0",
|
|
120
120
|
"screwdriver-request": "^1.0.3",
|
|
121
121
|
"screwdriver-scm-base": "^7.3.0",
|
|
122
122
|
"screwdriver-scm-bitbucket": "^4.5.1",
|
|
123
|
-
"screwdriver-scm-github": "^11.10.
|
|
123
|
+
"screwdriver-scm-github": "^11.10.3",
|
|
124
124
|
"screwdriver-scm-gitlab": "^2.10.0",
|
|
125
125
|
"screwdriver-scm-router": "^6.3.0",
|
|
126
126
|
"screwdriver-template-validator": "^5.2.0",
|
|
127
127
|
"screwdriver-workflow-parser": "^3.2.1",
|
|
128
|
-
"sqlite3": "^5.
|
|
128
|
+
"sqlite3": "^5.1.2",
|
|
129
129
|
"stream": "0.0.2",
|
|
130
130
|
"tinytim": "^0.1.1",
|
|
131
131
|
"uuid": "^8.3.2",
|
package/plugins/logging.js
CHANGED