{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.ECR.Types.ImageScanFinding
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ECR.Types.ImageScanFinding where

import qualified Amazonka.Core as Core
import Amazonka.ECR.Types.Attribute
import Amazonka.ECR.Types.FindingSeverity
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about an image scan finding.
--
-- /See:/ 'newImageScanFinding' smart constructor.
data ImageScanFinding = ImageScanFinding'
  { -- | The finding severity.
    ImageScanFinding -> Maybe FindingSeverity
severity :: Prelude.Maybe FindingSeverity,
    -- | A link containing additional details about the security vulnerability.
    ImageScanFinding -> Maybe Text
uri :: Prelude.Maybe Prelude.Text,
    -- | The name associated with the finding, usually a CVE number.
    ImageScanFinding -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A collection of attributes of the host from which the finding is
    -- generated.
    ImageScanFinding -> Maybe [Attribute]
attributes :: Prelude.Maybe [Attribute],
    -- | The description of the finding.
    ImageScanFinding -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (ImageScanFinding -> ImageScanFinding -> Bool
(ImageScanFinding -> ImageScanFinding -> Bool)
-> (ImageScanFinding -> ImageScanFinding -> Bool)
-> Eq ImageScanFinding
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImageScanFinding -> ImageScanFinding -> Bool
$c/= :: ImageScanFinding -> ImageScanFinding -> Bool
== :: ImageScanFinding -> ImageScanFinding -> Bool
$c== :: ImageScanFinding -> ImageScanFinding -> Bool
Prelude.Eq, ReadPrec [ImageScanFinding]
ReadPrec ImageScanFinding
Int -> ReadS ImageScanFinding
ReadS [ImageScanFinding]
(Int -> ReadS ImageScanFinding)
-> ReadS [ImageScanFinding]
-> ReadPrec ImageScanFinding
-> ReadPrec [ImageScanFinding]
-> Read ImageScanFinding
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImageScanFinding]
$creadListPrec :: ReadPrec [ImageScanFinding]
readPrec :: ReadPrec ImageScanFinding
$creadPrec :: ReadPrec ImageScanFinding
readList :: ReadS [ImageScanFinding]
$creadList :: ReadS [ImageScanFinding]
readsPrec :: Int -> ReadS ImageScanFinding
$creadsPrec :: Int -> ReadS ImageScanFinding
Prelude.Read, Int -> ImageScanFinding -> ShowS
[ImageScanFinding] -> ShowS
ImageScanFinding -> String
(Int -> ImageScanFinding -> ShowS)
-> (ImageScanFinding -> String)
-> ([ImageScanFinding] -> ShowS)
-> Show ImageScanFinding
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImageScanFinding] -> ShowS
$cshowList :: [ImageScanFinding] -> ShowS
show :: ImageScanFinding -> String
$cshow :: ImageScanFinding -> String
showsPrec :: Int -> ImageScanFinding -> ShowS
$cshowsPrec :: Int -> ImageScanFinding -> ShowS
Prelude.Show, (forall x. ImageScanFinding -> Rep ImageScanFinding x)
-> (forall x. Rep ImageScanFinding x -> ImageScanFinding)
-> Generic ImageScanFinding
forall x. Rep ImageScanFinding x -> ImageScanFinding
forall x. ImageScanFinding -> Rep ImageScanFinding x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImageScanFinding x -> ImageScanFinding
$cfrom :: forall x. ImageScanFinding -> Rep ImageScanFinding x
Prelude.Generic)

-- |
-- Create a value of 'ImageScanFinding' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'severity', 'imageScanFinding_severity' - The finding severity.
--
-- 'uri', 'imageScanFinding_uri' - A link containing additional details about the security vulnerability.
--
-- 'name', 'imageScanFinding_name' - The name associated with the finding, usually a CVE number.
--
-- 'attributes', 'imageScanFinding_attributes' - A collection of attributes of the host from which the finding is
-- generated.
--
-- 'description', 'imageScanFinding_description' - The description of the finding.
newImageScanFinding ::
  ImageScanFinding
newImageScanFinding :: ImageScanFinding
newImageScanFinding =
  ImageScanFinding' :: Maybe FindingSeverity
