Skip to content

Commit

Permalink
If caller out of scope risk shall not be created for code backdooring…
Browse files Browse the repository at this point in the history
… rule
  • Loading branch information
Yevhen Zavhorodnii committed May 29, 2024
1 parent 0b06df9 commit 863ba18
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/security/risks/builtin/code_backdooring_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (r *CodeBackdooringRule) GenerateRisks(parsedModel *types.Model) ([]*types.

for _, callerLink := range parsedModel.IncomingTechnicalCommunicationLinksMappedByTargetId[technicalAsset.Id] {
caller := parsedModel.TechnicalAssets[callerLink.SourceId]
if (!callerLink.VPN && caller.Internet) || caller.OutOfScope {
if !callerLink.VPN && caller.Internet && !caller.OutOfScope {
risks = append(risks, r.createRisk(parsedModel, technicalAsset))
break
}
Expand Down
41 changes: 41 additions & 0 deletions pkg/security/risks/builtin/code_backdooring_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,44 @@ func TestCodeBackdooringRuleGenerateRisksTechAssetNotInternetButComingThroughVPN
assert.Nil(t, err)
assert.Empty(t, risks)
}

func TestCodeBackdooringRuleGenerateRisksTechAssetNotInternetButComingThroughVPNInternetButCallerOutOfScopeRisksNotCreated(t *testing.T) {
rule := NewCodeBackdooringRule()

risks, err := rule.GenerateRisks(&types.Model{
TechnicalAssets: map[string]*types.TechnicalAsset{
"git-lab-ci-cd": {
Id: "git-lab-ci-cd",
Title: "GitLab CI/CD",
Technologies: types.TechnologyList{
{
Name: "build-pipeline",
Attributes: map[string]bool{
types.IsDevelopmentRelevant: true,
},
},
},
},
"vpn": {
Title: "VPN",
Internet: true,
},
"out-of-scope": {
Title: "Out of Scope",
OutOfScope: true,
},
},
IncomingTechnicalCommunicationLinksMappedByTargetId: map[string][]*types.CommunicationLink{
"git-lab-ci-cd": {
{
SourceId: "out-of-scope",
TargetId: "git-lab-ci-cd",
VPN: false,
},
},
},
})

assert.Nil(t, err)
assert.Empty(t, risks)
}

0 comments on commit 863ba18

Please sign in to comment.