mirror of
https://github.com/inspec/inspec
synced 2024-11-10 23:24:18 +00:00
d7fad68541
This pull request adds a packages resource so that we can check for pattern matches against all the packages on a system. This initially implements only dpkg support for debian-based platforms so we can cover this use case: ```ruby describe packages(/^xserver-xorg.*/) do its("list") { should be_empty } end ``` This uses FilterTable so we can supply additional queries, too. ```ruby describe packages(/vi.+/).where { status != 'installed' } do its('statuses') { should be_empty } end ``` Users can specify the name as a string or a regular expression. If it is a string, we will escape it and convert it to a regular expression to use in matching against the full returned list of packages. If it is a regular expression, we take that as is and use it to filter the results. While some package management systems such as `dpkg` can take a shell glob argument to filter their results, we eschew this and require a regular expression to match multiple package names because we will need this to work across other platforms in the future. This means that the following: ```ruby packages("vim") ``` Will return *all* the "vim" packages on the system. The `packages` resource will take `"vim"`, turn it into `/vim/`, and greedily match anything with "vim" in the name. To match only a single package named `vim`, it needs to be an anchored regular expression. ```ruby packages(/^vim$/) ``` Signed-off-by: Joshua Timberman <joshua@chef.io> Use entries instead of list Added a few more tests and non installed package in output Signed-off-by: Alex Pop <apop@chef.io> fix lint Signed-off-by: Alex Pop <apop@chef.io> Signed-off-by: Joshua Timberman <joshua@chef.io> |
||
---|---|---|
.. | ||
apache_conf_test.rb | ||
apt_test.rb | ||
audit_policy_test.rb | ||
auditd_conf_test.rb | ||
auditd_rules_test.rb | ||
bash_test.rb | ||
bond_test.rb | ||
bridge_test.rb | ||
csv_test.rb | ||
etc_group_test.rb | ||
file_test.rb | ||
gem_test.rb | ||
group_test.rb | ||
grub_conf_test.rb | ||
host_test.rb | ||
http_test.rb | ||
inetd_conf_test.rb | ||
ini_test.rb | ||
interface_test.rb | ||
iptables_test.rb | ||
json_test.rb | ||
kernel_module_test.rb | ||
kernel_parameter_test.rb | ||
limits_conf_test.rb | ||
login_def_test.rb | ||
mount_test.rb | ||
mysql_conf_test.rb | ||
npm_test.rb | ||
ntp_conf_test.rb | ||
oneget_test.rb | ||
os_env_test.rb | ||
os_test.rb | ||
package_test.rb | ||
packages_test.rb | ||
parse_config_test.rb | ||
passwd_test.rb | ||
pip_test.rb | ||
port_test.rb | ||
powershell_test.rb | ||
processes_test.rb | ||
registry_key_test.rb | ||
security_policy_test.rb | ||
service_test.rb | ||
shadow_test.rb | ||
ssh_conf_test.rb | ||
sys_info_test.rb | ||
user_test.rb | ||
vbscript_test.rb | ||
windows_feature.rb | ||
windows_task_test.rb | ||
wmi_test.rb | ||
xinetd_test.rb | ||
yaml_test.rb | ||
yum_test.rb |