Skip to content

fix: correct regex replacement logic in SecretsRedactor::redactEnvVars#6

Open
insign wants to merge 1 commit into
mainfrom
fix-secrets-redactor-regex-1892792159717856155
Open

fix: correct regex replacement logic in SecretsRedactor::redactEnvVars#6
insign wants to merge 1 commit into
mainfrom
fix-secrets-redactor-regex-1892792159717856155

Conversation

@insign
Copy link
Copy Markdown
Contributor

@insign insign commented May 14, 2026

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_replace redundantes e problemáticas na hora de ocultar segredos. A primeira substituição modificava incorretamente a chave da variável para algo como RCLONE_RCLONE_PASSWORD=secret=[REDACTED]. Embora a segunda preg_replace tentasse "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ógica preg_replace incorreta e preservada a correta.

Testes:
Foi validado localmente com scripts de teste. Os testes no phpunit mantiveram 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 .md foi 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

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>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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.

1 participant