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:
@@ -62,9 +62,10 @@ export function assertSafePrCheckout(
|
||||
|
||||
// (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 && input.commit.toLowerCase()
|
||||
const commitMatchesPrHeadSha = !!commit && prShas.includes(commit)
|
||||
@@ -78,7 +79,7 @@ export function assertSafePrCheckout(
|
||||
eventName === 'workflow_run' &&
|
||||
!input.ref &&
|
||||
commit &&
|
||||
input.qualifiedRepository.toLowerCase() ===
|
||||
repository ===
|
||||
`${github.context.repo.owner}/${github.context.repo.repo}`.toLowerCase() &&
|
||||
fetchesFromWorkflowServer(input)
|
||||
) {
|
||||
@@ -114,6 +115,12 @@ function fetchesFromWorkflowServer(input: IUnsafePrCheckoutInput): boolean {
|
||||
: checkoutServer.origin === workflowServer.origin
|
||||
}
|
||||
|
||||
// Git transports resolve 'owner/repo.git' to 'owner/repo', so compare
|
||||
// repositories without one terminal '.git' suffix.
|
||||
function repositoryIdentity(qualifiedRepository: string): string {
|
||||
return qualifiedRepository.replace(/\.git$/, '').toLowerCase()
|
||||
}
|
||||
|
||||
async function commitIsInWorkflowHistory(
|
||||
authToken: string,
|
||||
commit: string
|
||||
|
||||
Reference in New Issue
Block a user