boulder/core
Aaron Gable 96f9bfaab8
Fix IsAnyNilOrZero to correctly handle all numeric types (#5096)
The previous implementation of `IsAnyNilOrZero` did not in fact work,
and its tests did not catch this fact. Within the numeric clause, the
compiler would only instantiate the comparison literal 0 to be one
of the eight possible types. Comparisons against any of the other
seven types would always be false, no matter what value that type
held.

The tests did not catch this because they only tested two literal
values: `0` and `-12.345`, both of which can be `float64`s.

This change updates the utility function to use the `reflect` package,
to ensure that it works correctly. It also updates the test to test
multiple different kinds of numeric values, and removes the code
for handling pointer-to- types, as all of our proto2 code has been
removed.

Finally, it updates the SA wrapper's `RevokeCertificate` method to
correctly not require that `req.Reason` be non-zero: this field can
and often is zero, as that value represents `Unspecified`.

Using the reflect package is a conscious tradeoff. It will be slower
than manually writing out every single case, but it will also be less
prone to error.

Part of #5097
2020-09-23 09:01:20 -07:00
..
proto core: move to proto3 (#5063) 2020-08-31 17:58:32 -07:00
challenges.go Introduce new core.AcmeChallenge type (#5012) 2020-08-11 15:02:16 -07:00
challenges_test.go Make authz2 the default storage format (#4476) 2019-10-21 15:29:15 -04:00
core_test.go Introduce new core.AcmeChallenge type (#5012) 2020-08-11 15:02:16 -07:00
interfaces.go Introduce new core.AcmeChallenge type (#5012) 2020-08-11 15:02:16 -07:00
objects.go Introduce new core.AcmeChallenge type (#5012) 2020-08-11 15:02:16 -07:00
objects_test.go Introduce new core.AcmeChallenge type (#5012) 2020-08-11 15:02:16 -07:00
util.go Fix IsAnyNilOrZero to correctly handle all numeric types (#5096) 2020-09-23 09:01:20 -07:00
util_test.go Fix IsAnyNilOrZero to correctly handle all numeric types (#5096) 2020-09-23 09:01:20 -07:00