-
- Downloads
Catch Errors in Download process and only write error message (#47482)
* walk the error to remove any visualization settings Thanks Dan for the patch, this approach is nice because it doesn't require changing all 3 streaming-response-writer implementations (json csv and xlsx). It keeps behaviour basically the same, but just cleans up the output to not include potentially sensitive column/dataset details. * add a test that confirms json/csv errors are cleaned * walk the error to remove any visualization settings Thanks Dan for the patch, this approach is nice because it doesn't require changing all 3 streaming-response-writer implementations (json csv and xlsx). It keeps behaviour basically the same, but just cleans up the output to not include potentially sensitive column/dataset details. * add a test that confirms json/csv errors are cleaned * fix dataset error test * cljfmt * try to be a little more surgical with what we take out of the error * formatting again, oops * pass export format, only modify the obj for file exports In the case of errors being saved to files, the obj is a map with a :status :failed key assoc'd by the qp somewhere along the way. The format-exception cond branch is not used in this case, so we can't rely on modifying `format-exception` to just dissoc ex-data. Instead, I've kept the obj modification, but it excludes the query and the preprocessed keys, which are the only 2 keys where we see :viz-settings. This doesn't eliminate the problem of needing to exclude other keys in the future, but it does improve the surface area - the query and viz settings are the most likely candidates for holding potentially sensitive info. I'd prefer to stick with this solution, as we can get a fix for the security concern in quicker, and perhaps a non-security bug can be opened regarding the most correct way to indicate errors to users whose downloads have failed. * keep format-exception the same * cleaner passing of export-format to write-error!
Showing
- src/metabase/async/streaming_response.clj 15 additions, 5 deletionssrc/metabase/async/streaming_response.clj
- src/metabase/query_processor/streaming.clj 1 addition, 1 deletionsrc/metabase/query_processor/streaming.clj
- test/metabase/api/downloads_exports_test.clj 41 additions, 0 deletionstest/metabase/api/downloads_exports_test.clj
- test/metabase/query_processor/streaming/csv_test.clj 22 additions, 1 deletiontest/metabase/query_processor/streaming/csv_test.clj
Please register or sign in to comment