fix(quota): enforce.ts não fail-open em limite 0/negativo/não-finito (hardening do #4830) - #4866
Closed
diegosouzapw wants to merge 119 commits into
Closed
diegosouzapw wants to merge 119 commits into
diegosouzapw wants to merge 119 commits into
Conversation
…ease-acceleration) (#4857) * feat(quality): add check:test-runner-api gate (vitest-only dirs must use vitest API) * feat(release): reusable CHANGELOG i18n-mirror sync script * chore(ops): add prune-stale-worktrees.sh (dry-run by default) * ci(quality): run test-runner-api + docs-all + vitest + full unit suite on PR->release fast-path --------- Co-authored-by: Diego Rodrigues de Sa e Souza <souzamiriamrodrigues790@gmail.com>
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…rough (port from 9router#1157) (#4624) Integrated into release/v3.8.36 — port (rebuilt from stale base; defining commit cherry-picked clean over release tip, release-green validated)
…rmat providers (#4625) Integrated into release/v3.8.36 — port (rebuilt from stale base; defining commit cherry-picked clean over release tip, release-green validated)
…ocks (#4633) Integrated into release/v3.8.36 — port (rebuilt from stale base; defining commit cherry-picked clean over release tip, release-green validated)
…thropic providers (#4650) Integrated into release/v3.8.36 — port (rebuilt from stale base; defining commit cherry-picked clean over release tip, release-green validated)
…4651) Integrated into release/v3.8.36 — port (rebuilt from stale base; defining commit cherry-picked clean over release tip, release-green validated)
Integrated into release/v3.8.36 — port (rebuilt from stale base; defining commit cherry-picked clean over release tip, release-green validated)
…4656) Integrated into release/v3.8.36 — port (rebuilt from stale base; defining commit cherry-picked clean over release tip, release-green validated)
…ttings (#4659) Integrated into release/v3.8.36 — port (rebuilt from stale base; defining commit cherry-picked clean over release tip, release-green validated)
) (#4629) Integrated into release/v3.8.36 — kiro region SSRF guard (GHSA-6mwv-4mrm-5p3m), port rebuilt clean over release tip
Integrated into release/v3.8.36
…usage.ts (#4950) Integrated into release/v3.8.36
Integrated into release/v3.8.36
…4735) Integrated into release/v3.8.36
…4860) Integrated into release/v3.8.36
…4905) Integrated into release/v3.8.36
…4946) Integrated into release/v3.8.36
Integrated into release/v3.8.36
Integrated into release/v3.8.36
Integrated into release/v3.8.36
Integrated into release/v3.8.36
…ay-name (#4961) Integrated into release/v3.8.36
…ld OOM) (#4968) Integrated into release/v3.8.36 — fixes build OOM (optimizePackageImports open-sse)
Integrated into release/v3.8.36
…ariante A) (#4967) Integrated into release/v3.8.36
…(hardening)
O guard de placeholder usava `!(dim.limit > Number.EPSILON)`, que pulava o
enforcement para QUALQUER limite <= EPSILON — incluindo um 0 configurado
("bloquear tudo") e valores negativos (config corrompida). Isso é um fail-open:
uma dimensão de cota que o operador setou para 0/negativo para negar tráfego
liberava silenciosamente todas as requests.
Aperta o skip para igualdade exata com o ÚNICO placeholder semeado
(`=== Number.EPSILON`, glm/minimax/kimi-coding/deepseek em planRegistry.ts).
Agora 0 e negativo fluem para decideFairShare e são enforçados (block
global-saturated); apenas limites não-finitos (NaN/Infinity — nem armazenáveis
via provider_plans JSON) são pulados, e com warn-log para tornar o bypass
observável em vez de silencioso.
TDD: tests/unit/quota-enforce-misconfigured-limit-blocks.test.ts — limit=0 e
limit=-100 agora retornam block (antes: allow); o teste do placeholder EPSILON
(quota-epsilon-unconfigured-allow) continua verde.
Finding de revisão de segurança automatizada (MEDIUM, fail-open/control
regression) sobre o #4830.
diegosouzapw
force-pushed
the
fix/quota-enforce-fail-open-hardening
branch
from
June 24, 2026 23:00
5968a56 to
4fdf68e
Compare
Owner
Author
|
Fechando como duplicata. O commit definidor desta branch ( |
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.
Contexto
Hardening de segurança em
src/lib/quota/enforce.ts, sobre o código mergeado no #4830. Uma revisão de segurança automatizada apontou um fail-open / control regression (MEDIUM) no guard de placeholder de cota.Problema
Esse predicado pulava o enforcement para qualquer
limit <= EPSILON, não só o placeholder documentado. Consequências:limit = 0(um operador configurando "bloquear tudo" no Wizard "Limite") → era silenciosamente liberado (fail-open).limitnegativo (config corrompida) → também pulado (fail-open).NaN/Infinity→ pulado silenciosamente.Apenas
Number.EPSILONé o placeholder real semeado emplanRegistry.ts(glm/minimax/kimi-coding/deepseek = "configurar manualmente"). O predicado era largo demais.Correção
Number.EPSILON— o único valor placeholder semeado.0e negativo passam a ser enforçados (deny).0= "bloquear tudo"; negativo = fail-closed.NaN/Infinity(nem armazenáveis viaprovider_plansJSON) continuam pulados, mas com warn-log → bypass observável em vez de silencioso.Validação (Hard Rule #18 — TDD)
tests/unit/quota-enforce-misconfigured-limit-blocks.test.ts(failing-then-passing):limit=0→ block (antes:allow)limit=-100→ block (antes:allow)Regressão preservada:
quota-epsilon-unconfigured-allow(EPSILON segue liberado),quota-division-blocks(enforcement de limite real),quota-enforce/quota-fair-share(19/19),quota-exclusive-catalog-4806(#4806). typecheck:core limpo, lint 0, file-size OK.