Repository navigation
fix: scope push approvals to repository and branch (sfind-51d7a881) - #30
Open
devin-ai-integration[bot] wants to merge 2 commits into
Open
devin-ai-integration[bot] wants to merge 2 commits into
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
The push id was built only from commitFrom__commitTo, and checkIfWaitingAuth reused any authorised record found under that id. An approval for a commit range on one repository or branch therefore also allowed the same range to be pushed to a different repository or branch without a second review. - Action.setCommit/setBranch now build the id as commitFrom__commitTo__sha256(url + '\\n' + branch). - checkIfWaitingAuth only reuses an approval when url, branch, commitFrom and commitTo all match the incoming push. Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Author
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
The push id already encodes the ref update's original old/new commits. parsePush rewrites commitFrom for new branches from pack order, so comparing it could reject a legitimate re-push of an approved range. Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Corrige o finding de code scan sfind-51d7a881 (severidade média): uma aprovação de push podia ser reaproveitada em outro repositório ou branch, porque o id do push não tinha componente de repositório.
Contexto:
Action.setCommitgeravaaction.id = ${commitFrom}__${commitTo}.writeAuditfaz upsert por esse id echeckIfWaitingAuthfaziagetPush(action.id); se o registro estivesseauthorised, substituía a action atual e chamavasetAllowPush(). Assim, um range aprovado emacme/sandboxtambém liberava o mesmo range enviado paraacme/payments(ou para outra branch), sem uma segunda aprovação, e o registro de auditoria apontava para o repositório errado.Mudanças:
src/proxy/actions/Action.ts: o id passa a ser${commitFrom}__${commitTo}__${sha256(url + '\n' + branch)}.setBranchrecalcula o id se o range de commits já estiver definido (parsePushdefineaction.branchantes desetCommit, então o caminho atual já gera o id com escopo).src/proxy/processors/push-action/checkIfWaitingAuth.ts: defesa em profundidade. Só reaproveita a aprovação seurlebranchdo registro forem iguais aos do push que está chegando (o range original já está no id;commitFromnão é comparado porqueparsePusho reescreve em branches novas a partir da ordem do pack)./api/v1/push/:id(authorise/reject/cancel), na URL do dashboard/dashboard/push/:idmostrada nogit pushe no nome do diretórioproxyGitPath. O id continua sendo uma string opaca (nada no código faz parse de__), mas pushes que estavam pendentes ou aprovados e ainda não reenviados antes do deploy vão gerar um id novo no próximo push e precisar de nova aprovação.Como testar:
npx vitest --run test/testActionId.test.ts test/processors/checkIfWaitingAuth.test.ts test/testParsePush.test.tsA..Bno repositório X; envie o mesmo range para o repositório Y (ou outra branch de X) e confirme que ele fica aguardando aprovação própria em vez de ser liberado. Reenviar para X/mesma branch continua sendo liberado.Verificação feita: os testes novos (3 em
checkIfWaitingAuth.test.ts, 4 emtestActionId.test.ts) falham nomain(6 de 12 falhando) e passam com a correção (12/12).testParsePush.test.ts: 47/47. Prettier ok. Rodei com uma cópia emprestada denode_modules(vitest 3.0.6) porque o registry npm está bloqueado no ambiente; por isso não rodei a suíte completa,npm run lintnemnpm run check-typeslocalmente (o tsc isolado dos arquivos alterados só reclamou deexpressausente). Fica para o CI.Related Issue
Code scan finding
sfind-51d7a88168d74ce48d79f0c9e0a80c43(scanscan-70082f73b42b43fda8ae0a7ecbe7fedf).Checklist
General
Documentation
Configuration
config.schema.json) was modified: N/ATests
npm test) — só os arquivos afetados localmente; suíte completa no CInpm run lintandnpm run format:check) — prettier ok nos arquivos alteradosnpm run check-types) — no CIDevin-Org: engineering
Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/a2136e3cc3f84913854980e02641fa6e
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/a2136e3cc3f84913854980e02641fa6e?variant=devin
Devin Review