2016-09-22 12:43:57 +00:00
|
|
|
---
|
|
|
|
title: About the kernel_parameter Resource
|
2018-02-16 00:28:15 +00:00
|
|
|
platform: linux
|
2016-09-22 12:43:57 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# kernel_parameter
|
|
|
|
|
2019-04-26 18:24:29 +00:00
|
|
|
Use the `kernel_parameter` Chef InSpec audit resource to test kernel parameters on Linux platforms.
|
2018-02-16 00:28:15 +00:00
|
|
|
These parameters are located under `/proc/cmdline`.
|
2017-10-03 21:35:10 +00:00
|
|
|
<br>
|
|
|
|
|
2018-08-09 12:34:49 +00:00
|
|
|
## Availability
|
|
|
|
|
|
|
|
### Installation
|
|
|
|
|
2019-04-26 18:24:29 +00:00
|
|
|
This resource is distributed along with Chef InSpec itself. You can use it automatically.
|
2018-08-09 12:34:49 +00:00
|
|
|
|
|
|
|
### 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 `kernel_parameter` resource block declares a parameter and then a value to be tested:
|
|
|
|
|
|
|
|
describe kernel_parameter('path.to.parameter') do
|
|
|
|
its('value') { should eq 0 }
|
|
|
|
end
|
|
|
|
|
|
|
|
where
|
|
|
|
|
|
|
|
* `'kernel.parameter'` must specify a kernel parameter, such as `'net.ipv4.conf.all.forwarding'`
|
|
|
|
* `{ should eq 0 }` states the value to be tested
|
|
|
|
|
2017-10-03 21:35:10 +00:00
|
|
|
<br>
|
2016-09-22 12:43:57 +00:00
|
|
|
|
2016-09-27 19:03:23 +00:00
|
|
|
## Examples
|
2016-09-22 12:43:57 +00:00
|
|
|
|
2019-04-26 18:24:29 +00:00
|
|
|
The following examples show how to use this Chef InSpec audit resource.
|
2016-09-22 12:43:57 +00:00
|
|
|
|
2016-09-27 19:03:23 +00:00
|
|
|
### Test if global forwarding is enabled for an IPv4 address
|
2016-09-22 12:43:57 +00:00
|
|
|
|
|
|
|
describe kernel_parameter('net.ipv4.conf.all.forwarding') do
|
|
|
|
its('value') { should eq 1 }
|
|
|
|
end
|
|
|
|
|
2016-09-27 19:03:23 +00:00
|
|
|
### Test if global forwarding is disabled for an IPv6 address
|
2016-09-22 12:43:57 +00:00
|
|
|
|
|
|
|
describe kernel_parameter('net.ipv6.conf.all.forwarding') do
|
|
|
|
its('value') { should eq 0 }
|
|
|
|
end
|
|
|
|
|
2016-09-27 19:03:23 +00:00
|
|
|
### Test if an IPv6 address accepts redirects
|
2016-09-22 12:43:57 +00:00
|
|
|
|
|
|
|
describe kernel_parameter('net.ipv6.conf.interface.accept_redirects') do
|
2018-02-13 17:37:30 +00:00
|
|
|
its('value') { should cmp 'true' }
|
2016-09-22 12:43:57 +00:00
|
|
|
end
|
2017-10-03 21:35:10 +00:00
|
|
|
|
|
|
|
<br>
|
|
|
|
|
|
|
|
## Matchers
|
|
|
|
|
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/).
|