From cf4f7215f8d8ef83fb1bbb01c9aa832078dada16 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone <exarkun@twistedmatrix.com> Date: Wed, 7 Jun 2023 14:55:11 -0400 Subject: [PATCH] add ConfidentialShowable class for things holding secrets --- src/Tahoe/Capability.hs | 6 +++++- src/Tahoe/Capability/Internal/Confidential.hs | 12 ++++++++++++ tahoe-capabilities.cabal | 10 +++++++--- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 src/Tahoe/Capability/Internal/Confidential.hs diff --git a/src/Tahoe/Capability.hs b/src/Tahoe/Capability.hs index d1393bb..747f7a9 100644 --- a/src/Tahoe/Capability.hs +++ b/src/Tahoe/Capability.hs @@ -1 +1,5 @@ -module Tahoe.Capability where +module Tahoe.Capability ( + module Tahoe.Capability.Internal.Confidential, +) where + +import Tahoe.Capability.Internal.Confidential (ConfidentialShowable (..)) diff --git a/src/Tahoe/Capability/Internal/Confidential.hs b/src/Tahoe/Capability/Internal/Confidential.hs new file mode 100644 index 0000000..e6664c5 --- /dev/null +++ b/src/Tahoe/Capability/Internal/Confidential.hs @@ -0,0 +1,12 @@ +module Tahoe.Capability.Internal.Confidential where + +import qualified Data.Text as T + +{- | Something which contains confidential information and can be rendered as + text such that the text also includes confidential information. It is + expected (but not required) that such types will also have a Show instance + which obscures the confidential information. +-} +class ConfidentialShowable s where + -- | Show the value, including any confidential information. + confidentiallyShow :: s -> T.Text diff --git a/tahoe-capabilities.cabal b/tahoe-capabilities.cabal index d73684e..7af4ce9 100644 --- a/tahoe-capabilities.cabal +++ b/tahoe-capabilities.cabal @@ -64,7 +64,9 @@ library import: warnings -- Modules exported by the library. - exposed-modules: Tahoe.Capability + exposed-modules: + Tahoe.Capability + Tahoe.Capability.Internal.Confidential -- Modules included in this library but not exported. -- other-modules: @@ -73,7 +75,9 @@ library -- other-extensions: -- Other library packages from which modules are imported. - build-depends: base ^>=4.14.3.0 + build-depends: + , base + , text -- Directories containing source files. hs-source-dirs: src @@ -105,5 +109,5 @@ test-suite tahoe-capabilities-test -- Test dependencies. build-depends: - , base ^>=4.14.3.0 + , base , tahoe-capabilities -- GitLab