Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates needed to fully support the CIS AWS Foundations Benchmark v2.0.0 #981

Draft
wants to merge 93 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
a8cd6fb
recreateing #977 on a fresh pull from main
aaronlippold Nov 14, 2023
4766dce
adding missing library
aaronlippold Nov 14, 2023
1ce0e5a
Fixes to AWS Account and Backend
aaronlippold Nov 14, 2023
fa773f9
standardized classes and removed filter tables
aaronlippold Nov 18, 2023
2899832
moved account singular resources into seperate files
aaronlippold Nov 18, 2023
04bc284
fixed typo in resource_id function
aaronlippold Nov 18, 2023
ff7fffd
updated aws-account file name to match resource name
aaronlippold Nov 18, 2023
39afb10
updated aws alternate account file names to match resources
aaronlippold Nov 18, 2023
16ba41c
Added documentation and alias for resources
aaronlippold Nov 18, 2023
3ec62d0
Removed pry from resources
aaronlippold Nov 18, 2023
018f363
repulled upsteam copy of docs
aaronlippold Nov 18, 2023
972c118
reusing updated aws-billing-contact resource
aaronlippold Nov 19, 2023
c4d9933
Updated individual resources and added alternate
aaronlippold Nov 19, 2023
7d55c44
exposed the instance data for easier use by end user
aaronlippold Nov 19, 2023
7b5ea63
updated docs on aws-ec2-instance to include the instance properity
aaronlippold Nov 19, 2023
06652c8
updated docs on aws-ec2-instance to include the instance properity
aaronlippold Nov 19, 2023
d1a54e8
removed pry from requires
aaronlippold Nov 19, 2023
c27b2e8
updated examples
aaronlippold Nov 22, 2023
3672957
Start of Access Analyzer Plural Resource
aaronlippold Nov 22, 2023
574dd55
Updates to support CIS AWS Foundations 1.20
aaronlippold Nov 23, 2023
f1f6eed
minor updates for string interpolation fixes
aaronlippold Nov 23, 2023
e732d6f
fixed formating of non-interpolated strings
aaronlippold Nov 23, 2023
8a98798
Minor fixes
aaronlippold Nov 24, 2023
7106b07
removed commented lines
aaronlippold Nov 24, 2023
e0778ce
adding versioning hashie mash to aws_s3_bucket for convenience
wdower Nov 28, 2023
74b5748
adding missing hashie require
wdower Nov 28, 2023
c0d4916
exposing versioning as an attr
wdower Nov 28, 2023
3bb87df
fixing gemfile, adding a public? method to rds resource
wdower Nov 29, 2023
5660ba5
debugging null case for aws return with no rds instances
aaronlippold Nov 29, 2023
5af3282
returning the resource to standard sans the updated exist function
aaronlippold Nov 30, 2023
1ec68a9
added general securityhub resource
aaronlippold Dec 1, 2023
6e68bc0
adding event_selectors attr to cloudtrail
wdower Dec 1, 2023
317dac0
added docs for the aws_securityhub resource and added extra alias'
aaronlippold Dec 1, 2023
ec13a0c
- added gemspec-util.sh
aaronlippold Dec 3, 2023
ec6b2e5
- added gemspec-util.sh
aaronlippold Dec 3, 2023
6f4aa8c
Pulled in all gem updates from our train-aws PR
aaronlippold Dec 3, 2023
cf2c0f6
updated methods
aaronlippold Dec 3, 2023
b407565
prevent-public-access-by-bucket and ...-by-account should be working …
aaronlippold Dec 3, 2023
08c393c
Docs for `prevent_public_access` and 'prevent_public_access_via_account`
aaronlippold Dec 3, 2023
8508208
minor linting and some unneeded assignments
aaronlippold Dec 3, 2023
96238e4
fixed rubocop error - W: Lint/DuplicateBranch: Duplicate branch body …
aaronlippold Dec 3, 2023
2951f87
reverted cloudtrail resource for now to keep ci passing
aaronlippold Dec 4, 2023
12e38b1
wip on cloudtrail saner event selector functions
wdower Dec 4, 2023
1580b88
wip cloudtrail
wdower Dec 5, 2023
e4ec3b8
working functions for monitoring reads and writes of resource types
wdower Dec 5, 2023
6a8e6cc
removing errant puts statement
wdower Dec 5, 2023
b8c4d66
linting cloudtrail resource, adding macie resource first try
wdower Dec 5, 2023
9a99e26
small fix
aaronlippold Dec 5, 2023
88a2a58
small changes to the start of the aws_macie base resource
aaronlippold Dec 6, 2023
cf3345f
- fixed aws-backend catch errros by putting back to old style
aaronlippold Dec 6, 2023
a05637a
linting
aaronlippold Dec 6, 2023
7a8a7bb
fixed the param being passed to get_events
aaronlippold Dec 6, 2023
db8981f
made to_s an alias to avoid duplicate code
wdower Dec 6, 2023
4fa53dc
fixing alias in primary contact, fixing resource_id and to_s in aws_i…
wdower Dec 6, 2023
a44b72c
catching a new AWS error for IAM, initializing policy to nil in aws_i…
wdower Dec 6, 2023
8645735
updating kms display_name to expose it and set it equal to a human-fr…
wdower Dec 6, 2023
46b1949
updated resources to account for govcloud api access
aaronlippold Dec 7, 2023
5cbd6d7
rubocop:lint
aaronlippold Dec 7, 2023
6327bf8
added notes file
aaronlippold Dec 7, 2023
6713e85
rubocop:lint
aaronlippold Dec 7, 2023
664b18a
errors in macie
aaronlippold Dec 7, 2023
91157d1
adding the Network Seahorse Error to backend and contact resources
aaronlippold Dec 8, 2023
fb950c3
updating error catch for seahorse
aaronlippold Dec 8, 2023
a4223c0
adding ebs encryption matcher to aws_region
wdower Dec 8, 2023
fda831a
removing unneeded private function
aaronlippold Dec 9, 2023
67010a0
fixing proc processors on csv parser in aws_iam_credential_report
aaronlippold Dec 10, 2023
6ba3c10
added rescue for NoSuchEntity in aws_iam_password_policy
wdower Dec 11, 2023
3fb10d7
forgot to save prior edits to aws_iam_password_policy
wdower Dec 11, 2023
052f8f2
built out better has_acl_entry_value? for aws_network_acl
wdower Dec 11, 2023
d0cb116
forgot to save prior edits to aws_network_acl
wdower Dec 11, 2023
aac9edd
linting
wdower Dec 12, 2023
f2f2856
refactoring network_acl to use a filtertable for the acl rules for wa…
wdower Dec 12, 2023
5dabefd
adding better example for aws_network_acl
wdower Dec 12, 2023
c634966
better example formatting
wdower Dec 12, 2023
0b93fc4
linting
wdower Dec 12, 2023
9963bc4
cleaned up the of our filterTable helper
aaronlippold Dec 12, 2023
b45eddc
removed pry from testing
aaronlippold Dec 12, 2023
b2e9985
updating cloudtrail docs
wdow Dec 15, 2023
e47ebdb
adding docs for aws_iam_access_analyzer
wdower Dec 15, 2023
87b6fb7
fixing incorrect action in the permissions section of aw_iam_group
wdower Dec 15, 2023
2f68fbc
adding permissions section to aws_iam_access_analyzers
wdower Dec 15, 2023
2e24061
adding docs for aws_iam_credential_report
wdower Dec 15, 2023
75aa2a8
added a jobs filtertable to macie resource
wdower Dec 18, 2023
6bf7ec2
rounding out macie with more filtertables for findings and buckets --…
wdower Dec 19, 2023
e2844d0
updating cloudtrail function for mgmt events to understand advanced e…
wdower Dec 19, 2023
7486e24
working out findings table in macie
wdower Dec 19, 2023
d0c4f65
updating cloudtrail mgmt events function
wdower Dec 19, 2023
4444c6b
removing errant foobar
wdower Dec 19, 2023
13b6cba
full macie resource
wdower Dec 21, 2023
428c2a5
removing a bunch of complexity from macie because the filtertable bas…
wdower Dec 21, 2023
c02ed57
removing unused function from macie, privating the data fetcher
wdower Dec 21, 2023
4fafc06
doc for macie
wdower Dec 21, 2023
0c0280c
ran linter
wdower Jan 12, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Gemfile.lock
inspec.lock
.kitchen
*.code-workspace
*.plan
*.tfstate*
local
Expand Down
15 changes: 8 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'
source "https://rubygems.org"

