Skip to content

Commit cbe48df

Browse files
feat(CG-1298): add GCP CIS 1.30 2.13
1 parent 3040547 commit cbe48df

4 files changed

Lines changed: 112 additions & 1 deletion

File tree

src/gcp/cis-1.3.0/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Policy Pack based on the GCP Foundations 1.3.0 benchmark provided by the [Center
8282
| GCP CIS 2.10 | Ensure that the log metric filter and alerts exist for Cloud Storage IAM permission changes |
8383
| GCP CIS 2.11 | Ensure that the log metric filter and alerts exist for SQL instance configuration changes |
8484
| GCP CIS 2.12 | Ensure that Cloud DNS logging is enabled for all VPC networks |
85+
| GCP CIS 2.13 | Ensure Cloud Asset Inventory Is Enabled |
8586
| GCP CIS 3.1 | Ensure that the default network does not exist in a project |
8687
| GCP CIS 3.2 | Ensure legacy networks do not exist for a project |
8788
| GCP CIS 3.3 | Ensure that DNSSEC is enabled for Cloud DNS |
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
export default {
2+
id: 'gcp-cis-1.3.0-2.13',
3+
title:
4+
'GCP CIS 2.13 Ensure Cloud Asset Inventory Is Enabled',
5+
description: `GCP Cloud Asset Inventory is services that provides a historical view of GCP resources and
6+
IAM policies through a time-series database. The information recorded includes metadata
7+
on Google Cloud resources, metadata on policies set on Google Cloud projects or resources,
8+
and runtime information gathered within a Google Cloud resource.`,
9+
audit: `**From Console:
10+
11+
Ensure that the Cloud Asset API is enabled:**
12+
13+
1. Go to API & Services/Library by visiting
14+
https://console.cloud.google.com/apis/library
15+
2. Search for Cloud Asset API and select the result for Cloud Asset API
16+
3. Ensure that API Enabled is displayed.
17+
18+
**From Command Line:
19+
20+
Ensure that the Cloud Asset API is enabled:**
21+
22+
1. Query enabled services:
23+
24+
gcloud services list --enabled --filter=name:cloudasset.googleapis.com
25+
26+
If the API is listed, then it is enabled. If the response is Listed 0 items the API is not enabled.`,
27+
rationale: 'The GCP resources and IAM policies captured by GCP Cloud Asset Inventory enables security analysis, resource change tracking, and compliance auditing.',
28+
remediation: `**From Console:
29+
30+
Enable the Cloud Asset API:**
31+
32+
1. Go to API & Services/Library by visiting
33+
https://console.cloud.google.com/apis/library
34+
2. Search for Cloud Asset API and select the result for Cloud Asset API
35+
3. Click the ENABLE button.
36+
37+
**From Command Line:
38+
39+
Enable the Cloud Asset API:**
40+
41+
1. Enable the Cloud Asset API through the services interface:
42+
43+
gcloud services enable cloudasset.googleapis.com
44+
45+
**Default Value:**
46+
47+
The Cloud Asset Inventory API is disabled by default in each project
48+
`,
49+
references: ['https://cloud.google.com/asset-inventory/docs'],
50+
gql: `{
51+
querygcpAsset {
52+
id
53+
__typename
54+
}
55+
}`,
56+
resource: 'querygcpProject[*]',
57+
severity: 'unknown',
58+
check: ({ resource }: any) => {
59+
const { assets } = resource
60+
return !!assets
61+
},
62+
}

src/gcp/cis-1.3.0/rules/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import Gcp_CIS_130_29 from './gcp-cis-1.3.0-2.9'
2525
import Gcp_CIS_130_210 from './gcp-cis-1.3.0-2.10'
2626
import Gcp_CIS_130_211 from './gcp-cis-1.3.0-2.11'
2727
import Gcp_CIS_130_212 from './gcp-cis-1.3.0-2.12'
28+
import Gcp_CIS_130_213 from './gcp-cis-1.3.0-2.13'
2829
import Gcp_CIS_130_31 from './gcp-cis-1.3.0-3.1'
2930
import Gcp_CIS_130_32 from './gcp-cis-1.3.0-3.2'
3031
import Gcp_CIS_130_33 from './gcp-cis-1.3.0-3.3'
@@ -101,6 +102,7 @@ export default [
101102
Gcp_CIS_130_210,
102103
Gcp_CIS_130_211,
103104
Gcp_CIS_130_212,
105+
Gcp_CIS_130_213,
104106
Gcp_CIS_130_31,
105107
Gcp_CIS_130_32,
106108
Gcp_CIS_130_33,

src/gcp/cis-1.3.0/tests/gcp-cis-1.3.0-2.x.test.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import Gcp_CIS_130_29 from '../rules/gcp-cis-1.3.0-2.9'
1515
import Gcp_CIS_130_210 from '../rules/gcp-cis-1.3.0-2.10'
1616
import Gcp_CIS_130_211 from '../rules/gcp-cis-1.3.0-2.11'
1717
import Gcp_CIS_130_212 from '../rules/gcp-cis-1.3.0-2.12'
18+
import Gcp_CIS_130_213 from '../rules/gcp-cis-1.3.0-2.13'
1819
import { initRuleEngine } from '../../../utils/test'
1920

2021
const Gcp_CIS_130_24_Filter =
@@ -78,10 +79,15 @@ export interface LogSink {
7879
destination?: string
7980
}
8081

82+
export interface Asset {
83+
id: string
84+
}
85+
8186
export interface QuerygcpProject {
8287
id: string
83-
logSinks: LogSink[]
88+
logSinks?: LogSink[]
8489
logBuckets?: LogBucket[]
90+
assets?: Asset[]
8591
}
8692

8793
export interface AuditLogConfig {
@@ -1263,4 +1269,44 @@ describe('CIS Google Cloud Platform Foundations: 1.3.0', () => {
12631269
await test212Rule(false, false, Result.FAIL)
12641270
})
12651271
})
1272+
1273+
describe('GCP CIS 2.13 Ensure Cloud Asset Inventory Is Enabled', () => {
1274+
const test213Rule = async (
1275+
hasAsset: boolean,
1276+
expectedResult: Result
1277+
): Promise<void> => {
1278+
// Arrange
1279+
const data: CIS2xQueryResponse = {
1280+
querygcpProject: [
1281+
{
1282+
id: cuid(),
1283+
assets: hasAsset? [
1284+
{
1285+
id: cuid(),
1286+
},
1287+
]
1288+
: undefined,
1289+
},
1290+
],
1291+
1292+
}
1293+
1294+
// Act
1295+
const [processedRule] = await rulesEngine.processRule(
1296+
Gcp_CIS_130_213 as Rule,
1297+
{ ...data }
1298+
)
1299+
1300+
// Asserts
1301+
expect(processedRule.result).toBe(expectedResult)
1302+
}
1303+
1304+
test('No Security Issue when there is an inbound rule with dns logging enabled for all VPC networks', async () => {
1305+
await test213Rule(true, Result.PASS)
1306+
})
1307+
1308+
test('Security Issue when there is an inbound rule that does not have dns logging enabled for all VPC networks', async () => {
1309+
await test213Rule(false, Result.FAIL)
1310+
})
1311+
})
12661312
})

0 commit comments

Comments
 (0)