-> Maybe Text
-> Maybe Text
-> Maybe [Attribute]
-> Maybe Text
-> ImageScanFinding
ImageScanFinding'
    { $sel:severity:ImageScanFinding' :: Maybe FindingSeverity
severity = Maybe FindingSeverity
forall a. Maybe a
Prelude.Nothing,
      $sel:uri:ImageScanFinding' :: Maybe Text
uri = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ImageScanFinding' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:attributes:ImageScanFinding' :: Maybe [Attribute]
attributes = Maybe [Attribute]
forall a. Maybe a
Prelude.Nothing,
      $sel:description:ImageScanFinding' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The finding severity.
imageScanFinding_severity :: Lens.Lens' ImageScanFinding (Prelude.Maybe FindingSeverity)
imageScanFinding_severity :: (Maybe FindingSeverity -> f (Maybe FindingSeverity))
-> ImageScanFinding -> f ImageScanFinding
imageScanFinding_severity = (ImageScanFinding -> Maybe FindingSeverity)
-> (ImageScanFinding -> Maybe FindingSeverity -> ImageScanFinding)
-> Lens
     ImageScanFinding
     ImageScanFinding
     (Maybe FindingSeverity)
     (Maybe FindingSeverity)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageScanFinding' {Maybe FindingSeverity
severity :: Maybe FindingSeverity
$sel:severity:ImageScanFinding' :: ImageScanFinding -> Maybe FindingSeverity
severity} -> Maybe FindingSeverity
severity) (\s :: ImageScanFinding
s@ImageScanFinding' {} Maybe FindingSeverity
a -> ImageScanFinding
s {$sel:severity:ImageScanFinding' :: Maybe FindingSeverity
severity = Maybe FindingSeverity
a} :: ImageScanFinding)

-- | A link containing additional details about the security vulnerability.
imageScanFinding_uri :: Lens.Lens' ImageScanFinding (Prelude.Maybe Prelude.Text)
imageScanFinding_uri :: (Maybe Text -> f (Maybe Text))
-> ImageScanFinding -> f ImageScanFinding
imageScanFinding_uri = (ImageScanFinding -> Maybe Text)
-> (ImageScanFinding -> Maybe Text -> ImageScanFinding)
-> Lens ImageScanFinding ImageScanFinding (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageScanFinding' {Maybe Text
uri :: Maybe Text
$sel:uri:ImageScanFinding' :: ImageScanFinding -> Maybe Text
uri} -> Maybe Text
uri) (\s :: ImageScanFinding
s@ImageScanFinding' {} Maybe Text
a -> ImageScanFinding
s {$sel:uri:ImageScanFinding' :: Maybe Text
uri = Maybe Text
a} :: ImageScanFinding)

-- | The name associated with the finding, usually a CVE number.
imageScanFinding_name :: Lens.Lens' ImageScanFinding (Prelude.Maybe Prelude.Text)
imageScanFinding_name :: (Maybe Text -> f (Maybe Text))
-> ImageScanFinding -> f ImageScanFinding
imageScanFinding_name = (ImageScanFinding -> Maybe Text)
-> (ImageScanFinding -> Maybe Text -> ImageScanFinding)
-> Lens ImageScanFinding ImageScanFinding (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageScanFinding' {Maybe Text
name :: Maybe Text
$sel:name:ImageScanFinding' :: ImageScanFinding -> Maybe Text
name} -> Maybe Text
name) (\s :: ImageScanFinding
s@ImageScanFinding' {} Maybe Text
a -> ImageScanFinding
s {$sel:name:ImageScanFinding' :: Maybe Text
name = Maybe Text
a} :: ImageScanFinding)

-- | A collection of attributes of the host from which the finding is
-- generated.
imageScanFinding_attributes :: Lens.Lens' ImageScanFinding (Prelude.Maybe [Attribute])
imageScanFinding_attributes :: (Maybe [Attribute] -> f (Maybe [Attribute]))
-> ImageScanFinding -> f ImageScanFinding
imageScanFinding_attributes = (ImageScanFinding -> Maybe [Attribute])
-> (ImageScanFinding -> Maybe [Attribute] -> ImageScanFinding)
-> Lens
     ImageScanFinding
     ImageScanFinding
     (Maybe [Attribute])
     (Maybe [Attribute])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageScanFinding' {Maybe [Attribute]
