Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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}`;
if (!satisfiesExpression(expansion.scopes, expression)) {
throw new Error(
`Action is misconfigured: decision task's scopes do not satisfy ${expression}`,
);
}
const result = await hooks.triggerHook(hookGroupId, hookId, hookPayload);