mirror of
https://github.com/actions/checkout.git
synced 2026-12-05 03:52:55 +08:00
Ignore a .git suffix when matching checkout repositories
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
11
dist/index.js
vendored
11
dist/index.js
vendored
@@ -42012,8 +42012,9 @@ async function assertSafePrCheckout(input, authToken) {
|
||||
}
|
||||
// (B) We cannot check for all fork PR refs so check to see
|
||||
// if the resolved input points to the fork PR sha we have in the payload
|
||||
const repository = repositoryIdentity(input.qualifiedRepository);
|
||||
const repositoryMatchesPrHead = typeof prHeadRepoFullName === 'string' &&
|
||||
input.qualifiedRepository.toLowerCase() === prHeadRepoFullName.toLowerCase();
|
||||
repository === prHeadRepoFullName.toLowerCase();
|
||||
const refMatchesPullPattern = PR_REF_PATTERN.test(input.ref);
|
||||
const commit = input.commit?.toLowerCase();
|
||||
const commitMatchesPrHeadSha = !!commit && prShas.includes(commit);
|
||||
@@ -42022,8 +42023,7 @@ async function assertSafePrCheckout(input, authToken) {
|
||||
!commitMatchesPrHeadSha) {
|
||||
if (eventName === 'workflow_run' && !input.ref && commit) {
|
||||
const { owner, repo } = github_context.repo;
|
||||
if (input.qualifiedRepository.toLowerCase() ===
|
||||
`${owner}/${repo}`.toLowerCase() &&
|
||||
if (repository === `${owner}/${repo}`.toLowerCase() &&
|
||||
fetchesFromWorkflowServer(input) &&
|
||||
!(await commitIsInWorkflowHistory(authToken, owner, repo, commit))) {
|
||||
throw new Error('Refusing to check out the requested commit for this fork pull request. ' +
|
||||
@@ -42039,6 +42039,11 @@ async function assertSafePrCheckout(input, authToken) {
|
||||
`at https://gh.io/securely-using-pull_request_target and set 'allow-unsafe-pr-checkout: true' ` +
|
||||
`on the actions/checkout step.`);
|
||||
}
|
||||
// Git transports resolve 'owner/repo.git' to 'owner/repo', so compare
|
||||
// repositories without one terminal '.git' suffix.
|
||||
function repositoryIdentity(qualifiedRepository) {
|
||||
return qualifiedRepository.replace(/\.git$/, '').toLowerCase();
|
||||
}
|
||||
// SSH fetch URLs keep only the hostname, so the scheme and port cannot
|
||||
// distinguish the checkout server from the workflow server.
|
||||
function fetchesFromWorkflowServer(input) {
|
||||
|
||||
Reference in New Issue
Block a user