Merge pull request #5306 from james-stocks/js/grub2

grub_conf - handle no menuentry config
This commit is contained in:
Nick Schwaderer 2020-11-18 15:39:46 +00:00 committed by GitHub
commit 673e0415dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,7 +29,7 @@ module Inspec::Resources
@content = read_file(@conf_path) @content = read_file(@conf_path)
@kernel = kernel || "default" @kernel = kernel || "default"
rescue UnknownGrubConfig rescue UnknownGrubConfig
skip_resource "The `grub_config` resource is not supported on your OS yet." skip_resource "The `grub_conf` resource is not yet supported on the target OS #{inspec.os[:name]}."
end end
def config_for_platform(path) def config_for_platform(path)
@ -77,6 +77,7 @@ module Inspec::Resources
def grub2_parse_kernel_lines(content, conf) def grub2_parse_kernel_lines(content, conf)
menu_entries = extract_menu_entries(content) menu_entries = extract_menu_entries(content)
return {} if menu_entries.empty?
if @kernel == "default" if @kernel == "default"
default_menu_entry(menu_entries, conf["GRUB_DEFAULT"]) default_menu_entry(menu_entries, conf["GRUB_DEFAULT"])