{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.SecurityHub.Types.Vulnerability where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.Cvss
import Amazonka.SecurityHub.Types.SoftwarePackage
import Amazonka.SecurityHub.Types.VulnerabilityVendor
data Vulnerability = Vulnerability'
{
Vulnerability -> Maybe VulnerabilityVendor
vendor :: Prelude.Maybe VulnerabilityVendor,
Vulnerability -> Maybe [Text]
relatedVulnerabilities :: Prelude.Maybe [Prelude.Text],
Vulnerability -> Maybe [SoftwarePackage]
vulnerablePackages :: Prelude.Maybe [SoftwarePackage],
Vulnerability -> Maybe [Text]
referenceUrls :: Prelude.Maybe [Prelude.Text],
Vulnerability -> Maybe [Cvss]
cvss :: Prelude.Maybe [Cvss],
Vulnerability -> Text
id :: Prelude.Text
}
deriving (Vulnerability -> Vulnerability -> Bool
(Vulnerability -> Vulnerability -> Bool)
-> (Vulnerability -> Vulnerability -> Bool) -> Eq Vulnerability
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Vulnerability -> Vulnerability -> Bool
$c/= :: Vulnerability -> Vulnerability -> Bool
== :: Vulnerability -> Vulnerability -> Bool
$c== :: Vulnerability -> Vulnerability -> Bool
Prelude.Eq, ReadPrec [Vulnerability]
ReadPrec Vulnerability
Int -> ReadS Vulnerability
ReadS [Vulnerability]
(Int -> ReadS Vulnerability)
-> ReadS [Vulnerability]
-> ReadPrec Vulnerability
-> ReadPrec [Vulnerability]
-> Read Vulnerability
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Vulnerability]
$creadListPrec :: ReadPrec [Vulnerability]
readPrec :: ReadPrec Vulnerability
$creadPrec :: ReadPrec Vulnerability
readList :: ReadS [Vulnerability]
$creadList :: ReadS [Vulnerability]
readsPrec :: Int -> ReadS Vulnerability
$creadsPrec :: Int -> ReadS Vulnerability
Prelude.Read, Int -> Vulnerability -> ShowS
[Vulnerability] -> ShowS
Vulnerability -> String
(Int -> Vulnerability -> ShowS)
-> (Vulnerability -> String)
-> ([Vulnerability] -> ShowS)
-> Show Vulnerability
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Vulnerability] -> ShowS
$cshowList :: [Vulnerability] -> ShowS
show :: Vulnerability -> String
$cshow :: Vulnerability -> String
showsPrec :: Int -> Vulnerability -> ShowS
$cshowsPrec :: Int -> Vulnerability -> ShowS
Prelude.Show, (forall x. Vulnerability -> Rep Vulnerability x)
-> (forall x. Rep Vulnerability x -> Vulnerability)
-> Generic Vulnerability
forall x. Rep Vulnerability x -> Vulnerability
forall x. Vulnerability -> Rep Vulnerability x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Vulnerability x -> Vulnerability
$cfrom :: forall x. Vulnerability -> Rep Vulnerability x
Prelude.Generic)
newVulnerability ::
Prelude.Text ->
Vulnerability
newVulnerability :: Text -> Vulnerability
newVulnerability Text
pId_ =
Vulnerability' :: Maybe VulnerabilityVendor
-> Maybe [Text]
-> Maybe [SoftwarePackage]
-> Maybe [Text]
-> Maybe [Cvss]
-> Text
-> Vulnerability
Vulnerability'
{ $sel:vendor:Vulnerability' :: Maybe VulnerabilityVendor
vendor = Maybe VulnerabilityVendor
forall a. Maybe a
Prelude.Nothing,
$sel:relatedVulnerabilities:Vulnerability' :: Maybe [Text]
relatedVulnerabilities = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:vulnerablePackages:Vulnerability' :: Maybe [SoftwarePackage]
vulnerablePackages = Maybe [SoftwarePackage]
forall a. Maybe a
Prelude.Nothing,
$sel:referenceUrls:Vulnerability' :: Maybe [Text]
referenceUrls = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:cvss:Vulnerability' :: Maybe [Cvss]
cvss = Maybe [Cvss]
forall a. Maybe a
Prelude.Nothing,
$sel:id:Vulnerability' :: Text
id = Text
pId_
}
vulnerability_vendor :: Lens.Lens' Vulnerability (Prelude.Maybe VulnerabilityVendor)
vulnerability_vendor :: (Maybe VulnerabilityVendor -> f (Maybe VulnerabilityVendor))
-> Vulnerability -> f Vulnerability
vulnerability_vendor = (Vulnerability -> Maybe VulnerabilityVendor)
-> (Vulnerability -> Maybe VulnerabilityVendor -> Vulnerability)
-> Lens
Vulnerability
Vulnerability
(Maybe VulnerabilityVendor)
(Maybe VulnerabilityVendor)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Vulnerability' {Maybe VulnerabilityVendor
vendor :: Maybe VulnerabilityVendor
$sel:vendor:Vulnerability' :: Vulnerability -> Maybe VulnerabilityVendor
vendor} -> Maybe VulnerabilityVendor
vendor) (\s :: Vulnerability
s@Vulnerability' {} Maybe VulnerabilityVendor
a -> Vulnerability
s {$sel:vendor:Vulnerability' :: Maybe VulnerabilityVendor
vendor = Maybe VulnerabilityVendor
a} :: Vulnerability)
vulnerability_relatedVulnerabilities :: Lens.Lens' Vulnerability (Prelude.Maybe [Prelude.Text])
vulnerability_relatedVulnerabilities :: (Maybe [Text] -> f (Maybe [Text]))
-> Vulnerability -> f Vulnerability
vulnerability_relatedVulnerabilities = (Vulnerability -> Maybe [Text])
-> (Vulnerability -> Maybe [Text] -> Vulnerability)
-> Lens Vulnerability Vulnerability (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Vulnerability' {Maybe [Text]
relatedVulnerabilities :: Maybe [Text]
$sel:relatedVulnerabilities:Vulnerability' :: Vulnerability -> Maybe [Text]
relatedVulnerabilities} -> Maybe [Text]
relatedVulnerabilities) (\s :: Vulnerability
s@Vulnerability' {} Maybe [Text]
a -> Vulnerability
s {$sel:relatedVulnerabilities:Vulnerability' :: Maybe [Text]
relatedVulnerabilities = Maybe [Text]
a} :: Vulnerability) ((Maybe [Text] -> f (Maybe [Text]))
-> Vulnerability -> f Vulnerability)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Vulnerability
-> f Vulnerability
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
vulnerability_vulnerablePackages :: Lens.Lens' Vulnerability (Prelude.Maybe [SoftwarePackage])
vulnerability_vulnerablePackages :: (Maybe [SoftwarePackage] -> f (Maybe [SoftwarePackage]))
-> Vulnerability -> f Vulnerability
vulnerability_vulnerablePackages = (Vulnerability -> Maybe [SoftwarePackage])
-> (Vulnerability -> Maybe [SoftwarePackage] -> Vulnerability)
-> Lens
Vulnerability
Vulnerability
(Maybe [SoftwarePackage])
(Maybe [SoftwarePackage])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Vulnerability' {Maybe [SoftwarePackage]
vulnerablePackages :: Maybe [SoftwarePackage]
$sel:vulnerablePackages:Vulnerability' :: Vulnerability -> Maybe [SoftwarePackage]
vulnerablePackages} -> Maybe [SoftwarePackage]
vulnerablePackages) (\s :: Vulnerability
s@Vulnerability' {} Maybe [SoftwarePackage]
a -> Vulnerability
s {$sel:vulnerablePackages:Vulnerability' :: Maybe [SoftwarePackage]
vulnerablePackages = Maybe [SoftwarePackage]
a} :: Vulnerability) ((Maybe [SoftwarePackage] -> f (Maybe [SoftwarePackage]))
-> Vulnerability -> f Vulnerability)
-> ((Maybe [SoftwarePackage] -> f (Maybe [SoftwarePackage]))
-> Maybe [SoftwarePackage] -> f (Maybe [SoftwarePackage]))
-> (Maybe [SoftwarePackage] -> f (Maybe [SoftwarePackage]))
-> Vulnerability
-> f Vulnerability
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[SoftwarePackage]
[SoftwarePackage]
[SoftwarePackage]
[SoftwarePackage]
-> Iso
(Maybe [SoftwarePackage])
(Maybe [SoftwarePackage])
(Maybe [SoftwarePackage])
(Maybe [SoftwarePackage])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
[SoftwarePackage]
[SoftwarePackage]
[SoftwarePackage]
[SoftwarePackage]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
vulnerability_referenceUrls :: Lens.Lens' Vulnerability (Prelude.Maybe [Prelude.Text])
vulnerability_referenceUrls :: (Maybe [Text] -> f (Maybe [Text]))
-> Vulnerability -> f Vulnerability
vulnerability_referenceUrls = (Vulnerability -> Maybe [Text])
-> (Vulnerability -> Maybe [Text] -> Vulnerability)
-> Lens Vulnerability Vulnerability (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Vulnerability' {Maybe [Text]
referenceUrls :: Maybe [Text]
$sel:referenceUrls:Vulnerability' :: Vulnerability -> Maybe [Text]
referenceUrls} -> Maybe [Text]
referenceUrls) (\s :: Vulnerability
s@Vulnerability' {} Maybe [Text]
a -> Vulnerability
s {$sel:referenceUrls:Vulnerability' :: Maybe [Text]
referenceUrls = Maybe [Text]
a} :: Vulnerability) ((Maybe [Text] -> f (Maybe [Text]))
-> Vulnerability -> f Vulnerability)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Vulnerability
-> f Vulnerability
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
vulnerability_cvss :: Lens.Lens' Vulnerability (Prelude.Maybe [Cvss])
vulnerability_cvss :: (Maybe [Cvss] -> f (Maybe [Cvss]))
-> Vulnerability -> f Vulnerability
vulnerability_cvss = (Vulnerability -> Maybe [Cvss])
-> (Vulnerability -> Maybe [Cvss] -> Vulnerability)
-> Lens Vulnerability Vulnerability (Maybe [Cvss]) (Maybe [Cvss])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Vulnerability' {Maybe [Cvss]
cvss :: Maybe [Cvss]
$sel:cvss:Vulnerability' :: Vulnerability -> Maybe [Cvss]
cvss} -> Maybe [Cvss]
cvss) (\s :: Vulnerability
s@Vulnerability' {} Maybe [Cvss]
a -> Vulnerability
s {$sel:cvss:Vulnerability' :: Maybe [Cvss]
cvss = Maybe [Cvss]
a} :: Vulnerability) ((Maybe [Cvss] -> f (Maybe [Cvss]))
-> Vulnerability -> f Vulnerability)
-> ((Maybe [Cvss] -> f (Maybe [Cvss]))
-> Maybe [Cvss] -> f (Maybe [Cvss]))
-> (Maybe [Cvss] -> f (Maybe [Cvss]))
-> Vulnerability
-> f Vulnerability
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Cvss] [Cvss] [Cvss] [Cvss]
-> Iso (Maybe [Cvss]) (Maybe [Cvss]) (Maybe [Cvss]) (Maybe [Cvss])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Cvss] [Cvss] [Cvss] [Cvss]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
vulnerability_id :: Lens.Lens' Vulnerability Prelude.Text
vulnerability_id :: (Text -> f Text) -> Vulnerability -> f Vulnerability
vulnerability_id = (Vulnerability -> Text)
-> (Vulnerability -> Text -> Vulnerability)
-> Lens Vulnerability Vulnerability Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Vulnerability' {Text
id :: Text
$sel:id:Vulnerability' :: Vulnerability -> Text
id} -> Text
id) (\s :: Vulnerability
s@Vulnerability' {} Text
a -> Vulnerability
s {$sel:id:Vulnerability' :: Text
id = Text
a} :: Vulnerability)
instance Core.FromJSON Vulnerability where
parseJSON :: Value -> Parser Vulnerability
parseJSON =
String
-> (Object -> Parser Vulnerability)
-> Value
-> Parser Vulnerability
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Vulnerability"
( \Object
x ->
Maybe VulnerabilityVendor
-> Maybe [Text]
-> Maybe [SoftwarePackage]
-> Maybe [Text]
-> Maybe [Cvss]
-> Text
-> Vulnerability
Vulnerability'
(Maybe VulnerabilityVendor
-> Maybe [Text]
-> Maybe [SoftwarePackage]
-> Maybe [Text]
-> Maybe [Cvss]
-> Text
-> Vulnerability)
-> Parser (Maybe VulnerabilityVendor)
-> Parser
(Maybe [Text]
-> Maybe [SoftwarePackage]
-> Maybe [Text]
-> Maybe [Cvss]
-> Text
-> Vulnerability)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe VulnerabilityVendor)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Vendor")
Parser
(Maybe [Text]
-> Maybe [SoftwarePackage]
-> Maybe [Text]
-> Maybe [Cvss]
-> Text
-> Vulnerability)
-> Parser (Maybe [Text])
-> Parser
(Maybe [SoftwarePackage]
-> Maybe [Text] -> Maybe [Cvss] -> Text -> Vulnerability)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RelatedVulnerabilities"
Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
)
Parser
(Maybe [SoftwarePackage]
-> Maybe [Text] -> Maybe [Cvss] -> Text -> Vulnerability)
-> Parser (Maybe [SoftwarePackage])
-> Parser (Maybe [Text] -> Maybe [Cvss] -> Text -> Vulnerability)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [SoftwarePackage]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"VulnerablePackages"
Parser (Maybe (Maybe [SoftwarePackage]))
-> Maybe [SoftwarePackage] -> Parser (Maybe [SoftwarePackage])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [SoftwarePackage]
forall a. Monoid a => a
Prelude.mempty
)
Parser (Maybe [Text] -> Maybe [Cvss] -> Text -> Vulnerability)
-> Parser (Maybe [Text])
-> Parser (Maybe [Cvss] -> Text -> Vulnerability)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ReferenceUrls" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
Parser (Maybe [Cvss] -> Text -> Vulnerability)
-> Parser (Maybe [Cvss]) -> Parser (Text -> Vulnerability)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Cvss]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Cvss" Parser (Maybe (Maybe [Cvss]))
-> Maybe [Cvss] -> Parser (Maybe [Cvss])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Cvss]
forall a. Monoid a => a
Prelude.mempty)
Parser (Text -> Vulnerability)
-> Parser Text -> Parser Vulnerability
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Id")
)
instance Prelude.Hashable Vulnerability
instance Prelude.NFData Vulnerability
instance Core.ToJSON Vulnerability where
toJSON :: Vulnerability -> Value
toJSON Vulnerability' {Maybe [Text]
Maybe [Cvss]
Maybe [SoftwarePackage]
Maybe VulnerabilityVendor
Text
id :: Text
cvss :: Maybe [Cvss]
referenceUrls :: Maybe [Text]
vulnerablePackages :: Maybe [SoftwarePackage]
relatedVulnerabilities :: Maybe [Text]
vendor :: Maybe VulnerabilityVendor
$sel:id:Vulnerability' :: Vulnerability -> Text
$sel:cvss:Vulnerability' :: Vulnerability -> Maybe [Cvss]
$sel:referenceUrls:Vulnerability' :: Vulnerability -> Maybe [Text]
$sel:vulnerablePackages:Vulnerability' :: Vulnerability -> Maybe [SoftwarePackage]
$sel:relatedVulnerabilities:Vulnerability' :: Vulnerability -> Maybe [Text]
$sel:vendor:Vulnerability' :: Vulnerability -> Maybe VulnerabilityVendor
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Vendor" Text -> VulnerabilityVendor -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (VulnerabilityVendor -> Pair)
-> Maybe VulnerabilityVendor -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VulnerabilityVendor
vendor,
(Text
"RelatedVulnerabilities" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
relatedVulnerabilities,
(Text
"VulnerablePackages" Text -> [SoftwarePackage] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
([SoftwarePackage] -> Pair)
-> Maybe [SoftwarePackage] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [SoftwarePackage]
vulnerablePackages,
(Text
"ReferenceUrls" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
referenceUrls,
(Text
"Cvss" Text -> [Cvss] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Cvss] -> Pair) -> Maybe [Cvss] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Cvss]
cvss,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id)
]
)