Skip to content

fix: Ensure allowlist is also checked in the context of issue #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions __tests__/functions/prechecks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,22 @@ test('runs prechecks and finds that the user is not an allowed operator', async
message: `### ⚠️ Cannot proceed with operation\n\n> User monalisa is not an allowed operator`,
status: false
})

expect(
await prechecks(
'123',
true,
false, // skip_ci
true, // skip_reviews
false, // allow_drafts
'issue', // contextType
context,
octokit
)
).toStrictEqual({
message: `### ⚠️ Cannot proceed with operation\n\n> User monalisa is not an allowed operator`,
status: false
})
})

test('runs prechecks and finds that skip_ci is set and no reviews are defined', async () => {
Expand Down
12 changes: 6 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/functions/prechecks.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ export async function prechecks(
return {message: validPermissionsRes, status: false}
}

// Get allowed operator data
if (!(await isAllowed(context))) {
message = `### ⚠️ Cannot proceed with operation\n\n> User ${context.actor} is not an allowed operator`
return {message: message, status: false}
}

// if this is an issue comment, we can skip all the logic below here as it...
// ... only applies to pull requests
if (contextType === 'issue') {
Expand Down Expand Up @@ -189,12 +195,6 @@ export async function prechecks(
}
}

// Get allowed operator data
if (!(await isAllowed(context))) {
message = `### ⚠️ Cannot proceed with operation\n\n> User ${context.actor} is not an allowed operator`
return {message: message, status: false}
}

// log values for debugging
core.debug('precheck values for debugging:')
core.debug(`reviewDecision: ${reviewDecision}`)
Expand Down