From ed1678a7f21649f3ce89409494caa55d0ec4582f Mon Sep 17 00:00:00 2001 From: YiscahLevySilas1 <80635572+YiscahLevySilas1@users.noreply.github.com> Date: Sun, 16 Jul 2023 12:28:46 +0200 Subject: [PATCH] add indicator of VulnerabilityStep to AttackTrackStep (#118) * add indicator of IsVulnerabilityStep Signed-off-by: YiscahLevySilas1 * name changes Signed-off-by: YiscahLevySilas1 * changes following review Signed-off-by: YiscahLevySilas1 --------- Signed-off-by: YiscahLevySilas1 --- .../attacktrack/v1alpha1/attacktrackmocks.go | 13 +++++++++---- .../attacktrack/v1alpha1/attacktrackstepmethods.go | 4 ++++ .../attacktrack/v1alpha1/datastructures.go | 7 ++++--- reporthandling/attacktrack/v1alpha1/interface.go | 1 + 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/reporthandling/attacktrack/v1alpha1/attacktrackmocks.go b/reporthandling/attacktrack/v1alpha1/attacktrackmocks.go index 5821d68b..7dd94392 100644 --- a/reporthandling/attacktrack/v1alpha1/attacktrackmocks.go +++ b/reporthandling/attacktrack/v1alpha1/attacktrackmocks.go @@ -41,10 +41,11 @@ func GetAttackTrackMock(data AttackTrackStep) IAttackTrack { // Mocked AttackTrackStep implementation for testing type AttackTrackStepMock struct { - Name string - Description string - SubSteps []AttackTrackStepMock - Controls []IAttackTrackControl + Name string + Description string + ChecksVulnerabilities bool + SubSteps []AttackTrackStepMock + Controls []IAttackTrackControl } // Mocked AttackTrackStep methods @@ -68,6 +69,10 @@ func (s AttackTrackStepMock) IsLeaf() bool { return len(s.SubSteps) == 0 } +func (s AttackTrackStepMock) DoesCheckVulnerabilities() bool { + return s.ChecksVulnerabilities +} + func (a AttackTrackStepMock) IsPartOfAttackTrackPath() bool { return len(a.Controls) > 0 } diff --git a/reporthandling/attacktrack/v1alpha1/attacktrackstepmethods.go b/reporthandling/attacktrack/v1alpha1/attacktrackstepmethods.go index 84e44fb6..ef3f4cb8 100644 --- a/reporthandling/attacktrack/v1alpha1/attacktrackstepmethods.go +++ b/reporthandling/attacktrack/v1alpha1/attacktrackstepmethods.go @@ -33,6 +33,10 @@ func (step *AttackTrackStep) IsLeaf() bool { return step.Length() == 0 } +func (step *AttackTrackStep) DoesCheckVulnerabilities() bool { + return step.ChecksVulnerabilities +} + // Equal checks if the given attack track step is equal to the current one // If compareControls is true, the controls are also compared func (s *AttackTrackStep) Equal(other *AttackTrackStep, compareControls bool) bool { diff --git a/reporthandling/attacktrack/v1alpha1/datastructures.go b/reporthandling/attacktrack/v1alpha1/datastructures.go index 56a0c4cf..7896f0bf 100644 --- a/reporthandling/attacktrack/v1alpha1/datastructures.go +++ b/reporthandling/attacktrack/v1alpha1/datastructures.go @@ -21,9 +21,10 @@ type AttackTrackSpecification struct { } type AttackTrackStep struct { - Name string `json:"name"` - Description string `json:"description,omitempty"` - SubSteps []AttackTrackStep `json:"subSteps,omitempty"` + Name string `json:"name"` + Description string `json:"description,omitempty"` + ChecksVulnerabilities bool `json:"checksVulnerabilities,omitempty"` + SubSteps []AttackTrackStep `json:"subSteps,omitempty"` // failed controls which are related to this step Controls []IAttackTrackControl `json:"-"` diff --git a/reporthandling/attacktrack/v1alpha1/interface.go b/reporthandling/attacktrack/v1alpha1/interface.go index 3580997a..e1ddd3a6 100644 --- a/reporthandling/attacktrack/v1alpha1/interface.go +++ b/reporthandling/attacktrack/v1alpha1/interface.go @@ -21,6 +21,7 @@ type IAttackTrackStep interface { SubStepAt(index int) IAttackTrackStep // returns a sub step at the given index IsPartOfAttackTrackPath() bool // checks if the step can be a part of an attack track path IsLeaf() bool // checks if the step is a leaf node + DoesCheckVulnerabilities() bool // checks if the step checks for vulnerabilities } // A control related to an attack track step