screwdriver-api 5.0.0 → 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 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
 
@@ -261,6 +264,7 @@ datastore.setup(datastoreConfig.ddlSyncEnabled).then(() =>
261
264
  scm
262
265
  },
263
266
  release,
267
+ log,
264
268
  validator: {
265
269
  externalJoin: true,
266
270
  notificationsValidationErr
@@ -468,6 +468,16 @@ release:
468
468
  __name: RELEASE_ENVIRONMENT_VARIABLES
469
469
  __format: json
470
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
+
471
481
  build:
472
482
  environment:
473
483
  __name: CLUSTER_ENVIRONMENT_VARIABLES
@@ -339,6 +339,13 @@ release:
339
339
  headerName: release
340
340
  headerValue: stable
341
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: []
342
349
 
343
350
  # default cluster environment variables to inject into builds
344
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": "5.0.0",
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.4",
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.4.2",
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.2.0",
101
+ "screwdriver-artifact-bookend": "^1.4.0",
102
102
  "screwdriver-build-bookend": "^3.0.0",
103
- "screwdriver-cache-bookend": "^2.0.2",
103
+ "screwdriver-cache-bookend": "^2.1.0",
104
104
  "screwdriver-command-validator": "^2.1.0",
105
- "screwdriver-config-parser": "^7.6.0",
106
- "screwdriver-coverage-bookend": "^1.0.3",
107
- "screwdriver-coverage-sonar": "^3.4.0",
108
- "screwdriver-data-schema": "^21.28.1",
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.18.1",
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.0",
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.0.11",
128
+ "sqlite3": "^5.1.2",
129
129
  "stream": "0.0.2",
130
130
  "tinytim": "^0.1.1",
131
131
  "uuid": "^8.3.2",
@@ -25,7 +25,12 @@ const loggingPlugin = {
25
25
  args: [{ error: '*', log: '*', response: '*', request: '*' }]
26
26
  },
27
27
  {
28
- module: '@hapi/good-console'
28
+ module: '@hapi/good-console',
29
+ args: [
30
+ {
31
+ color: false
32
+ }
33
+ ]
29
34
  },
30
35
  suppressAPITokens,
31
36
  'stdout'