Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (action.kind === 'task') {
context.task = task;
context.ownTaskId = actionTaskId;
const actionTask = jsone(action.task, context);
const decisionTask = await queue.task(decisionTaskId);
const submitQueue = queue.use({ authorizedScopes: decisionTask.scopes });
await submitQueue.createTask(actionTaskId, actionTask);
return actionTaskId;
}
if (action.kind === 'hook') {
const hookPayload = jsone(action.hookPayload, context);
const { hookId, hookGroupId } = action;
const auth = new Auth({ rootUrl: currentRepo.tc_root_url });
const userCredentials = testMode
? taskcluster.getMockCredentials()
: taskcluster.getCredentials(currentRepo.tc_root_url);
if (!userCredentials) {
throw new Error(tcCredentialsMessage);
}
const hooks = new Hooks({
rootUrl: currentRepo.tc_root_url,
credentials: userCredentials.credentials,
});
const decisionTask = await queue.task(decisionTaskId);
const expansion = await auth.expandScopes({
scopes: decisionTask.scopes,
});
const expression = `in-tree:hook-action:${hookGroupId}/${hookId}`;