Skip to content

Commit

Permalink
add indicator of VulnerabilityStep to AttackTrackStep (#118)
Browse files Browse the repository at this point in the history
* add indicator of IsVulnerabilityStep

Signed-off-by: YiscahLevySilas1 <[email protected]>

* name changes

Signed-off-by: YiscahLevySilas1 <[email protected]>

* changes following review

Signed-off-by: YiscahLevySilas1 <[email protected]>

---------

Signed-off-by: YiscahLevySilas1 <[email protected]>
  • Loading branch information
YiscahLevySilas1 authored Jul 16, 2023
1 parent 55d0527 commit ed1678a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
13 changes: 9 additions & 4 deletions reporthandling/attacktrack/v1alpha1/attacktrackmocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions reporthandling/attacktrack/v1alpha1/attacktrackstepmethods.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions reporthandling/attacktrack/v1alpha1/datastructures.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:"-"`
Expand Down
1 change: 1 addition & 0 deletions reporthandling/attacktrack/v1alpha1/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ed1678a

Please sign in to comment.