WSF
WsfCyberProtect.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2016 Infoscitex, a DCS Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef WSFCYBERPROTECT_HPP
13#define WSFCYBERPROTECT_HPP
14
15#include "wsf_cyber_export.h"
16
17#include <list>
18
19#include "UtMath.hpp"
20class UtScript;
21#include "UtScriptContext.hpp"
23#include "WsfObject.hpp"
24class WsfPlatform;
25#include "WsfRandomVariable.hpp"
26class WsfScenario;
29
30namespace wsf
31{
32namespace cyber
33{
34class Engagement;
35
39class WSF_CYBER_EXPORT Protect : public WsfObject, public WsfSimplePlatformComponent
40{
41public:
42 static Protect* Find(const WsfPlatform& aPlatform);
43 static void RegisterComponentFactory(WsfScenario& aScenario);
44
45 Protect(WsfScenario& aScenario);
46 ~Protect() override = default;
47
49 Protect& operator=(const Protect& aRhs) = delete;
50
52
53 WsfComponent* CloneComponent() const override { return Clone(); }
54 void* QueryInterface(int aRole) override { return (aRole == mRoles[0]) ? this : nullptr; }
55 void ComponentParentChanged(WsfPlatform* aPlatformPtr) override { mPlatformPtr = aPlatformPtr; }
57
59
60 Protect* Clone() const override;
61 bool Initialize(double aSimTime) override;
62 bool ProcessInput(UtInput& aInput) override;
64
67 bool DefaultExists() const { return mDefaultDefined; }
68
72 bool ProtectionExists(const std::string& aAttackName) const;
73
75
76 double GetProbabilityOfScanDetection(const std::string& aAttackName) const;
77 double GetProbabilityOfScanAttribution(const std::string& aAttackName) const;
78 double GetProbabilityOfAttackSuccess(const std::string& aAttackName) const;
79 double GetProbabilityOfStatusReport(const std::string& aAttackName) const;
80 double GetProbabilityOfAttackDetection(const std::string& aAttackName) const;
81 double GetProbabilityOfAttackAttribution(const std::string& aAttackName) const;
82 double GetProbabilityOfFutureImmunity(const std::string& aAttackName) const;
83 double DetectionDelayTime(const std::string& aAttackName) const;
84 double RecoveryDelayTime(const std::string& aAttackName) const;
85 double LastDetectionDelayTime(const std::string& aAttackName) const;
86 double LastRecoveryDelayTime(const std::string& aAttackName) const;
87 bool DoRestore(const std::string& aAttackName) const;
88 bool IsImmune(const std::string& aAttackName) const;
90
92
93 void ExecuteOnAttackDetection(Engagement& aEngagement, double aSimTime);
94 void ExecuteOnAttackRecovery(Engagement& aEngagement, double aSimTime);
95 void ExecuteOnScanDetection(Engagement& aEngagement, double aSimTime);
96 bool ExecuteIsVulnerable(Engagement& aEngagement, double aSimTime, bool& aWasRun);
98
101 void SetImmune(const std::string& aNamedAttack) { mImmuneAttacks.push_back(aNamedAttack); }
102
103 WsfScriptContext& GetScriptContext() { return mContext; }
104 UtScriptContext* GetScriptAccessibleContext() const override { return &mContext.GetContext(); }
105
106protected:
107 Protect(const Protect& aSrc);
108
114 {
115 public:
116 ~ProtectedAttack() override = default;
117
118 bool ProcessInput(UtInput& aInput, WsfScriptContext& aContext);
119
122 double mScanDetection{0.0};
123 double mScanAttribution{0.0};
124 double mAttackSuccess{1.0};
125 double mStatusReport{0.0};
126 double mAttackDetection{0.0};
128 double mImmunity{0.0};
129
132
133 bool mRestore{false};
134
135 UtScript* mOnAttackDetection{nullptr};
136 UtScript* mOnAttackRecovery{nullptr};
137 UtScript* mOnScanDetection{nullptr};
138 UtScript* mIsVulnerable{nullptr};
139 };
140
142
143 using ProtectedAttackList = std::vector<ProtectedAttack>;
144 using ProtectedAttackListIt = std::vector<ProtectedAttack>::const_iterator;
145 using ProtectedAttackListNonConstIt = std::vector<ProtectedAttack>::iterator;
147
148private:
150 ProtectedAttackListIt FindAttackProtection(const std::string& aAttackName) const;
151 ProtectedAttackListNonConstIt FindAttackProtection(const std::string& aAttackName);
152
154 WsfScenario* mScenarioPtr;
155
157 WsfPlatform* mPlatformPtr;
158
160 ProtectedAttackList mNamedAttacks;
161
163 bool mDefaultDefined;
164
167 std::vector<std::string> mImmuneAttacks;
168
169 WsfScriptContext mContext;
170 UtScriptClass* mEngagementClassPtr; // = mContext.GetClass("WsfCyberEngagement");
171};
172
173} // namespace cyber
174} // namespace wsf
175
177
178#endif
#define WSF_DECLARE_COMPONENT_ROLE_TYPE(TYPE, ROLE)
Definition WsfComponentRoles.hpp:44
@ cWSF_COMPONENT_CYBER_PROTECT
'cyber_protect' platform extension.
Definition WsfCyberComponentRoles.hpp:18
WsfSimpleComponentT< WsfPlatformComponent > WsfSimplePlatformComponent
Definition WsfSimpleComponent.hpp:126
Definition WsfComponent.hpp:39
WsfNamed()
Definition WsfNamed.cpp:17
WsfObject()
This is the constructor for the WsfObject class.
Definition WsfObject.cpp:88
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
Definition WsfRandomVariable.hpp:33
@ cCONSTANT
The random values will always have a constant value.
Definition WsfRandomVariable.hpp:38
@ cNON_NEGATIVE
Value must be greater than or equal to zero.
Definition WsfRandomVariable.hpp:50
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
Definition WsfScriptContext.hpp:71
int mRoles[2]
Definition WsfSimpleComponent.hpp:116
A class that represents the cyber engagements between two platforms.
Definition WsfCyberEngagement.hpp:37
Definition WsfCyberProtect.hpp:114
UtScript * mIsVulnerable
Definition WsfCyberProtect.hpp:138
bool mRestore
Definition WsfCyberProtect.hpp:133
double mAttackSuccess
Definition WsfCyberProtect.hpp:124
UtScript * mOnAttackRecovery
Definition WsfCyberProtect.hpp:136
double mAttackDetection
Definition WsfCyberProtect.hpp:126
double mStatusReport
Definition WsfCyberProtect.hpp:125
double mAttackAttribution
Definition WsfCyberProtect.hpp:127
bool ProcessInput(UtInput &aInput, WsfScriptContext &aContext)
Definition WsfCyberProtect.cpp:162
double mImmunity
Definition WsfCyberProtect.hpp:128
UtScript * mOnScanDetection
Definition WsfCyberProtect.hpp:137
WsfRandomVariable mDetectionDelay
Definition WsfCyberProtect.hpp:130
double mScanAttribution
Definition WsfCyberProtect.hpp:123
WsfRandomVariable mRecoveryDelay
Definition WsfCyberProtect.hpp:131
double mScanDetection
Definition WsfCyberProtect.hpp:122
UtScript * mOnAttackDetection
Definition WsfCyberProtect.hpp:135
Definition WsfCyberProtect.hpp:40
std::vector< ProtectedAttack > ProtectedAttackList
Definition WsfCyberProtect.hpp:143
std::vector< ProtectedAttack >::iterator ProtectedAttackListNonConstIt
Definition WsfCyberProtect.hpp:145
bool DefaultExists() const
Definition WsfCyberProtect.hpp:67
WsfComponent * CloneComponent() const override
Definition WsfCyberProtect.hpp:53
void SetImmune(const std::string &aNamedAttack)
Definition WsfCyberProtect.hpp:101
Protect(WsfScenario &aScenario)
Definition WsfCyberProtect.cpp:81
Protect & operator=(const Protect &aRhs)=delete
Assignment operator deleted to prevent use.
WsfScriptContext & GetScriptContext()
Definition WsfCyberProtect.hpp:103
UtScriptContext * GetScriptAccessibleContext() const override
Definition WsfCyberProtect.hpp:104
std::vector< ProtectedAttack >::const_iterator ProtectedAttackListIt
Definition WsfCyberProtect.hpp:144
~Protect() override=default
static Protect * Find(const WsfPlatform &aPlatform)
Definition WsfCyberProtect.cpp:67
Protect * Clone() const override
Definition WsfCyberProtect.cpp:110
void * QueryInterface(int aRole) override
Definition WsfCyberProtect.hpp:54
void ComponentParentChanged(WsfPlatform *aPlatformPtr) override
Definition WsfCyberProtect.hpp:55
static void RegisterComponentFactory(WsfScenario &aScenario)
Definition WsfCyberProtect.cpp:74
Definition WsfCyberApplicationExtension.cpp:24
Function definitions for those who need run-time access to the version.
Definition WsfComm.cpp:32
Copyrights Multiple, All Rights Reserved