Skip to content

Commit ed1678a

Browse files
add indicator of VulnerabilityStep to AttackTrackStep (kubescape#118)
* 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]>
1 parent 55d0527 commit ed1678a

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

reporthandling/attacktrack/v1alpha1/attacktrackmocks.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ func GetAttackTrackMock(data AttackTrackStep) IAttackTrack {
4141

4242
// Mocked AttackTrackStep implementation for testing
4343
type AttackTrackStepMock struct {
44-
Name string
45-
Description string
46-
SubSteps []AttackTrackStepMock
47-
Controls []IAttackTrackControl
44+
Name string
45+
Description string
46+
ChecksVulnerabilities bool
47+
SubSteps []AttackTrackStepMock
48+
Controls []IAttackTrackControl
4849
}
4950

5051
// Mocked AttackTrackStep methods
@@ -68,6 +69,10 @@ func (s AttackTrackStepMock) IsLeaf() bool {
6869
return len(s.SubSteps) == 0
6970
}
7071

72+
func (s AttackTrackStepMock) DoesCheckVulnerabilities() bool {
73+
return s.ChecksVulnerabilities
74+
}
75+
7176
func (a AttackTrackStepMock) IsPartOfAttackTrackPath() bool {
7277
return len(a.Controls) > 0
7378
}

reporthandling/attacktrack/v1alpha1/attacktrackstepmethods.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ func (step *AttackTrackStep) IsLeaf() bool {
3333
return step.Length() == 0
3434
}
3535

36+
func (step *AttackTrackStep) DoesCheckVulnerabilities() bool {
37+
return step.ChecksVulnerabilities
38+
}
39+
3640
// Equal checks if the given attack track step is equal to the current one
3741
// If compareControls is true, the controls are also compared
3842
func (s *AttackTrackStep) Equal(other *AttackTrackStep, compareControls bool) bool {

reporthandling/attacktrack/v1alpha1/datastructures.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ type AttackTrackSpecification struct {
2121
}
2222

2323
type AttackTrackStep struct {
24-
Name string `json:"name"`
25-
Description string `json:"description,omitempty"`
26-
SubSteps []AttackTrackStep `json:"subSteps,omitempty"`
24+
Name string `json:"name"`
25+
Description string `json:"description,omitempty"`
26+
ChecksVulnerabilities bool `json:"checksVulnerabilities,omitempty"`
27+
SubSteps []AttackTrackStep `json:"subSteps,omitempty"`
2728

2829
// failed controls which are related to this step
2930
Controls []IAttackTrackControl `json:"-"`

reporthandling/attacktrack/v1alpha1/interface.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type IAttackTrackStep interface {
2121
SubStepAt(index int) IAttackTrackStep // returns a sub step at the given index
2222
IsPartOfAttackTrackPath() bool // checks if the step can be a part of an attack track path
2323
IsLeaf() bool // checks if the step is a leaf node
24+
DoesCheckVulnerabilities() bool // checks if the step checks for vulnerabilities
2425
}
2526

2627
// A control related to an attack track step

0 commit comments

Comments
 (0)