/
section_1.sp
423 lines (361 loc) · 17.3 KB
/
section_1.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
variable "trusted_repo_admins" {
type = list(string)
default = [""]
description = "A list of github users allowed to delete the repository."
}
variable "trusted_issue_admins" {
type = list(string)
default = [""]
description = "A list of github users allowed to delete the issue."
}
locals {
cis_supply_chain_v100_1_common_tags = merge(local.cis_supply_chain_v100_common_tags, {
cis_section_id = "1"
})
}
locals {
cis_supply_chain_v100_1_1_common_tags = merge(local.cis_supply_chain_v100_1_common_tags, {
cis_section_id = "1.1"
})
cis_supply_chain_v100_1_2_common_tags = merge(local.cis_supply_chain_v100_1_common_tags, {
cis_section_id = "1.2"
})
cis_supply_chain_v100_1_3_common_tags = merge(local.cis_supply_chain_v100_1_common_tags, {
cis_section_id = "1.3"
})
}
benchmark "cis_supply_chain_v100_1" {
title = "1 Source Code"
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1.md")
children = [
benchmark.cis_supply_chain_v100_1_1,
benchmark.cis_supply_chain_v100_1_2,
benchmark.cis_supply_chain_v100_1_3,
]
tags = merge(local.cis_supply_chain_v100_1_common_tags, {
type = "Benchmark"
})
}
benchmark "cis_supply_chain_v100_1_1" {
title = "1.1 Code Changes"
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_1.md")
children = [
control.cis_supply_chain_v100_1_1_3,
control.cis_supply_chain_v100_1_1_4,
control.cis_supply_chain_v100_1_1_5,
control.cis_supply_chain_v100_1_1_6,
control.cis_supply_chain_v100_1_1_9,
control.cis_supply_chain_v100_1_1_10,
control.cis_supply_chain_v100_1_1_11,
control.cis_supply_chain_v100_1_1_12,
control.cis_supply_chain_v100_1_1_13,
control.cis_supply_chain_v100_1_1_14,
control.cis_supply_chain_v100_1_1_15,
control.cis_supply_chain_v100_1_1_16,
control.cis_supply_chain_v100_1_1_17
]
tags = merge(local.cis_supply_chain_v100_1_1_common_tags, {
type = "Benchmark"
})
}
control "cis_supply_chain_v100_1_1_3" {
title = "1.1.3 Ensure any change to code receives approval of two strongly authenticated users"
description = "Ensure that every code change is reviewed and approved by two authorized contributors who are both strongly authenticated, from the team relevant to the code change."
query = query.default_branch_requires_2_pull_request_reviews
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_1_3.md")
tags = merge(local.cis_supply_chain_v100_1_1_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_1_4" {
title = "1.1.4 Ensure previous approvals are dismissed when updates are introduced to a code change proposal"
description = "Ensure that when a proposed code change is updated, previous approvals are declined and new approvals are required."
query = query.default_branch_must_dismiss_stale_approvals
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_1_4.md")
tags = merge(local.cis_supply_chain_v100_1_1_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_1_5" {
title = "1.1.5 Ensure there are restrictions on who can dismiss code change reviews"
description = "Only trusted users should be allowed to dismiss code change reviews."
query = query.default_branch_code_change_review_dismissal_restrictions
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_1_5.md")
tags = merge(local.cis_supply_chain_v100_1_1_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_1_6" {
title = "1.1.6 Ensure code owners are set for extra sensitive code or configuration"
description = "Code owners are trusted users that are responsible for reviewing and managing an important piece of code or configuration. An organization is advised to set code owners for every extremely sensitive code or configuration."
query = query.default_branch_requires_code_owners_review
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_1_6.md")
tags = merge(local.cis_supply_chain_v100_1_1_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_1_9" {
title = "1.1.9 Ensure all checks have passed before merging new code"
description = "Before a code change request can be merged to the code base, all predefined checks must ssuccessfully pass."
query = query.default_branch_requires_status_checks
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_1_9.md")
tags = merge(local.cis_supply_chain_v100_1_1_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_1_10" {
title = "1.1.10 Ensure open Git branches are up to date before they can be merged into code base"
description = "Organizations should make sure each suggested code change is in full sync with the existing state of its origin code repository before allowing merging."
query = query.repo_open_branches_are_upto_date_before_merge
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_1_10.md")
tags = merge(local.cis_supply_chain_v100_1_1_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_1_11" {
title = "1.1.11 Ensure all open comments are resolved before allowing code change merging"
description = "Organizations should enforce a 'no open comments' policy before allowing code change merging."
query = query.repo_no_open_comments
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_1_11.md")
tags = merge(local.cis_supply_chain_v100_1_1_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_1_12" {
title = "1.1.12 Ensure verification of signed commits for new changes before merging"
description = "Ensure every commit in a pull request is signed and verified before merging."
query = query.default_branch_requires_signed_commits
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_1_12.md")
tags = merge(local.cis_supply_chain_v100_1_1_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_1_13" {
title = "1.1.13 Ensure linear history is required"
description = "Linear history is the name for Git history where all commits are listed in chronological order, one after another. Such history exists if a pull request is merged either by rebase merge (reorders the commits history) or squash merge (squashes all commits to one). Ensure that linear history is required by requiring the use of rebase or squash merge when merging a pull request."
query = query.repo_linear_history_enabled
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_1_13.md")
tags = merge(local.cis_supply_chain_v100_1_1_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_1_14" {
title = "1.1.14 Ensure branch protection rules are enforced for administrators"
description = "Ensure administrators are subject to branch protection rules."
query = query.default_branch_protections_apply_to_admins
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_1_14.md")
tags = merge(local.cis_supply_chain_v100_1_1_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_1_15" {
title = "1.1.15 Ensure pushing or merging of new code is restricted to specific individuals or teams"
description = "Ensure that only trusted users can push or merge new code to protected branches."
query = query.default_branch_restrict_push_and_merge
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_1_15.md")
tags = merge(local.cis_supply_chain_v100_1_1_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_1_16" {
title = "1.1.16 Ensure force push code to branches is denied"
description = "The 'force push' option allows users with 'push' permissions to force their changes directly to the branch without a pull request, and thus should be disabled."
query = query.default_branch_blocks_force_push
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_1_16.md")
tags = merge(local.cis_supply_chain_v100_1_1_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_1_17" {
title = "1.1.17 Ensure branch deletions are denied"
description = "Ensure that users with only push access are incapable of deleting a protected branch."
query = query.default_branch_setting_block_deletion
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_1_17.md")
tags = merge(local.cis_supply_chain_v100_1_1_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
benchmark "cis_supply_chain_v100_1_2" {
title = "1.2 Repository Management"
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_2.md")
children = [
control.cis_supply_chain_v100_1_2_1,
control.cis_supply_chain_v100_1_2_2,
control.cis_supply_chain_v100_1_2_3,
control.cis_supply_chain_v100_1_2_4,
control.cis_supply_chain_v100_1_2_7
]
tags = merge(local.cis_supply_chain_v100_1_2_common_tags, {
type = "Benchmark"
})
}
control "cis_supply_chain_v100_1_2_1" {
title = "1.2.1 Ensure all public repositories contain a SECURITY.md file"
description = "A SECURITY.md file is a security policy file that offers instruction on reporting security vulnerabilities in a project. When someone creates an issue within a specific project, a link to the SECURITY.md file will subsequently be shown."
query = query.public_repo_has_security_md_file
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_2_1.md")
tags = merge(local.cis_supply_chain_v100_1_2_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_2_2" {
title = "1.2.2 Ensure repository creation is limited to specific members"
description = "Limit the ability to create repositories to trusted users and teams."
query = query.org_members_cannot_create_repos
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_2_2.md")
tags = merge(local.cis_supply_chain_v100_1_2_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_2_3" {
title = "1.2.3 Ensure repository deletion is limited to specific users"
description = "Ensure only a limited number of trusted users can delete repositories."
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_2_3.md")
query = query.repo_deletion_limited_to_trusted_users
param "trusted_repo_admins" {
description = "A list of GitHub users allowed to delete repositories."
default = var.trusted_repo_admins
}
tags = merge(local.cis_supply_chain_v100_1_2_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_2_4" {
title = "1.2.4 Ensure issue deletion is limited to specific users"
description = "Ensure only trusted and responsible users can delete issues."
query = query.repo_issue_deletion_limited_to_trusted_users
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_2_4.md")
param "trusted_issue_admins" {
description = "A list of GitHub users allowed to delete issues."
default = var.trusted_issue_admins
}
tags = merge(local.cis_supply_chain_v100_1_2_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_2_7" {
title = "1.2.4 Ensure inactive repositories are reviewed and archived periodically"
description = "Ensure inactive repositories are reviewed and archived periodically."
query = query.repo_inactive_more_than_90_days
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_2_7.md")
tags = merge(local.cis_supply_chain_v100_1_2_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
benchmark "cis_supply_chain_v100_1_3" {
title = "1.3 Contribution Access"
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_3.md")
children = [
control.cis_supply_chain_v100_1_3_1,
control.cis_supply_chain_v100_1_3_3,
control.cis_supply_chain_v100_1_3_5,
control.cis_supply_chain_v100_1_3_7,
control.cis_supply_chain_v100_1_3_8,
control.cis_supply_chain_v100_1_3_9
]
tags = merge(local.cis_supply_chain_v100_1_3_common_tags, {
type = "Benchmark"
})
}
control "cis_supply_chain_v100_1_3_1" {
title = "1.3.1 Ensure inactive users are reviewed and removed periodically"
description = "Track inactive user accounts and periodically remove them."
query = query.repo_inactive_members_review
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_3_1.md")
tags = merge(local.cis_supply_chain_v100_1_3_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "manual"
})
}
control "cis_supply_chain_v100_1_3_3" {
title = "1.3.3 Ensure minimum number of administrators are set for the organization"
description = "Ensure the organization has a minimum number of administrators."
query = query.org_minimum_administrators_set
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_3_3.md")
tags = merge(local.cis_supply_chain_v100_1_3_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_3_5" {
title = "1.3.5 Ensure the organization is requiring members to use Multi-Factor Authentication (MFA)"
description = "Require members of the organization to use Multi-Factor Authentication (MFA) in addition to a standard user name and password when authenticating to the source code management platform."
query = query.org_two_factor_required
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_3_5.md")
tags = merge(local.cis_supply_chain_v100_1_3_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_3_7" {
title = "1.3.7 Ensure two administrators are set for each repository"
description = "Ensure every repository has two users with administrative permissions."
query = query.repo_should_have_two_admins
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_3_7.md")
tags = merge(local.cis_supply_chain_v100_1_3_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_3_8" {
title = "1.3.8 Ensure strict base permissions are set for repositories"
description = "Base permissions define the permission level automatically granted to all organization members. Define strict base access permissions for all of the repositories in the organization, including new ones."
query = query.org_default_repo_permission_none_read
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_3_8.md")
tags = merge(local.cis_supply_chain_v100_1_3_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}
control "cis_supply_chain_v100_1_3_9" {
title = "1.3.9 Ensure an organization's identity is confirmed with a 'Verified' badge"
description = "Confirm the domains an organization owns with a 'Verified' badge."
query = query.org_domain_verified
documentation = file("./cis_supply_chain_v100/docs/cis_supply_chain_v100_1_3_9.md")
tags = merge(local.cis_supply_chain_v100_1_3_common_tags, {
cis = "true"
cis_supply_chain_v100 = "true"
cis_type = "automated"
})
}