Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const boom = require('boom');
const joi = require('joi');
const schema = require('screwdriver-data-schema');
const baseSchema = schema.models.commandTag.base;
const urlLib = require('url');
const VERSION_REGEX = schema.config.regex.VERSION;
const exactVersionSchema = joi.reach(schema.models.commandTag.base, 'version');
const tagSchema = joi.reach(schema.models.commandTag.base, 'tag');
/* Currently, only build scope is allowed to tag command due to security reasons.
* The same pipeline that publishes the command has the permission to tag it.
*/
module.exports = () => ({
method: 'PUT',
path: '/commands/{namespace}/{name}/tags/{tagName}',
config: {
description: 'Add or update a command tag',
notes: 'Add or update a specific command',
tags: ['api', 'commands'],
auth: {
strategies: ['token'],
scope: ['build', '!guest']
},
plugins: {
'use strict';
const boom = require('boom');
const joi = require('joi');
const schema = require('screwdriver-data-schema');
const idSchema = joi.reach(schema.models.pipeline.base, 'id');
module.exports = () => ({
method: 'POST',
path: '/pipelines/{id}/sync/pullrequests',
config: {
description: 'Add or update pull request of a pipeline',
notes: 'Add or update pull request jobs',
tags: ['api', 'pipelines'],
auth: {
strategies: ['token'],
scope: ['user', '!guest']
},
plugins: {
'hapi-swagger': {
security: [{ token: [] }]
}
fields: () => omitBy(mapValues(desc.children, (child, k) => {
if (presence(child, 'forbidden')) return null
return { type: descToType(Joi.reach(schema, k), true) }
}), isNull)
})
fields: () => descsToFields(mapValues(desc.children, (child, k) => Joi.reach(schema, k)))
})
'use strict';
const boom = require('boom');
const joi = require('joi');
const schema = require('screwdriver-data-schema');
const idSchema = joi.reach(schema.models.token.base, 'id');
module.exports = () => ({
method: 'PUT',
path: '/tokens/{id}',
config: {
description: 'Update a token',
notes: 'Update a specific token',
tags: ['api', 'tokens'],
auth: {
strategies: ['token'],
scope: ['user', '!guest']
},
plugins: {
'hapi-swagger': {
security: [{ token: [] }]
}
}
};
return job.getBuilds(listConfig)
.then(builds => reply.redirect(getUrl(Object.assign(
badgeConfig,
{
builds,
subject: `${pipeline.name}:${jobName}`
}))));
}).catch(() => reply.redirect(getUrl(badgeConfig)));
},
validate: {
params: {
id: idSchema,
jobName: joi.reach(schema.models.job.base, 'name')
}
}
}
});
'use strict';
const boom = require('boom');
const joi = require('joi');
const schema = require('screwdriver-data-schema');
const getSchema = schema.models.event.get;
const idSchema = joi.reach(schema.models.event.base, 'id');
module.exports = () => ({
method: 'GET',
path: '/events/{id}',
config: {
description: 'Get a single event',
notes: 'Returns a event record',
tags: ['api', 'events'],
auth: {
strategies: ['token'],
scope: ['user', 'build', 'pipeline']
},
plugins: {
'hapi-swagger': {
security: [{ token: [] }]
}
'use strict';
const joi = require('joi');
const schema = require('screwdriver-data-schema');
const workflowParser = require('screwdriver-workflow-parser');
const tinytim = require('tinytim');
const idSchema = joi.reach(schema.models.pipeline.base, 'id');
/**
* Generate Badge URL
* @method getUrl
* @param {String} badgeService Badge service url
* @param {Object} statusColor Mapping for status and color
* @param {Function} encodeBadgeSubject Function to encode subject
* @param {Array} [buildsStatus=[]] An array of builds
* @param {String} [subject='job'] Subject of the badge
* @return {String}
*/
function getUrl({
badgeService,
statusColor,
encodeBadgeSubject,
buildsStatus = [],
'use strict';
const boom = require('boom');
const joi = require('joi');
const schema = require('screwdriver-data-schema');
const getSchema = schema.models.command.get;
const namespaceSchema = joi.reach(schema.models.command.base, 'namespace');
const nameSchema = joi.reach(schema.models.command.base, 'name');
const versionSchema = joi.reach(schema.models.command.base, 'version');
const tagSchema = joi.reach(schema.models.commandTag.base, 'tag');
module.exports = () => ({
method: 'GET',
path: '/commands/{namespace}/{name}/{versionOrTag}',
config: {
description: 'Get a single command given command namespace, name and version or tag',
notes: 'Returns a command record',
tags: ['api', 'commands'],
auth: {
strategies: ['token'],
scope: ['user', 'build']
},
plugins: {
'hapi-swagger': {
security: [{ token: [] }]