Potential fix for code scanning alert no. 3: Clear-text logging of sensitive information #15
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/sandialabs/VISTA/security/code-scanning/3
To fix this problem, we must ensure that no sensitive data or untrusted user-supplied content is logged in clear text. That means:
create_api_keyanddeactivate_api_keyoperations, sanitize or eliminate logging of user-supplied fields inadditional_info(e.g., do not logapi_key.name). Log only safe, pre-reviewed constants such as the user ID (which is already a UUID and not PII), and the fact an operation occurred.Required changes:
crud.create_api_key: update the call tolog_db_operationto not include the user-supplied API key name. Log only theuser_id(already a UUID), or removeadditional_infoentirely.crud.deactivate_api_key: the call tolog_db_operationonly logs{ "deactivated": True }, which is fine.log_db_operation: optionally, add a security comment to indicate thatadditional_infomust never include sensitive/user-supplied values; validate or sanitize as an extra layer if desired.No new methods or imports are needed; the change is limited to the removal/editing of logging of untrusted content.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.