-
Notifications
You must be signed in to change notification settings - Fork 295
Fix cross-repo update-issue safe-outputs: routing bypass and wildcard validation failure
#19354
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
Changes from all commits
d22d179
4da8d32
b0e53d4
1f3b15a
9647220
95a3a11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,19 +149,23 @@ function createUpdateHandlerFactory(handlerConfig) { | |
|
|
||
| const item = message; | ||
|
|
||
| // Resolve cross-repo target: if message has a "repo" field, validate it against | ||
| // the allowed repos and use it as the effective context. This enables updating items | ||
| // in a different repository when github-token is configured with the required permissions. | ||
| // Resolve cross-repo target: always validate the target repository against the | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good fix — |
||
| // allowed repos and use it as the effective context. When item.repo is set it | ||
| // overrides the default; otherwise defaultTargetRepo is used. This mirrors the | ||
| // add_comment routing behaviour and ensures target-repo config is honoured even | ||
| // when the agent does not explicitly provide a repo field. | ||
| // Using {any} type to allow partial context override (effectiveContext.repo may differ from context.repo). | ||
| const repoResult = resolveAndValidateRepo(item, defaultTargetRepo, allowedRepos, itemTypeName); | ||
| if (!repoResult.success) { | ||
| core.warning(repoResult.error); | ||
| return { success: false, error: repoResult.error }; | ||
| } | ||
| /** @type {any} */ | ||
| let effectiveContext = context; | ||
| if (item.repo) { | ||
| const repoResult = resolveAndValidateRepo(item, defaultTargetRepo, allowedRepos, itemTypeName); | ||
| if (!repoResult.success) { | ||
| core.warning(repoResult.error); | ||
| return { success: false, error: repoResult.error }; | ||
| } | ||
| effectiveContext = { ...context, repo: repoResult.repoParts }; | ||
| const effectiveContext = { ...context, repo: repoResult.repoParts }; | ||
| // Log cross-repo routing when the agent explicitly set a repo field, | ||
| // or when the resolved repo differs from the current workflow's repository. | ||
| const workflowRepo = `${context.repo.owner}/${context.repo.repo}`; | ||
| if (item.repo || repoResult.repo !== workflowRepo) { | ||
| core.info(`Cross-repo update: targeting ${repoResult.repo}`); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wildcard check is placed correctly before the default repo check, which ensures
"*"bypasses all other validation. Consider documenting the implication: whentarget-repois"*", the agent must always supply arepofield — otherwiseresolveAndValidateRepowill receive"*"as the repo string and emit an "Invalid repository format" error (verified by the new test inupdate_handler_factory.test.cjs). A short JSDoc comment here would make that contract explicit.