{-# 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.SecurityHub.Types.ProcessDetails
-- 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.SecurityHub.Types.ProcessDetails where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The details of process-related information about a finding.
--
-- /See:/ 'newProcessDetails' smart constructor.
data ProcessDetails = ProcessDetails'
  { -- | The path to the process executable.
    ProcessDetails -> Maybe Text
path :: Prelude.Maybe Prelude.Text,
    -- | The name of the process.
    ProcessDetails -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The process ID.
    ProcessDetails -> Maybe Int
pid :: Prelude.Maybe Prelude.Int,
    -- | Indicates when the process was terminated.
    --
    -- Uses the @date-time@ format specified in
    -- <https://tools.ietf.org/html/rfc3339#section-5.6 RFC 3339 section 5.6, Internet Date\/Time Format>.
    -- The value cannot contain spaces. For example,
    -- @2020-03-22T13:22:13.933Z@.
    ProcessDetails -> Maybe Text
terminatedAt :: Prelude.Maybe Prelude.Text,
    -- | The parent process ID.
    ProcessDetails -> Maybe Int
parentPid :: Prelude.Maybe Prelude.Int,
    -- | Indicates when the process was launched.
    --
    -- Uses the @date-time@ format specified in
    -- <https://tools.ietf.org/html/rfc3339#section-5.6 RFC 3339 section 5.6, Internet Date\/Time Format>.
    -- The value cannot contain spaces. For example,
    -- @2020-03-22T13:22:13.933Z@.
    ProcessDetails -> Maybe Text
launchedAt :: Prelude.Maybe Prelude.Text
  }
  deriving (ProcessDetails -> ProcessDetails -> Bool
(ProcessDetails -> ProcessDetails -> Bool)
-> (ProcessDetails -> ProcessDetails -> Bool) -> Eq ProcessDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProcessDetails -> ProcessDetails -> Bool
$c/= :: ProcessDetails -> ProcessDetails -> Bool
== :: ProcessDetails -> ProcessDetails -> Bool
$c== :: ProcessDetails -> ProcessDetails -> Bool
Prelude.Eq, ReadPrec [ProcessDetails]
ReadPrec ProcessDetails
Int -> ReadS ProcessDetails
ReadS [ProcessDetails]
(Int -> ReadS ProcessDetails)
-> ReadS [ProcessDetails]
-> ReadPrec ProcessDetails
-> ReadPrec [ProcessDetails]
-> Read ProcessDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProcessDetails]
$creadListPrec :: ReadPrec [ProcessDetails]
readPrec :: ReadPrec ProcessDetails
$creadPrec :: ReadPrec ProcessDetails
readList :: ReadS [ProcessDetails]
$creadList :: ReadS [ProcessDetails]
readsPrec :: Int -> ReadS ProcessDetails
$creadsPrec :: Int -> ReadS ProcessDetails
Prelude.Read, Int -> ProcessDetails -> ShowS
[ProcessDetails] -> ShowS
ProcessDetails -> String
(Int -> ProcessDetails -> ShowS)
-> (ProcessDetails -> String)
-> ([ProcessDetails] -> ShowS)
-> Show ProcessDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProcessDetails] -> ShowS
$cshowList :: [ProcessDetails] -> ShowS
show :: ProcessDetails -> String
$cshow :: ProcessDetails -> String
showsPrec :: Int -> ProcessDetails -> ShowS
$cshowsPrec :: Int -> ProcessDetails -> ShowS
Prelude.Show, (forall x. ProcessDetails -> Rep ProcessDetails x)
-> (forall x. Rep ProcessDetails x -> ProcessDetails)
-> Generic ProcessDetails
forall x. Rep ProcessDetails x -> ProcessDetails
forall x. ProcessDetails -> Rep ProcessDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProcessDetails x -> ProcessDetails
$cfrom :: forall x. ProcessDetails -> Rep ProcessDetails x
Prelude.Generic)

-- |
-- Create a value of 'ProcessDetails' 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:
--
-- 'path', 'processDetails_path' - The path to the process executable.
--
-- 'name', 'processDetails_name' - The name of the process.
--
-- 'pid', 'processDetails_pid' - The process ID.
--
-- 'terminatedAt', 'processDetails_terminatedAt' - Indicates when the process was terminated.
--
-- Uses the @date-time@ format specified in
-- <https://tools.ietf.org/html/rfc3339#section-5.6 RFC 3339 section 5.6, Internet Date\/Time Format>.
-- The value cannot contain spaces. For example,
-- @2020-03-22T13:22:13.933Z@.
--
-- 'parentPid', 'processDetails_parentPid' - The parent process ID.
--
-- 'launchedAt', 'processDetails_launchedAt' - Indicates when the process was launched.
--
-- Uses the @date-time@ format specified in
-- <https://tools.ietf.org/html/rfc3339#section-5.6 RFC 3339 section 5.6, Internet Date\/Time Format>.
-- The value cannot contain spaces. For example,
-- @2020-03-22T13:22:13.933Z@.
newProcessDetails ::
  ProcessDetails
