Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions hackage-security/hackage-security.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cabal-version: 1.12
name: hackage-security
version: 0.6.0.1
x-revision: 9

synopsis: Hackage security library
description: The hackage security library provides both server and
Expand Down Expand Up @@ -110,13 +111,13 @@ library
Hackage.Security.Util.TypedEmbedded
Prelude
-- We support ghc 7.4 (bundled with Cabal 1.14) and up
build-depends: base >= 4.5 && < 4.15,
build-depends: base >= 4.5 && < 4.17,
base16-bytestring >= 0.1.1 && < 1.1,
base64-bytestring >= 1.0 && < 1.3,
bytestring >= 0.9 && < 0.12,
Cabal >= 1.14 && < 1.26
|| >= 2.0 && < 2.6
|| >= 3.0 && < 3.4,
|| >= 3.0 && < 3.8,
containers >= 0.4 && < 0.7,
ed25519 >= 0.0 && < 0.1,
filepath >= 1.2 && < 1.5,
Expand All @@ -126,8 +127,8 @@ library
-- 0.4.2 introduces TarIndex, 0.4.4 introduces more
-- functionality, 0.5.0 changes type of serialise
tar >= 0.5 && < 0.6,
template-haskell >= 2.7 && < 2.17,
time >= 1.2 && < 1.10,
template-haskell >= 2.7 && < 2.19,
time >= 1.2 && < 1.13,
transformers >= 0.3 && < 0.6,
zlib >= 0.5 && < 0.7,
-- whatever versions are bundled with ghc:
Expand Down Expand Up @@ -252,21 +253,18 @@ test-suite TestSuite
Cabal,
containers,
bytestring,
network-uri,
tar,
text,
time,
zlib

if flag(use-network-uri)
build-depends: network-uri
else
build-depends: network

-- dependencies exclusive to test-suite
build-depends: tasty == 1.2.*,
build-depends: tasty == 1.2.* || == 1.3.*,
tasty-hunit == 0.10.*,
tasty-quickcheck == 0.10.*,
QuickCheck >= 2.11 && <2.14,
aeson == 1.4.*,
QuickCheck >= 2.11 && <2.15,
aeson == 1.4.* || == 1.5.*,
vector == 0.12.*,
unordered-containers >=0.2.8.0 && <0.3,
temporary >= 1.2 && < 1.4
Expand Down
10 changes: 8 additions & 2 deletions hackage-security/tests/TestSuite/JSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import Data.String (fromString)
import qualified Data.Vector as V
import qualified Data.HashMap.Strict as HM

-- text
import qualified Data.Text as Text

prop_aeson_canonical, prop_roundtrip_canonical, prop_roundtrip_pretty, prop_canonical_pretty
:: JSValue -> Bool

Expand All @@ -48,16 +51,19 @@ canonicalise (JSArray vs) = JSArray [ canonicalise v | v <- vs]
canonicalise (JSObject vs) = JSObject [ (k, canonicalise v)
| (k,v) <- sortBy (compare `on` fst) vs ]

sanitizeString :: String -> String
sanitizeString s = Text.unpack (Text.replace (Text.pack "\\") (Text.pack "\\\\") (Text.pack (show s)))

instance Arbitrary JSValue where
arbitrary =
sized $ \sz ->
frequency
[ (1, pure JSNull)
, (1, JSBool <$> arbitrary)
, (2, JSNum <$> arbitrary)
, (2, JSString . getASCIIString <$> arbitrary)
, (2, JSString . sanitizeString . getASCIIString <$> arbitrary)
, (3, JSArray <$> resize (sz `div` 2) arbitrary)
, (3, JSObject . mapFirst getASCIIString . noDupFields <$> resize (sz `div` 2) arbitrary)
, (3, JSObject . mapFirst (sanitizeString . getASCIIString) . noDupFields <$> resize (sz `div` 2) arbitrary)
]
where
noDupFields = nubBy (\(x,_) (y,_) -> x==y)
Expand Down