From a1fdb1e9993ae668464d43d95ccb86b3c07981f9 Mon Sep 17 00:00:00 2001 From: Clinton Wolfe Date: Thu, 25 Feb 2021 14:41:38 -0500 Subject: [PATCH 1/2] Clarify include matcher on crontab resource Signed-off-by: Clinton Wolfe --- docs-chef-io/content/inspec/resources/crontab.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs-chef-io/content/inspec/resources/crontab.md b/docs-chef-io/content/inspec/resources/crontab.md index f2fcd8ec4..4b0f9cde2 100644 --- a/docs-chef-io/content/inspec/resources/crontab.md +++ b/docs-chef-io/content/inspec/resources/crontab.md @@ -25,12 +25,14 @@ This resource first became available in v1.15.0 of InSpec. ## Syntax -A `crontab` resource block declares a user (which defaults to the current user, if not specified), and then the details to be tested, such as the schedule elements for each crontab entry or the commands itself: +A `crontab` resource block declares a user (which defaults to the current user, if not specified), and then the details to be tested, such as the schedule elements for each crontab entry or the exact commands themselves: describe crontab do its('commands') { should include '/some/scheduled/task.sh' } end +Note that the word `include` here means "the list of commands in the crontab should include this complete entry," not "a particular command should include this substring." The `include matcher always matches a complete command invocation, including options and arguments. + The path to the system crontab can also be supplied via: describe crontab(path: '/etc/cron.d/some_crontab') do @@ -46,7 +48,7 @@ The following examples show how to use this Chef InSpec audit resource. ### Test that root's crontab has a particular command describe crontab('root') do - its('commands') { should include '/path/to/some/script' } + its('commands') { should include '/path/to/some/script -option arg' } end ### Test that myuser's crontab entry for command '/home/myuser/build.sh' runs every minute From c7c09641ec0fc8b39e441b7b817676fa98a6b24e Mon Sep 17 00:00:00 2001 From: Clinton Wolfe Date: Wed, 10 Mar 2021 11:28:50 -0500 Subject: [PATCH 2/2] Apply suggestions from code review Signed-off-by: Clinton Wolfe Co-authored-by: Ian Maddaus --- docs-chef-io/content/inspec/resources/crontab.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs-chef-io/content/inspec/resources/crontab.md b/docs-chef-io/content/inspec/resources/crontab.md index 4b0f9cde2..d2065ebf0 100644 --- a/docs-chef-io/content/inspec/resources/crontab.md +++ b/docs-chef-io/content/inspec/resources/crontab.md @@ -25,13 +25,17 @@ This resource first became available in v1.15.0 of InSpec. ## Syntax -A `crontab` resource block declares a user (which defaults to the current user, if not specified), and then the details to be tested, such as the schedule elements for each crontab entry or the exact commands themselves: +A `crontab` resource block declares a user (which defaults to the current user) and the details to be tested, such as the schedule elements for each crontab entry or the exact commands themselves: describe crontab do its('commands') { should include '/some/scheduled/task.sh' } end -Note that the word `include` here means "the list of commands in the crontab should include this complete entry," not "a particular command should include this substring." The `include matcher always matches a complete command invocation, including options and arguments. +{{< note >}} + +The `include` matcher in this context specifies the entire list of commands that the crontab should include and not a particular substring that should be included by a command. The `include` matcher always matches a complete command invocation, including options and arguments. + +{{< /note >}} The path to the system crontab can also be supplied via: