Giter VIP home page Giter VIP logo

Comments (5)

tony-iqlusion avatar tony-iqlusion commented on June 12, 2024

Thanks for reporting this.

For context: one of the goals of this crate (which could definitely be better documented) is preventing accidental secret leakage through mechanisms such as Debug logging.

To enforce that concern, DebugSecret::debug_secret presently returns a &static str.

I think you're right that having DebugSecret contingent on Vec<S> where S: DebugSecret is not ideal. I think instead of asking the downstream type to opt into DebugSecret, instead the type signature for DebugSecret::debug_secret could be changed to use const fn, which would uphold the same invariant of no data-dependent debug logging, but in a way that's more flexible than a &'static str.

By leveraging const fn, a DebugSecret impl on Vec<S> could incorporate the core::any::type_name of S.

Is that what you'd ultimately like for debugging information? If so, it seems possible.

from crates.

ionut-arm avatar ionut-arm commented on June 12, 2024

That definitely sounds like a sensible solution that would solve our problem.

Is that what you'd ultimately like for debugging information? If so, it seems possible.

Actually, it's not really debugging that I'm interested in, but serialization. However, Serialize and Deserialize are tied to DebugSecret, and thus my request :) I should've mentioned that previously.

We're trying to protect a secret while working with it in memory, but to also be able to serialize it at the right point. Don't know if that would be better achieved through other means, like exposing the contents of the secret and then serializing, but it feels more error-prone.

from crates.

tony-iqlusion avatar tony-iqlusion commented on June 12, 2024

You might take a look at the docs for SerializableSecret:

https://docs.rs/secrecy/0.6.0/secrecy/trait.SerializableSecret.html

...which, upon further inspection, does not appear to be properly used in the bounds for the Serialize impl on Secret (!)

To prevent accidental exfiltration of secrets, SerializableSecret was supposed to act as a marker trait, and one deliberately not impl'd for SecretVec.

The alternatives are:

  1. Make your own newtype that wraps Vec<_> (of whatever type you're interested in)
  2. Use serde's serialize_with as noted in the SerializableSecret docs.

All that said, it seems this crate could use a little work and documentation improvements. Hopefully I'll have time to make a pass over it in the next few days to clear some of that up and fix the issues brought up here.

from crates.

ionut-arm avatar ionut-arm commented on June 12, 2024

Thanks for pointing that out! For some reason I was completely blind to the existence of SerializableSecret in the crate...

I'll probably go down the route of using serialize_with, seems more idiomatic.

from crates.

tony-iqlusion avatar tony-iqlusion commented on June 12, 2024

#463 should address the issues with the trait bounds: serde serialization is no longer bounded by DebugSecret.

from crates.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.