newProcessDetails :: ProcessDetails
newProcessDetails =
  ProcessDetails' :: Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe Int
-> Maybe Text
-> ProcessDetails
ProcessDetails'
    { $sel:path:ProcessDetails' :: Maybe Text
path = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ProcessDetails' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:pid:ProcessDetails' :: Maybe Int
pid = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:terminatedAt:ProcessDetails' :: Maybe Text
terminatedAt = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:parentPid:ProcessDetails' :: Maybe Int
parentPid = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:launchedAt:ProcessDetails' :: Maybe Text
launchedAt = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The path to the process executable.
processDetails_path :: Lens.Lens' ProcessDetails (Prelude.Maybe Prelude.Text)
processDetails_path :: (Maybe Text -> f (Maybe Text))
-> ProcessDetails -> f ProcessDetails
processDetails_path = (ProcessDetails -> Maybe Text)
-> (ProcessDetails -> Maybe Text -> ProcessDetails)
-> Lens ProcessDetails ProcessDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessDetails' {Maybe Text
path :: Maybe Text
$sel:path:ProcessDetails' :: ProcessDetails -> Maybe Text
path} -> Maybe Text
path) (\s :: ProcessDetails
s@ProcessDetails' {} Maybe Text
a -> ProcessDetails
s {$sel:path:ProcessDetails' :: Maybe Text
path = Maybe Text
a} :: ProcessDetails)

-- | The name of the process.
processDetails_name :: Lens.Lens' ProcessDetails (Prelude.Maybe Prelude.Text)
processDetails_name :: (Maybe Text -> f (Maybe Text))
-> ProcessDetails -> f ProcessDetails
processDetails_name = (ProcessDetails -> Maybe Text)
-> (ProcessDetails -> Maybe Text -> ProcessDetails)
-> Lens ProcessDetails ProcessDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessDetails' {Maybe Text
name :: Maybe Text
$sel:name:ProcessDetails' :: ProcessDetails -> Maybe Text
name} -> Maybe Text
name) (\s :: ProcessDetails
s@ProcessDetails' {} Maybe Text
a -> ProcessDetails
s {$sel:name:ProcessDetails' :: Maybe Text
name = Maybe Text
a} :: ProcessDetails)

-- | The process ID.
processDetails_pid :: Lens.Lens' ProcessDetails (Prelude.Maybe Prelude.Int)
processDetails_pid :: (Maybe Int -> f (Maybe Int)) -> ProcessDetails -> f ProcessDetails
processDetails_pid = (ProcessDetails -> Maybe Int)
-> (ProcessDetails -> Maybe Int -> ProcessDetails)
-> Lens ProcessDetails ProcessDetails (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessDetails' {Maybe Int
pid :: Maybe Int
$sel:pid:ProcessDetails' :: ProcessDetails -> Maybe Int
pid} -> Maybe Int
pid) (\s :: ProcessDetails
s@ProcessDetails' {} Maybe Int
a -> ProcessDetails
s {$sel:pid:ProcessDetails' :: Maybe Int
pid = Maybe Int
a} :: ProcessDetails)

-- | Indicates when the process was terminated.
--
-- Uses the @date-time@ format specified in
-- <https://tools.ietf.org/html/rfc3339#section-5.6 RFC 3339 section 5.6, Internet Date\/Time Format>.
-- The value cannot contain spaces. For example,
-- @2020-03-22T13:22:13.933Z@.
processDetails_terminatedAt :: Lens.Lens' ProcessDetails (Prelude.Maybe Prelude.Text)
processDetails_terminatedAt :: (Maybe Text -> f (Maybe Text))
-> ProcessDetails -> f ProcessDetails
processDetails_terminatedAt = (ProcessDetails -> Maybe Text)
-> (ProcessDetails -> Maybe Text -> ProcessDetails)
-> Lens ProcessDetails ProcessDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessDetails' {Maybe Text
terminatedAt :: Maybe Text
$sel:terminatedAt:ProcessDetails' :: ProcessDetails -> Maybe Text
terminatedAt} -> Maybe Text
terminatedAt) (\s :: ProcessDetails
s@ProcessDetails' {} Maybe Text
a -> ProcessDetails
s {$sel:terminatedAt:ProcessDetails' :: Maybe Text
terminatedAt = Maybe Text
a} :: ProcessDetails)

