Repository navigation
fix(trainer): redact provider API keys in config.json and summary.json - #454
Open
ni (nniiovoo) wants to merge 1 commit into
Open
ni (nniiovoo) wants to merge 1 commit into
ni (nniiovoo) wants to merge 1 commit into
Conversation
_redact_cfg only masked azure_api_key, api_key and openai_api_key, but the config stores credentials as azure_openai_api_key, qwen_chat_api_key, minimax_api_key, openai_compatible_api_key and the role-specific Azure, Qwen and OpenAI-compatible keys. A key set in the YAML or with --cfg-options was written to the run folder in plaintext, including the copy load_config makes of a legacy azure_api_key. A key is now masked when its name is in the existing set or ends in api_key, api-key, token, secret or password, the suffixes scripts/train.py already treats as credentials, also inside a nested section that flattening keeps as-is. Fixes microsoft#453 Signed-off-by: NNIIOVO <haimingni44@gmail.com>
This branch has not been deployed
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.
Fixes #453
_redact_cfgonly maskedazure_api_key,api_keyandopenai_api_key. But the config stores credentials asazure_openai_api_key,qwen_chat_api_key,minimax_api_key,openai_compatible_api_keyand the role-specific Azure, Qwen and OpenAI-compatible keys. So a key set in the YAML or with--cfg-optionswas written to the run folder in plaintext. That included the copyload_configmakes of a legacyazure_api_key.A key is now masked when its name is in the existing set or ends in
api_key,api-key,token,secretorpassword.scripts/train.pyalready treats those suffixes as credentials when it checks--cfg-options. The same rule applies inside a section that flattening keeps as-is, such as--cfg-options gateway.api_key=.... Only the copies written to disk are masked; the config the run uses is unchanged.Tests: new
tests/test_trainer_config_redaction.py. All 4 tests fail on main.out_root.load_configwith--azure_api_keyand checks that the alias copy is masked.token/secret/passwordsuffixes while budgets likemax_completion_tokensstay as they are.Full suite on macOS: 2435 passed. The 2 failures in
tests/test_sleep_adopt_skill_subset.pyalso fail on main.