forked from inspec/inspec
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update ssh_config resource to support returning the current sshd_conf…
…ig file in use. (inspec#7070) * modify resource * windows compatibility * end line * removing comments to clean things up Signed-off-by: Aaron Lippold <[email protected]> * CHEF-12175: Remove use of `Kernel.open` or `IO.read` or similar sinks with a non-constant value (inspec#7079) * fix: update io reads to fix codescanning vuln Signed-off-by: Sonu Saha <[email protected]> * fix: remove kernel#open fallback and update open method to handle local files Signed-off-by: Sonu Saha <[email protected]> * fix: replace io.readlines to file.readlines Signed-off-by: Sonu Saha <[email protected]> * chore: fix lint offense, unnecessary space Signed-off-by: Sonu Saha <[email protected]> * fix: raise exception for standard errors as FetcherFailure Signed-off-by: Sonu Saha <[email protected]> * chore: update exception message Signed-off-by: Sonu Saha <[email protected]> --------- Signed-off-by: Sonu Saha <[email protected]> * fix: Missing regular expression anchor (inspec#7077) Signed-off-by: Sonu Saha <[email protected]> * Bump version to 6.6.27 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. * Fix gitignore file in docs dir (inspec#7082) Signed-off-by: Ian Maddaus <[email protected]> * Bump version to 6.6.28 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. * adding docs now that the gitignore is fixed. Signed-off-by: Aaron Lippold <[email protected]> * add docs for sshd_active_config resource * fix docs * unit tests * rubocop on ssh_config.rb, sshd_con_test.rb, and sshd_active_config.md * rename active path in method * doc fix * Linting Corrections for Active SSHD Config (#1) Signed-off-by: Clinton Wolfe <[email protected]> * Update sshd_active_config.md updated version * doc version update --------- Signed-off-by: Aaron Lippold <[email protected]> Signed-off-by: Sonu Saha <[email protected]> Signed-off-by: Ian Maddaus <[email protected]> Signed-off-by: Clinton Wolfe <[email protected]> Co-authored-by: Daniel Medina <[email protected]> Co-authored-by: Sonu Saha <[email protected]> Co-authored-by: Chef Expeditor <[email protected]> Co-authored-by: Ian Maddaus <[email protected]> Co-authored-by: Clinton Wolfe <[email protected]>
- Loading branch information
1 parent
0e904a3
commit 0ab3568
Showing
5 changed files
with
216 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
docs-chef-io/content/inspec/resources/sshd_active_config.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
+++ | ||
title = "sshd_active_config resource" | ||
draft = false | ||
gh_repo = "inspec" | ||
platform = "linux" | ||
[menu] | ||
[menu.inspec] | ||
title = "sshd_active_config" | ||
identifier = "inspec/resources/os/sshd_active_config.md sshd_active_config resource" | ||
parent = "inspec/resources/os" | ||
+++ | ||
Use the `sshd_active_config` Chef InSpec audit resource to find and test configuration data for the OpenSSH daemon. By default, this configuration data is located at `/etc/ssh/sshd_config` on Linux and Unix platforms. However, this resource is designed to retrieve the active configuration file by the sshd process itself. sshd---the OpenSSH daemon---listens on dedicated ports, starts a daemon for each incoming connection, and then handles encryption, authentication, key exchanges, command execution, and data exchanges. | ||
## Availability | ||
|
||
### Install | ||
|
||
{{< readfile file="content/inspec/reusable/md/inspec_installation.md" >}} | ||
|
||
### Version | ||
|
||
This resource first became available in v6.8.0 of InSpec. | ||
|
||
## Syntax | ||
|
||
An `sshd_active_config` resource block declares the OpenSSH daemon configuration data to be tested: | ||
|
||
describe sshd_active_config do | ||
its('name') { should include('foo') } | ||
end | ||
|
||
where | ||
|
||
- `name` is a configuration setting in `sshd_config` | ||
- `{ should include('foo') }` tests the value of `name` as read from `sshd_active_config` versus the value declared in the test | ||
|
||
## Examples | ||
|
||
The following examples show how to use this Chef InSpec audit resource. | ||
|
||
### Inspect the file and path found by the `sshd_active_config` resource | ||
|
||
describe sshd_active_config.active_path do | ||
it { should match '/expected/path/sshd_config' } | ||
end | ||
|
||
### Test which variables may be sent to the server | ||
|
||
describe sshd_active_config do | ||
its('AcceptEnv') { should include('CI_ENABLE_COVERAGE') } | ||
end | ||
|
||
### Test for IPv6-only addresses | ||
|
||
describe sshd_active_config do | ||
its('AddressFamily') { should cmp 'inet6' } | ||
end | ||
|
||
### Test the Protocol setting | ||
|
||
describe sshd_active_config do | ||
its('Protocol') { should cmp 2 } | ||
end | ||
|
||
### Test for approved, strong ciphers | ||
|
||
describe sshd_active_config do | ||
its('Ciphers') { should cmp('[email protected],aes256-ctr,aes192-ctr,aes128-ctr') } | ||
end | ||
|
||
### Test SSH protocols | ||
|
||
describe sshd_active_config do | ||
its('Port') { should cmp 22 } | ||
its('UsePAM') { should eq 'yes' } | ||
its('ListenAddress') { should eq nil } | ||
its('HostKey') do | ||
should eq [ | ||
'/etc/ssh/ssh_host_rsa_key', | ||
'/etc/ssh/ssh_host_dsa_key', | ||
'/etc/ssh/ssh_host_ecdsa_key', | ||
] | ||
end | ||
end | ||
|
||
## Matchers | ||
|
||
{{< readfile file="content/inspec/reusable/md/inspec_matchers_link.md" >}} | ||
|
||
This resource has the following special matchers. | ||
|
||
### name | ||
|
||
The `name` matcher tests the value of `name` as read from `sshd_active_config` versus the value declared in the test: | ||
|
||
its('name') { should cmp 'foo' } | ||
|
||
or: | ||
|
||
its('name') {should include('bar') } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# This is just here to make the dynamic loader happy. | ||
require "inspec/resources/ssh_config" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters