screwdriver-api 7.0.223 → 7.0.225
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
|
@@ -62,6 +62,7 @@ const queueWebhookEnabled = convertToBool(config.get('queueWebhook').enabled);
|
|
|
62
62
|
// Default cluster environment variable
|
|
63
63
|
const clusterEnvConfig = config.get('build').environment; // readonly
|
|
64
64
|
const clusterEnv = { ...clusterEnvConfig };
|
|
65
|
+
const artifactsMaxDownloadSize = config.get('build').artifacts.maxDownloadSize;
|
|
65
66
|
|
|
66
67
|
Object.keys(clusterEnv).forEach(k => {
|
|
67
68
|
clusterEnv[k] = String(clusterEnv[k]);
|
|
@@ -304,7 +305,8 @@ datastore.setup(datastoreConfig.ddlSyncEnabled).then(() =>
|
|
|
304
305
|
executor,
|
|
305
306
|
queueWebhookEnabled
|
|
306
307
|
},
|
|
307
|
-
unzipArtifactsEnabled
|
|
308
|
+
unzipArtifactsEnabled,
|
|
309
|
+
artifactsMaxDownloadSize
|
|
308
310
|
})
|
|
309
311
|
.then(instance => logger.info('Server running at %s', instance.info.uri))
|
|
310
312
|
.catch(err => {
|
package/config/default.yaml
CHANGED
package/lib/server.js
CHANGED
|
@@ -82,6 +82,7 @@ function prettyPrintErrors(request, h) {
|
|
|
82
82
|
* @param {Object} config.builds.authConfig Configuration for auth
|
|
83
83
|
* @param {Object} config.builds.externalJoin Flag to allow external join
|
|
84
84
|
* @param {Object} config.unzipArtifactsEnabled Flag to allow unzip artifacts
|
|
85
|
+
* @param {Object} config.artifactsMaxDownloadSize Maximum download size for artifacts
|
|
85
86
|
* @param {Function} callback Callback to invoke when server has started.
|
|
86
87
|
* @return {http.Server} A listener: NodeJS http.Server object
|
|
87
88
|
*/
|
|
@@ -211,6 +212,7 @@ module.exports = async config => {
|
|
|
211
212
|
expiresIn
|
|
212
213
|
);
|
|
213
214
|
server.app.buildFactory.executor.tokenGen = server.app.buildFactory.tokenGen;
|
|
215
|
+
server.app.buildFactory.maxDownloadSize = parseInt(config.artifactsMaxDownloadSize, 10) * 1024 * 1024 * 1024;
|
|
214
216
|
|
|
215
217
|
server.app.jobFactory.apiUri = server.info.uri;
|
|
216
218
|
server.app.jobFactory.tokenGen = (username, metadata, scmContext, scope = ['user']) =>
|
package/package.json
CHANGED
|
@@ -31,6 +31,7 @@ module.exports = config => ({
|
|
|
31
31
|
const { credentials } = req.auth;
|
|
32
32
|
const { canAccessPipeline } = req.server.plugins.pipelines;
|
|
33
33
|
const { buildFactory, eventFactory } = req.server.app;
|
|
34
|
+
const { maxDownloadSize } = buildFactory;
|
|
34
35
|
|
|
35
36
|
return buildFactory.get(buildId)
|
|
36
37
|
.then(build => {
|
|
@@ -70,6 +71,23 @@ module.exports = config => ({
|
|
|
70
71
|
}).text();
|
|
71
72
|
const manifestArray = manifest.trim().split('\n');
|
|
72
73
|
const directoryArray = manifestArray.filter(f => f.startsWith(`./${artifact}/`));
|
|
74
|
+
let totalSize = 0;
|
|
75
|
+
|
|
76
|
+
// Check file sizes by fetching metadata
|
|
77
|
+
for (const file of directoryArray) {
|
|
78
|
+
if (file) {
|
|
79
|
+
const fileMetaResponse = await request.head(`${baseUrl}/${file}?token=${token}&type=download`);
|
|
80
|
+
const fileSize = parseInt(fileMetaResponse.headers['content-length'], 10);
|
|
81
|
+
|
|
82
|
+
// Accumulate total size
|
|
83
|
+
totalSize += fileSize;
|
|
84
|
+
|
|
85
|
+
// If total size exceeds allowed limit, stop further processing
|
|
86
|
+
if (totalSize > maxDownloadSize) {
|
|
87
|
+
throw new Error(`Total size of files exceeds the allowed limit of ${maxDownloadSize/1024/1024/1024}GB.`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
73
91
|
|
|
74
92
|
// Create a stream and set up archiver
|
|
75
93
|
const archive = archiver('zip', { zlib: { level: 9 } });
|