Skip to content

Commit 9c0cc49

Browse files
GrantBirkiCopilot
andauthored
Apply suggestion from @Copilot
Co-authored-by: Copilot <[email protected]>
1 parent c902335 commit 9c0cc49

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/hooks/app/helpers.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ def load_handler(handler_class_name, handler_dir)
8080
file_path = File.join(handler_dir, file_name)
8181

8282
# Security: Ensure the file path doesn't escape the handler directory
83-
normalized_handler_dir = File.expand_path(handler_dir)
84-
normalized_file_path = File.expand_path(file_path)
85-
unless normalized_file_path.start_with?(normalized_handler_dir)
83+
normalized_handler_dir = Pathname.new(File.expand_path(handler_dir))
84+
normalized_file_path = Pathname.new(File.expand_path(file_path))
85+
unless normalized_file_path.descend.any? { |path| path == normalized_handler_dir }
8686
error!("handler path outside of handler directory", 400)
8787
end
8888

0 commit comments

Comments
 (0)