Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(function (user) {
// NOTE: For more secure applications, the server should respond with a success even if the user isn't found
// since this reveals the existence of an account. For more information, refer to the links below:
// https://postmarkapp.com/guides/password-reset-email-best-practices
// https://security.stackexchange.com/questions/40694/disclose-to-user-if-account-exists
if (!user) {
return reply(Boom.notFound('User not found.'));
}
return reply(user);
})
.catch(function (error) {
async getModule(id, prefix = '') {
let manifestJSON = null;
let dirName = null;
const manifestFile = await this.getManifestFile(id);
if (manifestFile !== undefined) {
manifestJSON = manifestFile.json;
dirName = manifestFile.dirName;
}
else {
throw Boom.notFound(`Module with the id "${id}" not found`);
}
const jobs = [];
const datafeeds = [];
const kibana = {};
// load all of the job configs
await Promise.all(manifestJSON.jobs.map(async (job) => {
try {
const jobConfig = await this.readFile(`${this.modulesDir}/${dirName}/${ML_DIR}/${job.file}`);
// use the file name for the id
jobs.push({
id: `${prefix}${job.id}`,
config: JSON.parse(jobConfig)
});
} catch (error) {
mlLog.warn(`Data recognizer error loading config for job ${job.id} for module ${id}. ${error}`);
.then(([token, pipeline, user]) => {
if (!token) {
throw boom.notFound('Token does not exist');
}
if (!pipeline) {
throw boom.notFound('Pipeline does not exist');
}
if (!user) {
throw boom.notFound('User does not exist');
}
return user.getPermissions(pipeline.scmUri).then((permissions) => {
if (!permissions.admin) {
throw boom.forbidden(`User ${username} `
+ 'is not an admin of this repo');
}
return Promise.resolve();
}).then(() => {
if (token.pipelineId !== pipeline.id) {
throw boom.forbidden('Pipeline does not own token');
async function checkExists(func: () => Promise, message: string): Promise {
let result: R;
try {
result = await func();
} catch (e) {
if (e.errno === NodeGitError.CODE.ENOTFOUND) {
throw Boom.notFound(message);
} else {
throw e;
}
}
if (result == null) {
throw Boom.notFound(message);
}
return result;
}
return buildFactory.get(request.params.id).then((build) => {
if (!build) {
throw boom.notFound('Build does not exist');
}
if (parseInt(request.params.id, 10) !== parseInt(profile.username, 10)) {
throw boom.notFound('Build Id parameter and token does not match');
}
if (isFinite(buildTimeout) === false && buildTimeout !== null) {
throw boom.badRequest(`Invalid buildTimeout value: ${buildTimeout}`);
}
if (build.status !== 'QUEUED' && build.status !== 'BLOCKED') {
throw boom.forbidden('Build is already running or finished.');
}
const jwtInfo = {
isPR: profile.isPR,
jobId: profile.jobId,
eventId: profile.eventId,
pipelineId: profile.pipelineId,
configPipelineId: profile.configPipelineId
};
.catch((err) => {
reply(Boom.notFound(err))
})
}
Service.getStreamById(request.params.id).then(function(result) {
if (result instanceof Error) {
logger.error(result.message);
return reply(Boom.notFound(result.message));
}
return reply(result);
});
};
redis.hgetall(`scenario:${intentId}`, (err, data) => {
if (err){
const error = Boom.badImplementation('An error occurred retrieving the scenario.');
return reply(error);
}
if (data){
return reply(null, Cast(Flat.unflatten(data), 'scenario'));
}
const error = Boom.notFound('The specified scenario doesn\'t exists');
return reply(error);
});
async getJournalEntry(journal, id) {
const me = this;
try {
let entryPath = path.join(me.parentFolder, journal, id);
if(!fs.existsSync(entryPath))
throw Boom.notFound(`Entry ${id} not found.`);
return JSON.parse(fs.readFileSync(entryPath, 'utf8'))
} catch (err) {
me.error(scope, 'getJournalEntry', err);
throw err;
}
}
function(err, result) {
if ( err ) {
return reply(err);
}
if ( !result.rows.length ) {
return reply(boom.notFound('Element not found'));
}
reply({
status: 'success',
element: request.server.methods.utils.formatElement(result.rows[0])
});
}
);