Skip to content

Commit 6d43230

Browse files
authored
fix(security): do not log merged repo settings dict (may contain secrets) (#2505)
apply_repo_settings() logged the full merged Dynaconf dict at INFO, which can include secrets from a repo/global .pr_agent.toml (e.g. openai.key, gitlab.personal_access_token), leaking them into CI/server logs. Log only the merged section names, matching the extra-config path in the same file.
1 parent 3ee267c commit 6d43230

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

pr_agent/git_providers/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,13 @@ def apply_repo_settings(pr_url):
341341
# Same precedence-restoration rationale as the extra-config
342342
# path: env-sourced values must remain the highest layer.
343343
_reapply_env_overrides()
344-
get_logger().info(f"Applying repo settings:\n{new_settings.as_dict()}")
344+
# Do NOT log the merged dict: repo/global .pr_agent.toml may contain secrets
345+
# (e.g. openai.key, gitlab.personal_access_token) that would otherwise leak into
346+
# CI logs. Section names are safe and sufficient for debugging (same rationale as
347+
# the extra-config path above).
348+
get_logger().info(
349+
f"Applying repo settings (sections: {sorted(new_settings.as_dict().keys())})"
350+
)
345351
except Exception as e:
346352
get_logger().warning(f"Failed to apply repo {category} settings, error: {str(e)}")
347353
error_local = {'error': str(e), 'settings': repo_settings, 'category': category}

0 commit comments

Comments
 (0)