Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Add inspec support for ACM level #472

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions docs/resources/google_access_context_manager_access_level.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
title: About the google_access_context_manager_access_level resource
platform: gcp
---

## Syntax
A `google_access_context_manager_access_level` is used to test a Google AccessLevel resource

## Examples
```

policy_name = google_access_context_manager_access_policies(org_id: '190694428152').names.first

describe google_access_context_manager_access_level(parent: policy_name, name: "ip_subnet") do
it { should exist }
its('title') { should cmp "ip_subnet" }
its('basic.conditions.size') { should cmp 1 }
its('basic.conditions.first.ip_subnetworks') { should include "192.0.2.0/24" }
end

describe google_access_context_manager_access_level(parent: policy_name, name: "none") do
it { should_not exist }
end

```

## Properties
Properties that can be accessed from the `google_access_context_manager_access_level` resource:


* `title`: Human readable title. Must be unique within the Policy.

* `description`: Description of the AccessLevel and its use. Does not affect behavior.

* `basic`: A set of predefined conditions for the access level and a combining function.

* `combining_function`: How the conditions list should be combined to determine if a request is granted this AccessLevel. If AND is used, each Condition in conditions must be satisfied for the AccessLevel to be applied. If OR is used, at least one Condition in conditions must be satisfied for the AccessLevel to be applied.
Possible values:
* AND
* OR

* `conditions`: A set of requirements for the AccessLevel to be granted.

* `ip_subnetworks`: A list of CIDR block IP subnetwork specification. May be IPv4 or IPv6. Note that for a CIDR IP address block, the specified IP address portion must be properly truncated (i.e. all the host bits must be zero) or the input is considered malformed. For example, "192.0.2.0/24" is accepted but "192.0.2.1/24" is not. Similarly, for IPv6, "2001:db8::/32" is accepted whereas "2001:db8::1/32" is not. The originating IP of a request must be in one of the listed subnets in order for this Condition to be true. If empty, all IP addresses are allowed.

* `required_access_levels`: A list of other access levels defined in the same Policy, referenced by resource name. Referencing an AccessLevel which does not exist is an error. All access levels listed must be granted for the Condition to be true. Format: accessPolicies/{policy_id}/accessLevels/{short_name}

* `members`: An allowed list of members (users, service accounts). Using groups is not supported yet. The signed-in user originating the request must be a part of one of the provided members. If not specified, a request may come from any user (logged in/not logged in, not present in any groups, etc.). Formats: `user:{emailid}`, `serviceAccount:{emailid}`

* `negate`: Whether to negate the Condition. If true, the Condition becomes a NAND over its non-empty fields, each field must be false for the Condition overall to be satisfied. Defaults to false.

* `device_policy`: Device specific restrictions, all restrictions must hold for the Condition to be true. If not specified, all devices are allowed.

* `require_screen_lock`: Whether or not screenlock is required for the DevicePolicy to be true. Defaults to false.

* `allowed_encryption_statuses`: A list of allowed encryptions statuses. An empty list allows all statuses.

* `allowed_device_management_levels`: A list of allowed device management levels. An empty list allows all management levels.

* `os_constraints`: A list of allowed OS versions. An empty list allows all types and all versions.

* `minimum_version`: The minimum allowed OS version. If not set, any version of this OS satisfies the constraint. Format: "major.minor.patch" such as "10.5.301", "9.2.1".

* `os_type`: The operating system type of the device.
Possible values:
* OS_UNSPECIFIED
* DESKTOP_MAC
* DESKTOP_WINDOWS
* DESKTOP_LINUX
* DESKTOP_CHROME_OS

* `require_admin_approval`: Whether the device needs to be approved by the customer admin.

* `require_corp_owned`: Whether the device needs to be corp owned.

* `regions`: The request must originate from one of the provided countries/regions. Format: A valid ISO 3166-1 alpha-2 code.

* `custom`: Custom access level conditions are set using the Cloud Common Expression Language to represent the necessary conditions for the level to apply to a request. See CEL spec at: https://github.com/google/cel-spec.

* `expr`: Represents a textual expression in the Common Expression Language (CEL) syntax. CEL is a C-like expression language. This page details the objects and attributes that are used to the build the CEL expressions for custom access levels - https://cloud.google.com/access-context-manager/docs/custom-access-level-spec.

* `expression`: Textual representation of an expression in Common Expression Language syntax.

* `title`: Title for the expression, i.e. a short string describing its purpose.

* `description`: Description of the expression

* `location`: String indicating the location of the expression for error reporting, e.g. a file name and a position in the file

* `parent`: Name of the parent access policy

* `name`: Name of the access level


## GCP Permissions
35 changes: 35 additions & 0 deletions docs/resources/google_access_context_manager_access_levels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: About the google_access_context_manager_access_levels resource
platform: gcp
---

