Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protosanitizer: handle secrets in oneof and maps, gRPC-style output #5

Closed
wants to merge 2 commits into from

Commits on Dec 7, 2018

  1. protosanitizer: handle secrets in oneof and maps

    As expected, oneof wasn't supported so far and requires special code:
    - JSON naming is not defined in Go structs and thus inconsistent with
      protobuf
    - JSON and Go struct are nested, protobuf fields aren't
    
    For maps from plain type to a message, the messages were not filtered.
    
    Because the nesting got a bit deep with support for both added, the
    code now avoids nesting by aborting the flow in `if` cases with
    continue or return and continuing unindented after that.
    
    Everything that could cause a panic gets checked, which protects
    against malformed protobuf data but should never trigger in
    practice. To determine where an assumption gets violated, strip() now
    returns an error and wraps that with pkg.errors, which eventually gets
    reports in the resulting string. This is similar to how fmt.Sprintf
    handles parameter errors.
    pohly committed Dec 7, 2018
    Configuration menu
    Copy the full SHA
    8ddc271 View commit details
    Browse the repository at this point in the history
  2. protosanitizer: nicer marshaling of stripped messages

    The output is now closer to the original marshaling done by gRPC:
    - no distracting quotation marks around field names
    - angle brackets for structs and maps
    
    Some differences are intentional to increase readability:
    - no redundant space after the last element in a struct or map
    - square brackets around arrays
    
    One remaining drawback is the loss of the original field ordering.
    Elements are now sorted alphabetically because the conversion into the
    generic data structure via json.Marshal/Unmarshal drops the ordering
    when converting to a map.
    pohly committed Dec 7, 2018
    Configuration menu
    Copy the full SHA
    e1b57dc View commit details
    Browse the repository at this point in the history