Skip to content

Commit a9134fc

Browse files
authored
Added directions for Heimdall Lite (#59)
* added directions to README and Walkthough to create a json result and looad into Heimdall Lite * added default dummy value for the project_id * fixed indent issues in inspec.yml * fixed markdown syntax in README Signed-off-by: Aaron Lippold <lippold@gmail.com>
1 parent 059e1ff commit a9134fc

File tree

3 files changed

+170
-118
lines changed

3 files changed

+170
-118
lines changed

README.md

Lines changed: 85 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,41 @@ This is not an officially supported Google product. This code is intended to hel
1010

1111
The following GCP CIS v1.1.0 Benchmark Controls are not covered:
1212

13-
* Identity and Access Management 1.2 - "Ensure that multi-factor authentication is enabled for all non-service accounts"
14-
* Identity and Access Management 1.3 - "Ensure that Security Key Enforcement is enabled for all admin accounts"
15-
* Identity and Access Management 1.12 - "Ensure API keys are not created for a project"
16-
* Identity and Access Management 1.13 - "Ensure API keys are restricted to use by only specified Hosts and Apps"
17-
* Identity and Access Management 1.14 - "Ensure API keys are restricted to only APIs that application needs access"
18-
* Identity and Access Management 1.15 - "Ensure API keys are rotated every 90 days"
19-
* Cloud SQL Database Services 6.3 - "Ensure that MySql database instance does not allow anyone to connect with administrative privileges"
20-
* Cloud SQL Database Services 6.4 - "Ensure that MySQL Database Instance does not allows root login from any Host"
13+
- Identity and Access Management 1.2 - "Ensure that multi-factor authentication is enabled for all non-service accounts"
14+
- Identity and Access Management 1.3 - "Ensure that Security Key Enforcement is enabled for all admin accounts"
15+
- Identity and Access Management 1.12 - "Ensure API keys are not created for a project"
16+
- Identity and Access Management 1.13 - "Ensure API keys are restricted to use by only specified Hosts and Apps"
17+
- Identity and Access Management 1.14 - "Ensure API keys are restricted to only APIs that application needs access"
18+
- Identity and Access Management 1.15 - "Ensure API keys are rotated every 90 days"
19+
- Cloud SQL Database Services 6.3 - "Ensure that MySql database instance does not allow anyone to connect with administrative privileges"
20+
- Cloud SQL Database Services 6.4 - "Ensure that MySQL Database Instance does not allows root login from any Host"
2121

2222
## Usage
2323

24-
### Profile Attributes
24+
### Profile Inputs (see `inspec.yml` file)
2525

26-
* **gcp_project_id** - (Default: "", type: string) - The target GCP Project that must be specified.
27-
* **sa_key_older_than_seconds** - (Default: 7776000, type: int, CIS IAM 1.15) - The maximum allowed age of GCP User-managed Service Account Keys (90 days in seconds).
28-
* **kms_rotation_period_seconds** - (Default: 7776000, type: int, CIS IAM 1.10) - The maximum allowed age of KMS keys (90 days in seconds).
26+
This profile uses InSpec Inputs to make the tests more flexible. You are able to provide inputs at runtime either via the `cli` or via `YAML files` to help the profile work best in your deployment.
2927

28+
**pro tip**: Do not change the inputs in the `inspec.yml` file directly, either:
29+
30+
- update them via the cli - via the `--input` flag
31+
- pass them in via a YAML file as shown in the `Example` - via the `--input-file` flag
32+
33+
Further details can be found here: <https://docs.chef.io/inspec/inputs/>
34+
35+
### (Required) User Provided Inputs - via the CLI or Input Files
36+
37+
- **gcp_project_id** - (Default: null, type: String) - The target GCP Project you are scanning.
38+
39+
### (Optional) User Provided Inputs
40+
41+
- **bucket_logging_ignore_regex** - (type: String) - Ignore this bucket by regex from requiring logging to be enabled. Example: `-logging`
42+
- **sa_key_older_than_seconds** - (Default: 7776000, type: int, CIS IAM 1.15) - The maximum allowed age of GCP User-managed Service Account Keys (90 days in seconds).
43+
- **kms_rotation_period_seconds** - (Default: 7776000, type: int, CIS IAM 1.10) - The maximum allowed age of KMS keys (90 days in seconds).
3044

3145
### Cloud Shell Walkthrough
3246

33-
Use this Cloud Shell walkthrough for a hands-on example.
47+
Use this Cloud Shell Walkthrough for a hands-on example.
3448

3549
[![Open this project in Cloud Shell](http://gstatic.com/cloudssh/images/open-btn.png)](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/inspec-gcp-cis-benchmark&page=editor&tutorial=walkthrough.md)
3650

@@ -51,8 +65,8 @@ $ gcloud auth application-default login
5165
```
5266

5367
```
54-
# scan a project with this profile, replace <YOUR_PROJECT_ID> with your project ID
55-
$ inspec exec https://github.com/GoogleCloudPlatform/inspec-gcp-cis-benchmark.git -t gcp:// --input gcp_project_id=<YOUR_PROJECT_ID>
68+
# scan a project with this profile, replace {{project-id}} with your project ID
69+
$ inspec exec https://github.com/GoogleCloudPlatform/inspec-gcp-cis-benchmark.git -t gcp:// --input gcp_project_id={{project-id}} --reporter cli json:{{project-id}}_scan.json
5670
...snip...
5771
Profile Summary: 48 successful controls, 5 control failures, 7 controls skipped
5872
Test Summary: 166 successful, 7 failures, 7 skipped
@@ -61,62 +75,67 @@ Test Summary: 166 successful, 7 failures, 7 skipped
6175
### Required APIs
6276

6377
Consider these GCP projects, which may all be the same or different:
64-
* the project of the Service Account that's used to authenticate the scan
65-
* the project from which the benchmark is called
66-
* the project to be scanned
78+
79+
- the project of the Service Account that's used to authenticate the scan
80+
- the project from which the benchmark is called
81+
- the project to be scanned
6782

6883
The following GCP APIs should be enabled in **all** of these projects:
69-
* cloudkms.googleapis.com
70-
* cloudresourcemanager.googleapis.com
71-
* compute.googleapis.com
72-
* dns.googleapis.com
73-
* iam.googleapis.com
74-
* logging.googleapis.com
75-
* monitoring.googleapis.com
76-
* sqladmin.googleapis.com
77-
* storage-api.googleapis.com
78-
84+
85+
- cloudkms.googleapis.com
86+
- cloudresourcemanager.googleapis.com
87+
- compute.googleapis.com
88+
- dns.googleapis.com
89+
- iam.googleapis.com
90+
- logging.googleapis.com
91+
- monitoring.googleapis.com
92+
- sqladmin.googleapis.com
93+
- storage-api.googleapis.com
94+
7995
### Required Permissions
96+
8097
The following permissions are required to run the CIS benchmark profile:
8198

8299
On organization level:
83-
* resourcemanager.organizations.get
84-
* resourcemanager.projects.get
85-
* resourcemanager.projects.getIamPolicy
86-
* resourcemanager.folders.get
100+
101+
- resourcemanager.organizations.get
102+
- resourcemanager.projects.get
103+
- resourcemanager.projects.getIamPolicy
104+
- resourcemanager.folders.get
87105

88106
On project level:
89-
* cloudkms.cryptoKeys.get
90-
* cloudkms.cryptoKeys.getIamPolicy
91-
* cloudkms.cryptoKeys.list
92-
* cloudkms.keyRings.list
93-
* cloudsql.instances.get
94-
* cloudsql.instances.list
95-
* compute.firewalls.get
96-
* compute.firewalls.list
97-
* compute.instances.get
98-
* compute.instances.list
99-
* compute.networks.get
100-
* compute.networks.list
101-
* compute.projects.get
102-
* compute.regions.list
103-
* compute.sslPolicies.get
104-
* compute.sslPolicies.list
105-
* compute.subnetworks.get
106-
* compute.subnetworks.list
107-
* compute.targetHttpsProxies.get
108-
* compute.targetHttpsProxies.list
109-
* compute.zones.list
110-
* dns.managedZones.get
111-
* dns.managedZones.list
112-
* iam.serviceAccountKeys.list
113-
* iam.serviceAccounts.list
114-
* logging.logMetrics.list
115-
* logging.sinks.get
116-
* logging.sinks.list
117-
* monitoring.alertPolicies.list
118-
* resourcemanager.projects.get
119-
* resourcemanager.projects.getIamPolicy
120-
* storage.buckets.get
121-
* storage.buckets.getIamPolicy
122-
* storage.buckets.list
107+
108+
- cloudkms.cryptoKeys.get
109+
- cloudkms.cryptoKeys.getIamPolicy
110+
- cloudkms.cryptoKeys.list
111+
- cloudkms.keyRings.list
112+
- cloudsql.instances.get
113+
- cloudsql.instances.list
114+
- compute.firewalls.get
115+
- compute.firewalls.list
116+
- compute.instances.get
117+
- compute.instances.list
118+
- compute.networks.get
119+
- compute.networks.list
120+
- compute.projects.get
121+
- compute.regions.list
122+
- compute.sslPolicies.get
123+
- compute.sslPolicies.list
124+
- compute.subnetworks.get
125+
- compute.subnetworks.list
126+
- compute.targetHttpsProxies.get
127+
- compute.targetHttpsProxies.list
128+
- compute.zones.list
129+
- dns.managedZones.get
130+
- dns.managedZones.list
131+
- iam.serviceAccountKeys.list
132+
- iam.serviceAccounts.list
133+
- logging.logMetrics.list
134+
- logging.sinks.get
135+
- logging.sinks.list
136+
- monitoring.alertPolicies.list
137+
- resourcemanager.projects.get
138+
- resourcemanager.projects.getIamPolicy
139+
- storage.buckets.get
140+
- storage.buckets.getIamPolicy
141+
- storage.buckets.list

inspec.yml

Lines changed: 55 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,64 @@
1313
# limitations under the License.
1414

1515
name: inspec-gcp-cis-benchmark
16-
title: "Inspec GCP CIS 1.1 Benchmark"
17-
maintainer:
18-
copyright: Google
19-
copyright_email: copyright@google.com
20-
license: Apache-2.0
16+
title: "InSpec GCP CIS 1.1 Benchmark"
17+
maintainer: "Google Cloud Platform"
18+
copyright: "(c) 2020, Google, Inc."
19+
copyright_email: "copyright@google.com"
20+
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-19
23+
2324
supports:
2425
- platform: gcp
26+
2527
depends:
26-
- name: inspec-gcp-helpers
27-
url: https://github.com/GoogleCloudPlatform/inspec-gcp-helpers/archive/v1.0.7.tar.gz
28+
- name: inspec-gcp-helpers
29+
url: https://github.com/GoogleCloudPlatform/inspec-gcp-helpers/archive/v1.0.7.tar.gz
30+
2831
inputs:
29-
- name: gcp_project_id
30-
description: 'The GCP project identifier.'
31-
type: string
32-
value: "replace_with_your_gcp_project_id"
33-
- name: cis_version
34-
description: 'The short version of the GCP CIS Benchmark'
35-
value: '1.0'
36-
type: string
37-
- name: cis_url
38-
description: 'The URL to the GCP CIS Benchmark'
39-
value: 'https://www.cisecurity.org/benchmark/google_cloud_computing_platform/'
40-
type: string
41-
- name: sa_key_older_than_seconds
42-
description: 'How many seconds SA keys should not be older than'
43-
value: 7776000
44-
type: numeric
45-
- name: kms_rotation_period_seconds
46-
description: 'How many seconds KMS Keys should be last rotated (90 days)'
47-
value: 7776000
48-
type: numeric
49-
- name: bucket_logging_ignore_regex
50-
description: 'Ignore this bucket by regex from requiring logging to be enabled'
32+
# {{gcp_project_id}} and {{bucket_logging_ignore_regex}}
33+
# must be defined at runtime by the user
34+
- name: gcp_project_id
35+
description: "The GCP project identifier."
36+
type: String
37+
required: true
38+
value: 'aaa-bbb-ccc-ddd'
39+
5140
# example = "-logging"
52-
value: "replace-with-bucket-name-or-partial-match"
53-
type: string
54-
- name: gcp_gke_locations
55-
description: 'The list of regions and/or zone names where GKE clusters are running. An empty array searches all locations'
56-
type: array
57-
value:
58-
- ""
59-
- name: gce_zones
60-
description: 'The list of zone names where GCE instances are running. An empty array searches all locations'
61-
type: array
62-
value:
63-
- ""
41+
# "replace-with-bucket-name-or-partial-match"
42+
- name: bucket_logging_ignore_regex
43+
description: "Ignore this bucket by regex from requiring logging to be enabled"
44+
type: String
45+
required: false
46+
47+
- name: cis_version
48+
description: "The short version of the GCP CIS Benchmark"
49+
value: "1.0"
50+
type: String
51+
52+
- name: cis_url
53+
description: "The URL to the GCP CIS Benchmark"
54+
value: "https://www.cisecurity.org/benchmark/google_cloud_computing_platform/"
55+
type: String
56+
57+
- name: sa_key_older_than_seconds
58+
description: "How many seconds SA keys should not be older than"
59+
value: 7776000
60+
type: Numeric
61+
62+
- name: kms_rotation_period_seconds
63+
description: "How many seconds KMS Keys should be last rotated (90 days)"
64+
value: 7776000
65+
type: Numeric
66+
67+
- name: gcp_gke_locations
68+
description: "The list of regions and/or zone names where GKE clusters are running. An empty array searches all locations"
69+
type: Array
70+
value:
71+
- ""
72+
- name: gce_zones
73+
description: "The list of zone names where GCE instances are running. An empty array searches all locations"
74+
type: Array
75+
value:
76+
- ""

walkthrough.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
# Introduction to Running InSpec in Cloud Shell
22

3-
4-
## Let's get started!
3+
## Getting Started
54

65
This guide will show you how to install InSpec on your Cloud Shell instance and how to use InSpec to check the infrastructure in your Google Cloud Project against the CIS GCP Benchmark.
76

87
**Time to complete**: About 5 minutes
98

109
Click the **Start** button to move to the next step.
1110

12-
1311
## What is InSpec?
1412

1513
Before we jump in, let's briefly go over what InSpec can do.
1614

1715
[InSpec](https://github.com/inspec/inspec), a popular framework in the DevSecOps community, checks the configuration state of resources within virtual machines, containers, and cloud providers such as GCP, AWS, and Azure. InSpec's lightweight nature, approachable domain specific Language (DSL) and extensibility, make it a valuable tool for:
16+
1817
- Expressing compliance policies as code
1918
- Enabling development teams to add application-specific tests and assess the compliance of their applications to security policies before pushing changes to the production environment.
2019
- Automating compliance verification in CI/CD pipelines and as part of the release process
2120
- Unifying compliance assessments across multiple cloud providers and on premises environments
2221

2322
Continue on to the next step to start setting up your tutorial.
2423

25-
26-
## Install InSpec
24+
## Installing InSpec
2725

2826
InSpec is distributed as a Ruby gem and your Cloud Shell instance has a Ruby environment already configured. All you need to do is install the InSpec gem:
2927

@@ -35,7 +33,7 @@ gem install inspec-bin --no-document --quiet
3533

3634
Next, you’ll select a Google Cloud Project to scan with InSpec.
3735

38-
## Select a Google Cloud Project to scan
36+
## Select the Google Cloud Project to scan
3937

4038
Pick a project where you have sufficient permissions. We'll use your user credentials in Cloud Shell to scan the project.
4139

@@ -45,20 +43,19 @@ The project you selected is **{{project-id}}**. If this is blank, make sure you
4543

4644
Hit Next after you successfully selected your project.
4745

48-
4946
## Scan Your Project
5047

5148
To scan your project against the CIS GCP Benchmark with InSpec, run:
5249

5350
```bash
54-
CHEF_LICENSE=accept-no-persist inspec exec https://github.com/GoogleCloudPlatform/inspec-gcp-cis-benchmark.git -t gcp:// --input gcp_project_id={{project-id}}
51+
CHEF_LICENSE=accept-no-persist inspec exec https://github.com/GoogleCloudPlatform/inspec-gcp-cis-benchmark.git -t gcp:// --input gcp_project_id={{project-id}} --reporter cli json:{{project-id}}_scan.json
5552
```
5653

5754
This should take about two minutes to complete.
5855

5956
Once complete, your terminal output should look something like this:
6057

61-
```
58+
```bash
6259
Profile Summary: 14 successful controls, 34 control failures, 7 controls skipped
6360
Test Summary: 107 successful, 88 failures, 7 skipped
6461
```
@@ -69,10 +66,33 @@ To scan another project, press the Previous button and select a different projec
6966

7067
Press Next if you're done scanning projects.
7168

69+
## Review your scan results with [Heimdall-Lite](https://heimdall-lite.mitre.org)
70+
71+
### What is Heimdall-Lite?
72+
73+
Heimdall-Lite is a great open-source Security Results Viewer by the [MITRE Corporation](https://www.mitre.org) for reviewing your GCP CIS Benchmark scan results.
74+
75+
Heimdall-Lite is one of many MITRE [Security Automation Framework](https://saf.mitre.org) (SAF) Supporting Tools working to enhance the Security Automation and DevSecOps communities.
76+
77+
The [MITRE SAF](https://saf.mitre.org) is an open-source community partnership including Government, Industry and the Open Community working together to make truly automated security a reality. It also hosts many InSpec profiles created by the SAF and references to many partner developed profiles - **_including this one_**.
78+
79+
**Tip**: MITRE hosts Heimdall-Lite on GitHub pages, but you can easily run it in your environment via Docker or NPM or whatever suites your need. See the projects GitHub more information.
80+
81+
### Download your JSON formatted results
82+
83+
1. Right click on your `myscan.json` file
84+
2. Then select `Download` to save the `{{project-id}}_scan.json` file locally
85+
86+
### Go to Heimdall Lite and Load your JSON formatted Results
87+
88+
1. Navigate to [Heimdall Lite](https://heimdall-lite.mitre.org)
89+
2. Click `Local Files` on the left side of the loader
90+
3. Drag and Drop or select and load your `{{project-id}}_scan.json` file to review your results.
91+
7292
## Congratulations
7393

7494
<walkthrough-conclusion-trophy></walkthrough-conclusion-trophy>
7595

7696
You’re all set!
7797

78-
You can now scan your Google Cloud Projects with InSpec directly from Cloud Shell.
98+
You can now scan your Google Cloud Projects with InSpec directly from Cloud Shell.

0 commit comments

Comments
 (0)