Skip to content

fix: scope push approvals to repository and branch (sfind-51d7a881) - #30

Open
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/sfind-51d7a881-push-id-repo-branch-scope
Open

devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/sfind-51d7a881-push-id-repo-branch-scope

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

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.setCommit gerava action.id = ${commitFrom}__${commitTo}. writeAudit faz upsert por esse id e checkIfWaitingAuth fazia getPush(action.id); se o registro estivesse authorised, substituía a action atual e chamava setAllowPush(). Assim, um range aprovado em acme/sandbox também liberava o mesmo range enviado para acme/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)}. setBranch recalcula o id se o range de commits já estiver definido (parsePush define action.branch antes de setCommit, 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 se url e branch do registro forem iguais aos do push que está chegando (o range original já está no id; commitFrom não é comparado porque parsePush o reescreve em branches novas a partir da ordem do pack).

⚠️ Mudança de contrato de API: o formato do id do push muda. Ele aparece nas rotas /api/v1/push/:id (authorise/reject/cancel), na URL do dashboard /dashboard/push/:id mostrada no git push e no nome do diretório proxyGitPath. 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.ts
  • Manual: aprove um push do range A..B no 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 em testActionId.test.ts) falham no main (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 de node_modules (vitest 3.0.6) porque o registry npm está bloqueado no ambiente; por isso não rodei a suíte completa, npm run lint nem npm run check-types localmente (o tsc isolado dos arquivos alterados só reclamou de express ausente). Fica para o CI.

Related Issue

Code scan finding sfind-51d7a88168d74ce48d79f0c9e0a80c43 (scan scan-70082f73b42b43fda8ae0a7ecbe7fedf).

Checklist

General

Documentation

  • Documentation has been added/updated for any new features

Configuration

  • If configuration schema (config.schema.json) was modified: N/A

Tests

  • Tests have been added/updated for new functionality
  • Unit tests pass (npm test) — só os arquivos afetados localmente; suíte completa no CI
  • Linting and formatting pass (npm run lint and npm run format:check) — prettier ok nos arquivos alterados
  • Type checks pass (npm run check-types) — no CI

Devin-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

Status Commit
⚪ Not started —

Run Devin Review

Enable auto-review to review your pull requests automatically.

Devin Review (Staging)


Devin Review

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>
@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

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>
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants