mirror of
https://github.com/inspec/inspec
synced 2024-11-24 05:33:17 +00:00
9cfc86d2ab
Light formatting changes, change order of example and matchers, slight color changes Signed-off-by: hannah-radish <hmaddy@chef.io>
58 lines
1.4 KiB
Text
58 lines
1.4 KiB
Text
---
|
|
title: About the kernel_parameter Resource
|
|
---
|
|
|
|
# kernel_parameter
|
|
|
|
Use the `kernel_parameter` InSpec audit resource to test kernel parameters on Linux platforms.
|
|
|
|
<br>
|
|
|
|
## Syntax
|
|
|
|
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
|
|
|
|
<br>
|
|
|
|
## Examples
|
|
|
|
The following examples show how to use this InSpec audit resource.
|
|
|
|
### Test if global forwarding is enabled for an IPv4 address
|
|
|
|
describe kernel_parameter('net.ipv4.conf.all.forwarding') do
|
|
its('value') { should eq 1 }
|
|
end
|
|
|
|
### Test if global forwarding is disabled for an IPv6 address
|
|
|
|
describe kernel_parameter('net.ipv6.conf.all.forwarding') do
|
|
its('value') { should eq 0 }
|
|
end
|
|
|
|
### Test if an IPv6 address accepts redirects
|
|
|
|
describe kernel_parameter('net.ipv6.conf.interface.accept_redirects') do
|
|
its('value') { should eq 'true' }
|
|
end
|
|
|
|
<br>
|
|
|
|
## Matchers
|
|
|
|
This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
|
|
|
|
### value
|
|
|
|
The `value` matcher tests the value assigned to the named IP address versus the value declared in the test:
|
|
|
|
its('value') { should eq 0 }
|