summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFerdi van der Werf <ferdi@rootnet.nl>2021-06-10 20:50:29 +0200
committerFerdi van der Werf <ferdi@rootnet.nl>2021-06-10 20:57:17 +0200
commitad9d197649a05d3917ed2799d9cdec689b7edc9e (patch)
tree1aa80e77733dd5eaa219ca0c26612a45dc2c1bd7
parent0bc0a13cbc5775a34fbc2984f3abf5d13897f60d (diff)
downloadchef-ad9d197649a05d3917ed2799d9cdec689b7edc9e.tar.gz
Handle source_line being nil gracefully
When a resource is marked sensitive, the source_line is nil and you can't gsub on it. So if a sensitive resource is slow, it should not crash the SlowReport because it has no source_line. Fixes chef/chef#11690 Signed-off-by: Ferdi van der Werf <ferdi@rootnet.nl>
-rw-r--r--lib/chef/handler/slow_report.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/chef/handler/slow_report.rb b/lib/chef/handler/slow_report.rb
index 7bb472f4d5..e5b2f2895f 100644
--- a/lib/chef/handler/slow_report.rb
+++ b/lib/chef/handler/slow_report.rb
@@ -59,7 +59,7 @@ class Chef
def stripped_source_line(resource)
# strip the leading path off of the source line
- resource.source_line.gsub(%r{.*/cookbooks/}, "").gsub(%r{.*/chef-[0-9\.]+/}, "")
+ resource.source_line&.gsub(%r{.*/cookbooks/}, "")&.gsub(%r{.*/chef-[0-9\.]+/}, "")
end
end
end