2016-09-22 12:43:57 +00:00
|
|
|
---
|
|
|
|
title: About the csv Resource
|
2018-02-16 00:28:15 +00:00
|
|
|
platform: os
|
2016-09-22 12:43:57 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# csv
|
|
|
|
|
|
|
|
Use the `csv` InSpec audit resource to test configuration data in a CSV file.
|
|
|
|
|
2017-10-03 21:35:10 +00:00
|
|
|
<br>
|
|
|
|
|
2018-08-09 12:34:49 +00:00
|
|
|
## Availability
|
|
|
|
|
|
|
|
### Installation
|
|
|
|
|
|
|
|
This resource is distributed along with InSpec itself. You can use it automatically.
|
|
|
|
|
|
|
|
### Version
|
|
|
|
|
|
|
|
This resource first became available in v1.0.0 of InSpec.
|
|
|
|
|
2016-09-27 19:03:23 +00:00
|
|
|
## Syntax
|
2016-09-22 12:43:57 +00:00
|
|
|
|
|
|
|
A `csv` resource block declares the configuration data to be tested:
|
|
|
|
|
|
|
|
describe csv('file') do
|
2018-02-07 14:25:42 +00:00
|
|
|
its('name') { should cmp 'foo' }
|
2016-09-22 12:43:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
where
|
|
|
|
|
|
|
|
* `'file'` is the path to a CSV file
|
|
|
|
* `name` is a configuration setting in a CSV file
|
|
|
|
* `should eq 'foo'` tests a value of `name` as read from a CSV file versus the value declared in the test
|
|
|
|
|
2017-10-03 21:35:10 +00:00
|
|
|
<br>
|
2016-09-22 12:43:57 +00:00
|
|
|
|
2018-02-15 14:33:22 +00:00
|
|
|
## Examples
|
2016-09-22 12:43:57 +00:00
|
|
|
|
2017-10-03 21:35:10 +00:00
|
|
|
The following examples show how to use this InSpec audit resource.
|
2016-09-22 12:43:57 +00:00
|
|
|
|
2017-10-03 21:35:10 +00:00
|
|
|
### Test a CSV file
|
2016-09-22 12:43:57 +00:00
|
|
|
|
2017-10-03 21:35:10 +00:00
|
|
|
describe csv('some_file.csv') do
|
|
|
|
its('setting') { should eq 1 }
|
|
|
|
end
|
2016-09-22 12:43:57 +00:00
|
|
|
|
2017-10-03 21:35:10 +00:00
|
|
|
<br>
|
2016-09-22 12:43:57 +00:00
|
|
|
|
2018-02-07 14:25:42 +00:00
|
|
|
## Property Examples
|
|
|
|
|
|
|
|
### name
|
|
|
|
|
|
|
|
The `name` property tests the value of `name` as read from a CSV file compared to the value declared in the test.
|
|
|
|
|
|
|
|
its('name') { should cmp 'foo' }
|
|
|
|
|
|
|
|
<br>
|
|
|
|
|
2017-10-03 21:35:10 +00:00
|
|
|
## Matchers
|
2016-09-22 12:43:57 +00:00
|
|
|
|
2018-02-16 03:07:18 +00:00
|
|
|
For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
|
2016-09-22 12:43:57 +00:00
|
|
|
|
|
|
|
|