gem 'bundle'
gem "bundle"
# Note that 'aws-sdk' pulls in a large number of libraries, choose explicitly those to include instead
# gem 'aws-sdk', '~> 3'
#
Expand All @@ -11,9 +11,10 @@ gem 'bundle'
# In the mean time the gem can be added here for local development

# Use Latest Inspec
gem 'inspec-bin'
gem "inspec-bin"
gem "train-aws", git: 'https://github.com/mitre/train-aws.git', branch: 'al/dep-updates'

gem 'rubocop', '~> 1.25.1', require: false
gem "rubocop", "~> 1.25.1", require: false

group :test do
gem "chefstyle", "~> 2.2.2"
Expand All @@ -22,7 +23,7 @@ group :test do
end

group :development do
gem 'rake'
gem 'minitest'
gem 'pry-byebug'
gem "rake"
gem "minitest"
gem "pry-byebug"
end
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ shell_tester:
docker-compose run --rm --entrypoint bash tester

logout:
docker-compose run --rm aws rm -rf /app/.aws
docker-compose run --rm aws rm -rf /app/.aws

113 changes: 113 additions & 0 deletions docs-chef-io/content/inspec/resources/aws_alternate_contact.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
+++
title = "aws_alternate_contact Resource"
platform = "aws"
draft = false
gh_repo = "inspec-aws"

