mirror of
https://github.com/inspec/inspec
synced 2024-11-27 15:10:44 +00:00
Removed double space after .
in text
Copied `eq` matcher text instead of linking Renamed template files Signed-off-by: Russell Seymour <russell.seymour@turtlesystems.co.uk>
This commit is contained in:
parent
3e7880627f
commit
cdc643974d
4 changed files with 37 additions and 19 deletions
22
README.md
22
README.md
|
@ -1,6 +1,6 @@
|
|||
# InSpec Azure Resource Pack
|
||||
|
||||
This resource pack provides resources for Azure Resources. It will ship with the required resources to write your own compliance rules:
|
||||
This resource pack provides resources for Azure Resources. It will ship with the required resources to write your own compliance rules:
|
||||
|
||||
```
|
||||
├── README.md - this readme
|
||||
|
@ -22,7 +22,7 @@ The information from the SPN can be specified either in a file `~/.azure/credent
|
|||
|
||||
### Credentials File
|
||||
|
||||
The simplest way is to create the file `~/.azure/credentials` with the following format. The profile is configured to look for this file by default do no settings are required.
|
||||
The simplest way is to create the file `~/.azure/credentials` with the following format. The profile is configured to look for this file by default do no settings are required.
|
||||
|
||||
```
|
||||
[<SUBSCRIPTION_ID>]
|
||||
|
@ -43,7 +43,7 @@ A different credentials file, with the same format, can be specified as an envir
|
|||
AZURE_CREDS_FILE="/path/to/another/file" inspec exec inspec-azure
|
||||
```
|
||||
|
||||
Note that this file format supports multiple subscription_ids. By default `inspec-azure` will pick the first subscription in the file. However if another subscription should be used then specify it in the environment variable `AZURE_SUBSCRIPTION_ID`.
|
||||
Note that this file format supports multiple subscription_ids. By default `inspec-azure` will pick the first subscription in the file. However if another subscription should be used then specify it in the environment variable `AZURE_SUBSCRIPTION_ID`.
|
||||
|
||||
```bash
|
||||
AZURE_SUBSCRIPTION_ID="2fbdbb02-df2e-11e6-bf01-fe55135034f3" inspec exec inspec-azure
|
||||
|
@ -75,7 +75,7 @@ AZURE_TENANT_ID="6ad89b58-df2e-11e6-bf01-fe55135034f3" inspec exec inspec-azure
|
|||
|
||||
## Use the resources
|
||||
|
||||
Since this is an InSpec resource pack, it only defines InSpec resources. It includes example tests only. To easily use the Azure InSpec resources in your tests do the following:
|
||||
Since this is an InSpec resource pack, it only defines InSpec resources. It includes example tests only. To easily use the Azure InSpec resources in your tests do the following:
|
||||
|
||||
### Create a new profile
|
||||
|
||||
|
@ -167,11 +167,11 @@ end
|
|||
| | boot_diagnostics? | Whether boot diagnostics have been enabled or not |
|
||||
| | nic_count | How many network cards are attached to the machine |
|
||||
| | username | The admin username that has been assigned to the machine |
|
||||
| | computername | Computer name of the machine in the operating system. This maybe different to the VM name as seen in Azure |
|
||||
| | computername | Computer name of the machine in the operating system. This maybe different to the VM name as seen in Azure |
|
||||
| | hostname | Alias for computername |
|
||||
| | password_authentication? | If password authentication is enabled. For Windows machines this is always true |
|
||||
| | ssh_key_count | How many SSH public keys have been added to the machine. For Windows this is always 0 |
|
||||
| | os_type | Tyep type of operating system. Linux or Windows |
|
||||
| | password_authentication? | If password authentication is enabled. For Windows machines this is always true |
|
||||
| | ssh_key_count | How many SSH public keys have been added to the machine. For Windows this is always 0 |
|
||||
| | os_type | Tyep type of operating system. Linux or Windows |
|
||||
|
||||
- `azure_vm_datadisks` - Resource to read the data disks for a machine and check that they are of the correct size etc
|
||||
|
||||
|
@ -181,7 +181,7 @@ end
|
|||
| | count | Returns the number of data disks attached to the machine |
|
||||
| | where | Filter that allows for different tests to be performed, see examples below |
|
||||
|
||||
When data disks are retrieved from a machine they are given as an array. The `where` filter will interogate the array according the criteria it is given. The followin attributes are available in the filter:
|
||||
When data disks are retrieved from a machine they are given as an array. The `where` filter will interogate the array according the criteria it is given. The followin attributes are available in the filter:
|
||||
|
||||
- `disk` - Disk number (0 index based)
|
||||
- `caching` - What sort of caching is enabled on the data disk
|
||||
|
@ -214,7 +214,7 @@ end
|
|||
|
||||
## Testing
|
||||
|
||||
The `test/integration/verify/controls` directory contains all of the tests that are run during integration tests. These can be used as examples of how to use this resource pack.
|
||||
The `test/integration/verify/controls` directory contains all of the tests that are run during integration tests. These can be used as examples of how to use this resource pack.
|
||||
|
||||
Rake tasks have been configured to enable the running of the integration tests:
|
||||
|
||||
|
@ -225,7 +225,7 @@ rake rubocop # Run Rubocop lint checks
|
|||
rake test:integration # Perform Integration Tests
|
||||
```
|
||||
|
||||
As with using the resources themselves the integration tests rely on a Service Principal Name being defined. Please see the information at the start of this page on how to generate this.
|
||||
As with using the resources themselves the integration tests rely on a Service Principal Name being defined. Please see the information at the start of this page on how to generate this.
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
@ -6,6 +6,10 @@ title: About the azure_resource_group Resource
|
|||
|
||||
Use the `azure_resource_group` InSpec audit resource to ensure that an Azure Resource group has the correct resources.
|
||||
|
||||
## References
|
||||
|
||||
- [Azure Ruby SDK - Resources](https://github.com/Azure/azure-sdk-for-ruby/tree/master/management/azure_mgmt_resources)
|
||||
|
||||
## Syntax
|
||||
|
||||
The name of the resource group is specified as an attribute on the resource:
|
||||
|
@ -46,7 +50,9 @@ This InSpec audit resource has the following matchers:
|
|||
|
||||
### eq
|
||||
|
||||
<%= partial "/shared/matcher_eq" %>
|
||||
Use the `eq` matcher to test the equality of two values: `its('Port') { should eq '22' }`.
|
||||
|
||||
Using `its('Port') { should eq 22 }` will fail because `22` is not a string value! Use the `cmp` matcher for less restrictive value comparisons.
|
||||
|
||||
### total
|
||||
|
||||
|
@ -92,7 +98,7 @@ end
|
|||
|
||||
The `count` filter allows testing for the number of resources that are not directly supported by the resource pack:
|
||||
|
||||
As before it is best used in conjunction with a filter. The following checks that there is at least 1 Managed Disk Image in the resource group.
|
||||
As before it is best used in conjunction with a filter. The following checks that there is at least 1 Managed Disk Image in the resource group.
|
||||
|
||||
```ruby
|
||||
describe azure_resource_group(name: 'MyResourceGroup').where { type: 'Microsoft.Compute/images' } do
|
|
@ -6,6 +6,10 @@ title: About the azure_virtual_machine Resource
|
|||
|
||||
Use the `azure_virtual_machine` InSpec audit resource to ensure that a Virtual Machine has been provisionned correctly.
|
||||
|
||||
## References
|
||||
|
||||
- [Azure Ruby SDK - Compute](https://github.com/Azure/azure-sdk-for-ruby/tree/master/management/azure_mgmt_compute)
|
||||
|
||||
## Syntax
|
||||
|
||||
The name of the machine and the resourece group are required as attributes to the resource.
|
||||
|
@ -18,7 +22,7 @@ end
|
|||
|
||||
where
|
||||
|
||||
* `MyVm` is the name of the virtual machine as seen in Azure. (It is **not** the hostname of the machine)
|
||||
* `MyVm` is the name of the virtual machine as seen in Azure. (It is **not** the hostname of the machine)
|
||||
* `MyResourceGroup` is the name of the resouce group that the machine is in.
|
||||
* `matcher` is one of
|
||||
- `publisher`
|
||||
|
@ -51,7 +55,9 @@ This InSpec audit resource has the following matchers:
|
|||
|
||||
### eq
|
||||
|
||||
<%= partial "/shared/matcher_eq" %>
|
||||
Use the `eq` matcher to test the equality of two values: `its('Port') { should eq '22' }`.
|
||||
|
||||
Using `its('Port') { should eq 22 }` will fail because `22` is not a string value! Use the `cmp` matcher for less restrictive value comparisons.
|
||||
|
||||
### publisher
|
||||
|
||||
|
@ -103,7 +109,7 @@ NOTE: Azure does not allow the use of `Administrator` as the admin username on
|
|||
|
||||
### computername
|
||||
|
||||
The computername of the machine. This is what was assigned to the machine during deployment and is what _should_ be returned by the `hostname` command.
|
||||
The computername of the machine. This is what was assigned to the machine during deployment and is what _should_ be returned by the `hostname` command.
|
||||
|
||||
### hostname
|
||||
|
|
@ -6,6 +6,10 @@ title: About the azure_virtual_machine_datadisks Resource
|
|||
|
||||
Use this resource to check that the correct number of data disks have been applied to the machine and that they are of the correct size.
|
||||
|
||||
## References
|
||||
|
||||
- [Azure Ruby SDK - Compute](https://github.com/Azure/azure-sdk-for-ruby/tree/master/management/azure_mgmt_compute)
|
||||
|
||||
## Syntax
|
||||
|
||||
The name of the resource group and machine are required to use this resource.
|
||||
|
@ -18,7 +22,7 @@ end
|
|||
|
||||
where
|
||||
|
||||
* `MyVm` is the name of the virtual machine as seen in Azure. (It is **not** the hostname of the machine)
|
||||
* `MyVm` is the name of the virtual machine as seen in Azure. (It is **not** the hostname of the machine)
|
||||
* `MyResourceGroup` is the name of the resouce group that the machine is in.
|
||||
* `matcher` is one of
|
||||
- `count` the number of data disks attached to the machine
|
||||
|
@ -32,7 +36,9 @@ This InSpec audit resource has the following matchers:
|
|||
|
||||
### eq
|
||||
|
||||
<%= partial "/shared/matcher_eq" %>
|
||||
Use the `eq` matcher to test the equality of two values: `its('Port') { should eq '22' }`.
|
||||
|
||||
Using `its('Port') { should eq 22 }` will fail because `22` is not a string value! Use the `cmp` matcher for less restrictive value comparisons.
|
||||
|
||||
### count
|
||||
|
||||
|
@ -58,7 +64,7 @@ The `entries` filter can be used to check the attributes of indivdual data disks
|
|||
its('entries') { should_not be_empty }
|
||||
```
|
||||
|
||||
This matcher is best used in conjunction with filters. For example the following tests that the first data disk has a capacity greater than 10gb.
|
||||
This matcher is best used in conjunction with filters. For example the following tests that the first data disk has a capacity greater than 10gb.
|
||||
|
||||
```ruby
|
||||
describe azure_virtual_machine_datadisks(name: 'MyVM', resource_group: 'MyResourceGroup').where { disk.zero? and size > 10 } do
|
Loading…
Reference in a new issue