-- | The parent process ID.
processDetails_parentPid :: Lens.Lens' ProcessDetails (Prelude.Maybe Prelude.Int)
processDetails_parentPid :: (Maybe Int -> f (Maybe Int)) -> ProcessDetails -> f ProcessDetails
processDetails_parentPid = (ProcessDetails -> Maybe Int)
-> (ProcessDetails -> Maybe Int -> ProcessDetails)
-> Lens ProcessDetails ProcessDetails (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessDetails' {Maybe Int
parentPid :: Maybe Int
$sel:parentPid:ProcessDetails' :: ProcessDetails -> Maybe Int
parentPid} -> Maybe Int
parentPid) (\s :: ProcessDetails
s@ProcessDetails' {} Maybe Int
a -> ProcessDetails
s {$sel:parentPid:ProcessDetails' :: Maybe Int
parentPid = Maybe Int
a} :: ProcessDetails)

-- | Indicates when the process was launched.
--
-- Uses the @date-time@ format specified in
-- <https://tools.ietf.org/html/rfc3339#section-5.6 RFC 3339 section 5.6, Internet Date\/Time Format>.
-- The value cannot contain spaces. For example,
-- @2020-03-22T13:22:13.933Z@.
processDetails_launchedAt :: Lens.Lens' ProcessDetails (Prelude.Maybe Prelude.Text)
processDetails_launchedAt :: (Maybe Text -> f (Maybe Text))
-> ProcessDetails -> f ProcessDetails
processDetails_launchedAt = (ProcessDetails -> Maybe Text)
-> (ProcessDetails -> Maybe Text -> ProcessDetails)
-> Lens ProcessDetails ProcessDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessDetails' {Maybe Text
launchedAt :: Maybe Text
$sel:launchedAt:ProcessDetails' :: ProcessDetails -> Maybe Text
launchedAt} -> Maybe Text
launchedAt) (\s :: ProcessDetails
s@ProcessDetails' {} Maybe Text
a -> ProcessDetails
s {$sel:launchedAt:ProcessDetails' :: Maybe Text
launchedAt = Maybe Text
a} :: ProcessDetails)

instance Core.FromJSON ProcessDetails where
  parseJSON :: Value -> Parser ProcessDetails
parseJSON =
    String
-> (Object -> Parser ProcessDetails)
-> Value
-> Parser ProcessDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ProcessDetails"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe Int
-> Maybe Text
-> ProcessDetails
ProcessDetails'
            (Maybe Text
 -> Maybe Text
 -> Maybe Int
 -> Maybe Text
 -> Maybe Int
 -> Maybe Text
 -> ProcessDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Int
      -> Maybe Text
      -> Maybe Int
      -> Maybe Text
      -> ProcessDetails)
forall (f :: * -> *) a b. Functor 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
"Path")
            Parser
  (Maybe Text
   -> Maybe Int
   -> Maybe Text
   -> Maybe Int
   -> Maybe Text
   -> ProcessDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe Int
      -> Maybe Text -> Maybe Int -> Maybe Text -> ProcessDetails)
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 Int
   -> Maybe Text -> Maybe Int -> Maybe Text -> ProcessDetails)
-> Parser (Maybe Int)
-> Parser (Maybe Text -> Maybe Int -> Maybe Text -> ProcessDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Pid")
            Parser (Maybe Text -> Maybe Int -> Maybe Text -> ProcessDetails)
-> Parser (Maybe Text)
-> Parser (Maybe Int -> Maybe Text -> ProcessDetails)
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
"TerminatedAt")
            Parser (Maybe Int -> Maybe Text -> ProcessDetails)
-> Parser (Maybe Int) -> Parser (Maybe Text -> ProcessDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ParentPid")
            Parser (Maybe Text -> ProcessDetails)
-> Parser (Maybe Text) -> Parser ProcessDetails
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
"LaunchedAt")
      )

instance Prelude.Hashable ProcessDetails

instance Prelude.NFData ProcessDetails

instance Core.ToJSON ProcessDetails where
  toJSON :: ProcessDetails -> Value
toJSON ProcessDetails' {Maybe Int
Maybe Text
launchedAt :: Maybe Text
parentPid :: Maybe Int
terminatedAt :: Maybe Text
pid :: Maybe Int
name :: Maybe Text
path :: Maybe Text
$sel:launchedAt:ProcessDetails' :: ProcessDetails -> Maybe Text
$sel:parentPid:ProcessDetails' :: ProcessDetails -> Maybe Int
$sel:terminatedAt:ProcessDetails' :: ProcessDetails -> Maybe Text
$sel:pid:ProcessDetails' :: ProcessDetails -> Maybe Int
$sel:name:ProcessDetails' :: ProcessDetails -> Maybe Text
$sel:path:ProcessDetails' :: ProcessDetails -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Path" 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
path,
            (Text
"Name" 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
name,
            (Text
"Pid" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
pid,
            (Text
"TerminatedAt" 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
terminatedAt,
            (Text
"ParentPid" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
parentPid,
            (Text
"LaunchedAt" 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
launchedAt
          ]
      )