[menu.inspec]
title = "aws_alternate_contact"
identifier = "inspec/resources/aws/aws_alternate_contact Resource"
parent = "inspec/resources/aws"
+++

Use the `aws_alternate_contact` InSpec audit resource to test properties of the alternate contact information associated with your account.

For additional information, including details on parameters and properties, see the [AWS documentation on the alternate contact information associated with your account](https://docs.aws.amazon.com/accounts/latest/reference/manage-acct-update-contact-alternate.html). Technical details on the data structure can be found for the [api documentation.](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Account/Client.html#get_contact_information-instance_method)

## Installation

{{% inspec_aws_install %}}

## Syntax

The `aws_alternate_contact` resource allows the testing of the alternate contact information associated with your account.

```ruby
describe aws_alternate_contact do
it { should exist }
end
```

## Parameters

`type` _(required)_

: This resource accepts a single parameter, the type of the alternate contact type.
This can be passed either as a string or as a `type: 'value'` key-value entry in a hash. Valid types are 'billing', 'operations' and 'security'

## Properties


`api_response` (Struct)
: Returns the api response from our call to the aws api as a struct.

`raw_data` (Hash)
: Returns a transformed Hash of Strings of the data associated with the alternate contact.

`aws_account_id` (String)
: 12-digit account ID number of the Amazon Web Services account associated with the alternate contact.

`name` (String)
: Specifies the full name of the alternate contact.

`title` (String)
: Specifies the full name of the alternate contact.

`email_address` (String)
: Specifies the full name of the alternate contact.

`phone_number` (String)
: Specifies the phone number associated with the alternate contact.

## Examples

The following examples show how to use this InSpec audit resource.

**Test that a alternate contact exists for the aws account.**

```ruby
describe aws_alternate_contact do
it { should exist }
end
```

**Test that the alternate contact is set and the values for its full name and first address line are set as expected.**

```ruby
describe aws_alternate_contact(type: 'billing') do
it { should be_configured }
its('name') { should cmp 'John Smith' }
its('title') { should cmp 'Money Guy' }
end
```
```ruby
describe aws_alternate_contact('security') do
it { should exist }
its('name') { should cmp 'Jane Smith' }
its('title') { should cmp 'Security Gal' }
end
```

## Matchers

{{% inspec_matchers_link %}}

### exist (alias of configured)

Use `should` to test if the aws account has a alternate contact configured.

```ruby
it { should exist }
```

### configured

The `configured` matcher tests if the described alternate contact is set and configured for the aws account by returning `true` if the api response is not null or data exists in the raw data.

```ruby
it { should be_configured }
```

## AWS Permissions

{{% aws_permissions_principal action="Aws::Account::Types::GetAlternateContactResponse" %}}
103 changes: 103 additions & 0 deletions docs-chef-io/content/inspec/resources/aws_billing_contact.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
+++
title = "aws_billing_contact Resource"
platform = "aws"
draft = false
gh_repo = "inspec-aws"

[menu.inspec]
title = "aws_billing_contact"
identifier = "inspec/resources/aws/aws_billing_contact Resource"
parent = "inspec/resources/aws"
+++

Use the `aws_billing_contact` InSpec audit resource to test properties of the billing contact information associated with your account.

For additional information, including details on parameters and properties, see the [AWS documentation on the billing contact information associated with your account](https://docs.aws.amazon.com/accounts/latest/reference/manage-acct-update-contact-billing.html). Technical details on the data structure can be found for the [api documentation.](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Account/Client.html#get_contact_information-instance_method)

## Installation

{{% inspec_aws_install %}}

## Syntax

The `aws_billing_contact` resource allows the testing of the billing contact information associated with your account.

```ruby
describe aws_billing_contact do
it { should exist }
end
```

## Parameters

This resources does not take any parameters at this time.

## Properties


`api_response` (Struct)
: Returns the api response from our call to the aws api as a struct.

`raw_data` (Hash)
: Returns a transformed Hash of Strings of the data associated with the billing contact.

`aws_account_id` (String)
: 12-digit account ID number of the Amazon Web Services account associated with the billing contact.

`name` (String)
: Specifies the full name of the billing contact.

`title` (String)
: Specifies the full name of the billing contact.

`email_address` (String)
: Specifies the full name of the billing contact.

`phone_number` (String)
: Specifies the phone number associated with the billing contact.

## Examples

The following examples show how to use this InSpec audit resource.

**Test that a billing contact exists for the aws account.**

```ruby
describe aws_billing_contact do
it { should exist }
end
```

**Test that the billing contact is set and the values for its full name and first address line are set as expected.**

```ruby
describe aws_billing_contact do
it { should be_configured }
its('name') { should cmp 'John Smith' }
its('title') { should cmp 'Money Guy' }
end
```

## Matchers

{{% inspec_matchers_link %}}

### exist (alias of configured)

Use `should` to test if the aws account has a billing contact configured.

```ruby
it { should exist }
```

### configured

The `configured` matcher tests if the described billing contact is set and configured for the aws account by returning `true` if the api response is not null or data exists in the raw data.

```ruby
it { should be_configured }
```

## AWS Permissions

{{% aws_permissions_principal action="Aws::Account::Types::GetAlternateContactResponse" %}}
29 changes: 29 additions & 0 deletions docs-chef-io/content/inspec/resources/aws_cloudtrail_trail.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ describe aws_cloudtrail_trail('TRAIL_NAME') do
end
```

**Test if a trail is monitoring an AWS object type:**

```ruby
describe aws_cloudtrail_trail('TRAIL_NAME') do
it { should be_monitoring_read("AWS::S3::Object") }
it { should be_monitoring_write("AWS::S3::Object") }
end
```

## Matchers

{{% inspec_matchers_link %}}
Expand Down Expand Up @@ -192,6 +201,26 @@ describe aws_cloudtrail_trail('TRAIL_NAME') do
end
```

### be_monitoring_read

The test will pass if the identified trail is monitoring read events on the given AWS object type (if the trail is only monitoring one ARN of that object type, the test will fail).

```ruby
describe aws_cloudtrail_trail('TRAIL_NAME') do
it { should be_monitoring_read("AWS::S3::Object") }
end
```

### be_monitoring_write

The test will pass if the identified trail is monitoring write events on the given AWS object type (if the trail is only monitoring one ARN of that object type, the test will fail).

```ruby
describe aws_cloudtrail_trail('TRAIL_NAME') do
it { should be_monitoring_write("AWS::S3::Object") }
end
```

## AWS Permissions

{{% aws_permissions_principal action="CloudTrail:Client:DescribeTrailsResponse" %}}
Expand Down
3 changes: 3 additions & 0 deletions docs-chef-io/content/inspec/resources/aws_ec2_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ One of either the EC2 instance's ID or name must be be provided.

There are also additional properties available. For a comprehensive list, see [the API reference documentation](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_Instance.html)

`instance`
: A hash containing all the data collected about the EC2.

## Examples

**Test that an EC2 instance is running.**
Expand Down
Loading