Potential fix for code scanning alert no. 2: Clear-text storage of sensitive information #6
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.
Potential fix for https://github.com/venkateshpabbati/adk-python/security/code-scanning/2
General fix:
To ensure that no sensitive or potentially sensitive information from user prompts is inadvertently written to the
.envfile, we should restrict the cleartext contents of that file to strictly non-sensitive configuration. Specifically, only include information that is not secret (such as generic flags or non-sensitive identifiers), and strictly avoid writing API keys, credentials, or potentially sensitive user input. Additionally, if there is any doubt about information sensitivity, default to not writing it, and update documentation and onscreen messages to remind users how and where to set required secrets.Detailed fix:
_generate_files, make sure that the lines written to.envonly include non-sensitive settings. Project and region names, while not as sensitive as API keys, should be handled per organizational standards. The existing code already avoids writing the API key, but we can reinforce this by refactoring the block to:GOOGLE_GENAI_USE_VERTEXAIto.env.GOOGLE_CLOUD_PROJECTandGOOGLE_CLOUD_LOCATIONas well, replacing this with a message instructing the user to set them as environment variables. This maximizes security and is consistent with the handling ofGOOGLE_API_KEY.Code changes required:
src/google/adk/cli/cli_create.py, lines associated with writing"GOOGLE_CLOUD_PROJECT=..."and"GOOGLE_CLOUD_LOCATION=..."should be commented or removed (lines 198–200).GOOGLE_GENAI_USE_VERTEXAI=0or=1is written to the.envfile.Suggested fixes powered by Copilot Autofix. Review carefully before merging.