## Syntax
A `google_access_context_manager_access_levels` is used to test a Google AccessLevel resource

## Examples
```

policy_name = google_access_context_manager_access_policies(org_id: '190694428152').names.first

describe google_access_context_manager_access_levels(parent: policy_name) do
its('names') { should include "ip_subnet" }
end

```

## Properties
Properties that can be accessed from the `google_access_context_manager_access_levels` resource:

See [google_access_context_manager_access_level.md](google_access_context_manager_access_level.md) for more detailed information
* `titles`: an array of `google_access_context_manager_access_level` title
* `descriptions`: an array of `google_access_context_manager_access_level` description
* `basics`: an array of `google_access_context_manager_access_level` basic
* `customs`: an array of `google_access_context_manager_access_level` custom
* `parents`: an array of `google_access_context_manager_access_level` parent
* `names`: an array of `google_access_context_manager_access_level` name

## Filter Criteria
This resource supports all of the above properties as filter criteria, which can be used
with `where` as a block or a method.

## GCP Permissions
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'google/accesscontextmanager/property/accesslevel_basic_conditions'
module GoogleInSpec
module AccessContextManager
module Property
class AccessLevelBasic
attr_reader :combining_function

attr_reader :conditions

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@combining_function = args['combiningFunction']
@conditions = GoogleInSpec::AccessContextManager::Property::AccessLevelBasicConditionsArray.parse(args['conditions'], to_s)
end

def to_s
"#{@parent_identifier} AccessLevelBasic"
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'google/accesscontextmanager/property/accesslevel_basic_conditions_device_policy'
require 'google/accesscontextmanager/property/accesslevel_basic_conditions_device_policy_os_constraints'
module GoogleInSpec
module AccessContextManager
module Property
class AccessLevelBasicConditions
attr_reader :ip_subnetworks

attr_reader :required_access_levels

attr_reader :members

attr_reader :negate

attr_reader :device_policy

attr_reader :regions

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@ip_subnetworks = args['ipSubnetworks']
@required_access_levels = args['requiredAccessLevels']
@members = args['members']
@negate = args['negate']
@device_policy = GoogleInSpec::AccessContextManager::Property::AccessLevelBasicConditionsDevicePolicy.new(args['devicePolicy'], to_s)
@regions = args['regions']
end

def to_s
"#{@parent_identifier} AccessLevelBasicConditions"
end
end

class AccessLevelBasicConditionsArray
def self.parse(value, parent_identifier)
return if value.nil?
return AccessLevelBasicConditions.new(value, parent_identifier) unless value.is_a?(::Array)
value.map { |v| AccessLevelBasicConditions.new(v, parent_identifier) }
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'google/accesscontextmanager/property/accesslevel_basic_conditions_device_policy_os_constraints'
module GoogleInSpec
module AccessContextManager
module Property
class AccessLevelBasicConditionsDevicePolicy
attr_reader :require_screen_lock

attr_reader :allowed_encryption_statuses

attr_reader :allowed_device_management_levels

attr_reader :os_constraints

attr_reader :require_admin_approval

attr_reader :require_corp_owned

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@require_screen_lock = args['requireScreenlock']
@allowed_encryption_statuses = args['allowedEncryptionStatuses']
@allowed_device_management_levels = args['allowedDeviceManagementLevels']
@os_constraints = GoogleInSpec::AccessContextManager::Property::AccessLevelBasicConditionsDevicePolicyOsConstraintsArray.parse(args['osConstraints'], to_s)
@require_admin_approval = args['requireAdminApproval']
@require_corp_owned = args['requireCorpOwned']
end

def to_s
"#{@parent_identifier} AccessLevelBasicConditionsDevicePolicy"
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
module GoogleInSpec
module AccessContextManager
module Property
class AccessLevelBasicConditionsDevicePolicyOsConstraints
attr_reader :minimum_version

attr_reader :os_type

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@minimum_version = args['minimumVersion']
@os_type = args['osType']
end

def to_s
"#{@parent_identifier} AccessLevelBasicConditionsDevicePolicyOsConstraints"
end
end

class AccessLevelBasicConditionsDevicePolicyOsConstraintsArray
def self.parse(value, parent_identifier)
return if value.nil?
return AccessLevelBasicConditionsDevicePolicyOsConstraints.new(value, parent_identifier) unless value.is_a?(::Array)
value.map { |v| AccessLevelBasicConditionsDevicePolicyOsConstraints.new(v, parent_identifier) }
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'google/accesscontextmanager/property/accesslevel_custom_expr'
module GoogleInSpec
module AccessContextManager
module Property
class AccessLevelCustom
attr_reader :expr

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@expr = GoogleInSpec::AccessContextManager::Property::AccessLevelCustomExpr.new(args['expr'], to_s)
end

def to_s
"#{@parent_identifier} AccessLevelCustom"
end
end
end
end
end
Loading