fix: correct regex replacement logic in SecretsRedactor::redactEnvVars#6
fix: correct regex replacement logic in SecretsRedactor::redactEnvVars#6insign wants to merge 1 commit into
Conversation
The previous implementation of `SecretsRedactor::redactEnvVars` used two sequential `preg_replace` calls to redact secrets from environment variables. The first call incorrectly used `RCLONE_$0=` in its replacement string, which matched the entire `RCLONE_CONFIG_MYREMOTE_TOKEN=secret` and substituted it with `RCLONE_RCLONE_CONFIG_MYREMOTE_TOKEN=secret=[REDACTED]`. This mangled the environment variable key. This commit simplifies the logic to a single pass that correctly uses capture groups to preserve the variable name (`$1`) while replacing the value with `[REDACTED]`. Co-authored-by: insign <1113045+insign@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
A melhoria escolhida foi a correção de um bug de substituição no redator de segredos
SecretsRedactor::redactEnvVars(na categoria Correção de bugs / Segurança).Por que agrega valor:
A implementação anterior usava duas chamadas
preg_replaceredundantes e problemáticas na hora de ocultar segredos. A primeira substituição modificava incorretamente a chave da variável para algo comoRCLONE_RCLONE_PASSWORD=secret=[REDACTED]. Embora a segundapreg_replacetentasse "mascarar" o valor, a chave continuava corrompida. Isso geraria logs de depuração quebrados. Com a correção, a string original de variável (a chave) é preservada perfeitamente através de grupos de captura, enquanto o valor sensível é mascarado.Arquivos alterados:
src/SecretsRedactor.php: Removida a lógicapreg_replaceincorreta e preservada a correta.Testes:
Foi validado localmente com scripts de teste. Os testes no
phpunitmantiveram sucesso em todos os casos relevantes. Nenhum teste anterior foi quebrado por essa correção de string de log.Mudanças em arquivos
.md:Nenhum arquivo
.mdfoi atualizado pois não houve mudança de comportamento do sistema, mas sim correção de como a string é mascarada sem quebrar a chave da variável. O comportamento desejado documentado continua intacto.PR created automatically by Jules for task 1892792159717856155 started by @insign