moov-io / iso8583

A golang implementation to marshal and unmarshal iso8583 message.
https://moov.io
Apache License 2.0
353 stars 105 forks source link

Wrap errors from external libraries to prevent leaking sensitive information #185

Closed cheukwing closed 2 years ago

cheukwing commented 2 years ago

Resolves #103

Introduce a SafeError type (credits to @alovak for the idea!) which is used to wrap around external errors, preventing the returned error message from displaying sensitive information, while still allowing errors to be matched. Use this new error type to wrap external errors in the field and encoding packages, as these operate on the potentially sensitive data.

I considered also wrapping external errors in the prefix and network packages, but since these only operate on the length part of the data, exposing their details should be okay (as long as the message is correctly formatted).

codecov-commenter commented 2 years ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 51.85185% with 26 lines in your changes missing coverage. Please review.

Project coverage is 70.91%. Comparing base (92f3b34) to head (dd4a723). Report is 120 commits behind head on master.

Files with missing lines Patch % Lines
field/binary.go 28.57% 4 Missing and 1 partial :warning:
field/composite.go 33.33% 3 Missing and 1 partial :warning:
utils/safe_error.go 60.00% 4 Missing :warning:
field/numeric.go 50.00% 2 Missing and 1 partial :warning:
field/string.go 40.00% 2 Missing and 1 partial :warning:
message.go 40.00% 2 Missing and 1 partial :warning:
specs/builder.go 0.00% 2 Missing :warning:
encoding/hex.go 75.00% 1 Missing :warning:
field/ordered_map.go 0.00% 1 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #185 +/- ## ========================================== + Coverage 70.50% 70.91% +0.41% ========================================== Files 37 38 +1 Lines 1773 1798 +25 ========================================== + Hits 1250 1275 +25 - Misses 334 336 +2 + Partials 189 187 -2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.