@@ -7,17 +7,17 @@ import (
7
7
"github.com/threagile/threagile/pkg/types"
8
8
)
9
9
10
- func TestCrossSiteRequestForgeryRuleGenerateRisksEmptyModelNotRisksCreated (t * testing.T ) {
11
- rule := NewCrossSiteRequestForgeryRule ()
10
+ func TestContainerPlatformEscapeRuleGenerateRisksEmptyModelNotRisksCreated (t * testing.T ) {
11
+ rule := NewContainerPlatformEscapeRule ()
12
12
13
13
risks , err := rule .GenerateRisks (& types.Model {})
14
14
15
15
assert .Nil (t , err )
16
16
assert .Empty (t , risks )
17
17
}
18
18
19
- func TestCrossSiteRequestForgeryRuleGenerateRisksOutOfScopeNotRisksCreated (t * testing.T ) {
20
- rule := NewCrossSiteRequestForgeryRule ()
19
+ func TestContainerPlatformEscapeRuleGenerateRisksOutOfScopeNotRisksCreated (t * testing.T ) {
20
+ rule := NewContainerPlatformEscapeRule ()
21
21
22
22
risks , err := rule .GenerateRisks (& types.Model {
23
23
TechnicalAssets : map [string ]* types.TechnicalAsset {
@@ -31,8 +31,8 @@ func TestCrossSiteRequestForgeryRuleGenerateRisksOutOfScopeNotRisksCreated(t *te
31
31
assert .Empty (t , risks )
32
32
}
33
33
34
- func TestCrossSiteRequestForgeryRuleGenerateRisksTechAssetNotWebApplicationNotRisksCreated (t * testing.T ) {
35
- rule := NewCrossSiteRequestForgeryRule ()
34
+ func TestContainerPlatformEscapeRuleRuleGenerateRisksTechAssetNotContainerPlatformNotRisksCreated (t * testing.T ) {
35
+ rule := NewContainerPlatformEscapeRule ()
36
36
37
37
risks , err := rule .GenerateRisks (& types.Model {
38
38
TechnicalAssets : map [string ]* types.TechnicalAsset {
@@ -41,7 +41,7 @@ func TestCrossSiteRequestForgeryRuleGenerateRisksTechAssetNotWebApplicationNotRi
41
41
{
42
42
Name : "tool" ,
43
43
Attributes : map [string ]bool {
44
- types .WebApplication : false ,
44
+ types .ContainerPlatform : false ,
45
45
},
46
46
},
47
47
},
@@ -53,208 +53,66 @@ func TestCrossSiteRequestForgeryRuleGenerateRisksTechAssetNotWebApplicationNotRi
53
53
assert .Empty (t , risks )
54
54
}
55
55
56
- func TestCrossSiteRequestForgeryRuleGenerateRisksTechAssetWebApplicationWithoutIncomingCommunicationNotRisksCreated (t * testing.T ) {
57
- rule := NewCrossSiteRequestForgeryRule ()
56
+ func TestContainerPlatformEscapeRuleGenerateRisksTechAssetContainerPlatformRisksCreated (t * testing.T ) {
57
+ rule := NewContainerPlatformEscapeRule ()
58
58
59
59
risks , err := rule .GenerateRisks (& types.Model {
60
60
TechnicalAssets : map [string ]* types.TechnicalAsset {
61
61
"ta1" : {
62
- Technologies : types.TechnologyList {
63
- {
64
- Name : "web-app" ,
65
- Attributes : map [string ]bool {
66
- types .WebApplication : true ,
67
- },
68
- },
69
- },
70
- },
71
- },
72
- })
73
-
74
- assert .Nil (t , err )
75
- assert .Empty (t , risks )
76
- }
77
-
78
- func TestCrossSiteRequestForgeryRuleGenerateRisksTechAssetWebApplicationIncomingRequestNotWebAccessProtocolNotRiskCreated (t * testing.T ) {
79
- rule := NewCrossSiteRequestForgeryRule ()
80
-
81
- risks , err := rule .GenerateRisks (& types.Model {
82
- TechnicalAssets : map [string ]* types.TechnicalAsset {
83
- "web-app" : {
84
- Id : "web-app" ,
85
- Technologies : types.TechnologyList {
86
- {
87
- Name : "web-app" ,
88
- Attributes : map [string ]bool {
89
- types .WebApplication : true ,
90
- },
91
- },
92
- },
93
- },
94
- "file-scrapper" : {
62
+ Id : "ta1" ,
63
+ Title : "Docker" ,
95
64
Technologies : types.TechnologyList {
96
65
{
97
66
Name : "tool" ,
98
- },
99
- },
100
- },
101
- },
102
- IncomingTechnicalCommunicationLinksMappedByTargetId : map [string ][]* types.CommunicationLink {
103
- "web-app" : {
104
- {
105
- Protocol : types .LocalFileAccess ,
106
- SourceId : "file-scrapper" ,
107
- TargetId : "web-app" ,
108
- },
109
- },
110
- },
111
- })
112
-
113
- assert .Nil (t , err )
114
- assert .Empty (t , risks )
115
- }
116
-
117
- func TestCrossSiteRequestForgeryRuleGenerateRisksTechAssetWebApplicationIncomingRequestWebAccessProtocolRiskCreated (t * testing.T ) {
118
- rule := NewCrossSiteRequestForgeryRule ()
119
-
120
- risks , err := rule .GenerateRisks (& types.Model {
121
- TechnicalAssets : map [string ]* types.TechnicalAsset {
122
- "web-app" : {
123
- Id : "web-app" ,
124
- Title : "Web Application" ,
125
- Technologies : types.TechnologyList {
126
- {
127
- Name : "web-app" ,
128
- Attributes : map [string ]bool {
129
- types .WebApplication : true ,
130
- },
131
- },
132
- },
133
- },
134
- "user" : {
135
- Title : "user" ,
136
- Technologies : types.TechnologyList {
137
- {
138
- Name : "user" ,
139
- },
140
- },
141
- },
142
- },
143
- IncomingTechnicalCommunicationLinksMappedByTargetId : map [string ][]* types.CommunicationLink {
144
- "web-app" : {
145
- {
146
- Title : "HTTP" ,
147
- Protocol : types .HTTP ,
148
- SourceId : "user" ,
149
- TargetId : "web-app" ,
150
- },
151
- },
152
- },
153
- })
154
-
155
- assert .Nil (t , err )
156
- assert .NotEmpty (t , risks )
157
- assert .Equal (t , "<b>Cross-Site Request Forgery (CSRF)</b> risk at <b>Web Application</b> via <b>HTTP</b> from <b>user</b>" , risks [0 ].Title )
158
- assert .Equal (t , types .VeryLikely , risks [0 ].ExploitationLikelihood )
159
- assert .Equal (t , types .LowImpact , risks [0 ].ExploitationImpact )
160
- }
161
-
162
- func TestCrossSiteRequestForgeryRuleGenerateRisksTechAssetWebApplicationIncomingRequestWebAccessProtocolViaDevOpsRiskCreatedWithLikelyLikelihood (t * testing.T ) {
163
- rule := NewCrossSiteRequestForgeryRule ()
164
-
165
- risks , err := rule .GenerateRisks (& types.Model {
166
- TechnicalAssets : map [string ]* types.TechnicalAsset {
167
- "web-app" : {
168
- Id : "web-app" ,
169
- Title : "Web Application" ,
170
- Technologies : types.TechnologyList {
171
- {
172
- Name : "web-app" ,
173
67
Attributes : map [string ]bool {
174
- types .WebApplication : true ,
68
+ types .ContainerPlatform : true ,
175
69
},
176
70
},
177
71
},
178
- },
179
- "ci/cd" : {
180
- Title : "ci/cd" ,
181
- Technologies : types.TechnologyList {
182
- {
183
- Name : "ci/cd" ,
184
- },
185
- },
186
- },
187
- },
188
- IncomingTechnicalCommunicationLinksMappedByTargetId : map [string ][]* types.CommunicationLink {
189
- "web-app" : {
190
- {
191
- Title : "HTTP" ,
192
- Protocol : types .HTTP ,
193
- SourceId : "ci/cd" ,
194
- TargetId : "web-app" ,
195
- Usage : types .DevOps ,
196
- },
72
+ Machine : types .Container ,
197
73
},
198
74
},
199
75
})
200
76
201
77
assert .Nil (t , err )
202
78
assert .NotEmpty (t , risks )
203
- assert .Equal (t , "<b>Cross-Site Request Forgery (CSRF)</b> risk at <b>Web Application</b> via <b>HTTP</b> from <b>ci/cd</b>" , risks [0 ].Title )
204
- assert .Equal (t , types .Likely , risks [0 ].ExploitationLikelihood )
205
- assert .Equal (t , types .LowImpact , risks [0 ].ExploitationImpact )
79
+ assert .Equal (t , "<b>Container Platform Escape</b> risk at <b>Docker</b>" , risks [0 ].Title )
80
+ assert .Equal (t , types .MediumImpact , risks [0 ].ExploitationImpact )
81
+ assert .NotEmpty (t , risks [0 ].DataBreachTechnicalAssetIDs )
82
+ assert .Equal (t , "ta1" , risks [0 ].DataBreachTechnicalAssetIDs [0 ])
206
83
}
207
84
208
- func TestCrossSiteRequestForgeryRuleGenerateRisksTechAssetWebApplicationIncomingRequestWebAccessProtocolRiskCreatedWithMediumImpactWhenIntegrityIsMissionCritical (t * testing.T ) {
209
- rule := NewCrossSiteRequestForgeryRule ()
85
+ func TestContainerPlatformEscapeRuleGenerateRisksTechAssetProcessStrictlyConfidentialDataAssetHighImpactRiskCreated (t * testing.T ) {
86
+ rule := NewContainerPlatformEscapeRule ()
210
87
211
88
risks , err := rule .GenerateRisks (& types.Model {
212
89
TechnicalAssets : map [string ]* types.TechnicalAsset {
213
- "web-app " : {
214
- Id : "web-app " ,
215
- Title : "Web Application " ,
90
+ "ta1 " : {
91
+ Id : "ta1 " ,
92
+ Title : "Docker " ,
216
93
Technologies : types.TechnologyList {
217
94
{
218
- Name : "web-app " ,
95
+ Name : "tool " ,
219
96
Attributes : map [string ]bool {
220
- types .WebApplication : true ,
97
+ types .ContainerPlatform : true ,
221
98
},
222
99
},
223
100
},
224
- },
225
- "user" : {
226
- Title : "user" ,
227
- Technologies : types.TechnologyList {
228
- {
229
- Name : "user" ,
230
- },
231
- },
101
+ Machine : types .Container ,
102
+ DataAssetsProcessed : []string {"strictly-confidential-data-asset" },
232
103
},
233
104
},
234
105
DataAssets : map [string ]* types.DataAsset {
235
- "mission-critical-data" : {
236
- Id : "mission-critical-data" ,
237
- Title : "Mission Critical Data" ,
238
- Integrity : types .MissionCritical ,
239
- },
240
- },
241
-
242
- IncomingTechnicalCommunicationLinksMappedByTargetId : map [string ][]* types.CommunicationLink {
243
- "web-app" : {
244
- {
245
- Title : "HTTP" ,
246
- Protocol : types .HTTP ,
247
- SourceId : "user" ,
248
- TargetId : "web-app" ,
249
- DataAssetsReceived : []string {"mission-critical-data" },
250
- },
106
+ "strictly-confidential-data-asset" : {
107
+ Confidentiality : types .StrictlyConfidential ,
251
108
},
252
109
},
253
110
})
254
111
255
112
assert .Nil (t , err )
256
113
assert .NotEmpty (t , risks )
257
- assert .Equal (t , "<b>Cross-Site Request Forgery (CSRF)</b> risk at <b>Web Application</b> via <b>HTTP</b> from <b>user</b>" , risks [0 ].Title )
258
- assert .Equal (t , types .VeryLikely , risks [0 ].ExploitationLikelihood )
259
- assert .Equal (t , types .MediumImpact , risks [0 ].ExploitationImpact )
114
+ assert .Equal (t , "<b>Container Platform Escape</b> risk at <b>Docker</b>" , risks [0 ].Title )
115
+ assert .Equal (t , types .HighImpact , risks [0 ].ExploitationImpact )
116
+ assert .NotEmpty (t , risks [0 ].DataBreachTechnicalAssetIDs )
117
+ assert .Equal (t , "ta1" , risks [0 ].DataBreachTechnicalAssetIDs [0 ])
260
118
}
0 commit comments