fix(database): mask SSH tunnel credentials explicitly on read paths#41293
fix(database): mask SSH tunnel credentials explicitly on read paths#41293rusackas wants to merge 1 commit into
Conversation
The SSH tunnel credential fields (password, private_key, private_key_password) are masked on the write paths (POST/PUT) via mask_password_info(), but the read paths (GET /<pk> and GET /<pk>/connection) attached SSHTunnel.data directly, relying solely on the model property to mask. Apply mask_password_info() on the read paths too so the masking contract is enforced consistently at the API boundary and is robust to future changes in SSHTunnel.data. Adds an integration test asserting the three credential fields are masked on both read paths while the stored values remain intact. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Code Review Agent Run #157feeActionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #41293 +/- ##
=======================================
Coverage 64.34% 64.35%
=======================================
Files 2653 2653
Lines 144952 144952
Branches 33433 33433
=======================================
+ Hits 93272 93284 +12
+ Misses 49996 49976 -20
- Partials 1684 1692 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
SUMMARY
SSH tunnel credential fields (
password,private_key,private_key_password) are masked on the database write paths (POST/PUT) viamask_password_info(). On the read paths —GET /api/v1/database/<pk>andGET /api/v1/database/<pk>/connection— the response attacheddatabase.ssh_tunnel.datadirectly, relying solely on theSSHTunnel.dataproperty to mask those fields.This applies
mask_password_info()explicitly on the read paths as well, so the masking contract is enforced at the API boundary consistently with the write paths and is robust to any future change inSSHTunnel.data. Masking is idempotent, so this is safe alongside the property's existing behavior.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend serialization behavior.
TESTING INSTRUCTIONS
Added
test_get_database_ssh_tunnel_credentials_are_maskedintests/integration_tests/databases/api_tests.py:password,private_key, andprivate_key_password.XXXXXXXXXX) on bothGET /<pk>andGET /<pk>/connection.Run:
pytest tests/integration_tests/databases/api_tests.py -k ssh_tunnelADDITIONAL INFORMATION