attributes :: Maybe [Attribute]
$sel:attributes:ImageScanFinding' :: ImageScanFinding -> Maybe [Attribute]
attributes} -> Maybe [Attribute]
attributes) (\s :: ImageScanFinding
s@ImageScanFinding' {} Maybe [Attribute]
a -> ImageScanFinding
s {$sel:attributes:ImageScanFinding' :: Maybe [Attribute]
attributes = Maybe [Attribute]
a} :: ImageScanFinding) ((Maybe [Attribute] -> f (Maybe [Attribute]))
 -> ImageScanFinding -> f ImageScanFinding)
-> ((Maybe [Attribute] -> f (Maybe [Attribute]))
    -> Maybe [Attribute] -> f (Maybe [Attribute]))
-> (Maybe [Attribute] -> f (Maybe [Attribute]))
-> ImageScanFinding
-> f ImageScanFinding
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Attribute] [Attribute] [Attribute] [Attribute]
-> Iso
     (Maybe [Attribute])
     (Maybe [Attribute])
     (Maybe [Attribute])
     (Maybe [Attribute])
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 [Attribute] [Attribute] [Attribute] [Attribute]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The description of the finding.
imageScanFinding_description :: Lens.Lens' ImageScanFinding (Prelude.Maybe Prelude.Text)
imageScanFinding_description :: (Maybe Text -> f (Maybe Text))
-> ImageScanFinding -> f ImageScanFinding
imageScanFinding_description = (ImageScanFinding -> Maybe Text)
-> (ImageScanFinding -> Maybe Text -> ImageScanFinding)
-> Lens ImageScanFinding ImageScanFinding (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageScanFinding' {Maybe Text
description :: Maybe Text
$sel:description:ImageScanFinding' :: ImageScanFinding -> Maybe Text
description} -> Maybe Text
description) (\s :: ImageScanFinding
s@ImageScanFinding' {} Maybe Text
a -> ImageScanFinding
s {$sel:description:ImageScanFinding' :: Maybe Text
description = Maybe Text
a} :: ImageScanFinding)

instance Core.FromJSON ImageScanFinding where
  parseJSON :: Value -> Parser ImageScanFinding
parseJSON =
    String
-> (Object -> Parser ImageScanFinding)
-> Value
-> Parser ImageScanFinding
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ImageScanFinding"
      ( \Object
x ->
          Maybe FindingSeverity
-> Maybe Text
-> Maybe Text
-> Maybe [Attribute]
-> Maybe Text
-> ImageScanFinding
ImageScanFinding'
            (Maybe FindingSeverity
 -> Maybe Text
 -> Maybe Text
 -> Maybe [Attribute]
 -> Maybe Text
 -> ImageScanFinding)
-> Parser (Maybe FindingSeverity)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe [Attribute]
      -> Maybe Text
      -> ImageScanFinding)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe FindingSeverity)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"severity")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe [Attribute]
   -> Maybe Text
   -> ImageScanFinding)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe [Attribute] -> Maybe Text -> ImageScanFinding)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"uri")
            Parser
  (Maybe Text -> Maybe [Attribute] -> Maybe Text -> ImageScanFinding)
-> Parser (Maybe Text)
-> Parser (Maybe [Attribute] -> Maybe Text -> ImageScanFinding)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"name")
            Parser (Maybe [Attribute] -> Maybe Text -> ImageScanFinding)
-> Parser (Maybe [Attribute])
-> Parser (Maybe Text -> ImageScanFinding)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Attribute]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"attributes" Parser (Maybe (Maybe [Attribute]))
-> Maybe [Attribute] -> Parser (Maybe [Attribute])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Attribute]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> ImageScanFinding)
-> Parser (Maybe Text) -> Parser ImageScanFinding
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"description")
      )

instance Prelude.Hashable ImageScanFinding

instance Prelude.NFData ImageScanFinding