Skip to content

Commit 60702e0

Browse files
author
Svetlin
authored
Addressing conditional IAM role bindings (#66)
Discovered when InSpec is checking conditional role bindings. In case they don't have any members (it happens after the expiration of the condition), the control simply fails.
1 parent a9134fc commit 60702e0

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

controls/1.05-iam.rb

+11-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,17 @@
4343
ref 'GCP Docs', url: 'https://cloud.google.com/iam/docs/understanding-service-accounts'
4444

4545
iam_bindings_cache.iam_bindings.keys.grep(/admin/i).each do |role|
46-
describe "[#{gcp_project_id}] Admin roles" do
47-
subject { iam_bindings_cache.iam_bindings[role] }
48-
its('members') { should_not include(/@[a-z][a-z0-9|-]{4,28}[a-z].iam.gserviceaccount.com/) }
46+
role_bindings = iam_bindings_cache.iam_bindings[role]
47+
if role_bindings.members.nil?
48+
impact 'none'
49+
describe "[#{gcp_project_id}] Role bindings for role [#{role}] do not contain any members. This test is Not Applicable." do
50+
skip "[#{gcp_project_id}] role bindings for role [#{role}] do not contain any members."
51+
end
52+
else
53+
describe "[#{gcp_project_id}] Admin role [#{role}]" do
54+
subject { role_bindings }
55+
its('members') { should_not include(/@[a-z][a-z0-9|-]{4,28}[a-z].iam.gserviceaccount.com/) }
56+
end
4957
end
5058
end
5159

inspec.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ copyright: "(c) 2020, Google, Inc."
1919
copyright_email: "[email protected]"
2020
license: "Apache-2.0"
2121
summary: "Inspec Google Cloud Platform Center for Internet Security Benchmark v1.1 Profile"
22-
version: 1.1.0-19
22+
version: 1.1.0-20
2323

2424
supports:
2525
- platform: gcp

0 commit comments

Comments
 (0)