From 075b6be9f6f740f953d07d9b240c4a733b8aa2ba Mon Sep 17 00:00:00 2001 From: Jeff Ohrstrom Date: Fri, 23 Jul 2021 11:10:33 -0400 Subject: [PATCH] move rubocop file to the dashboard and fix 1 file's warnings --- .rubocop.yml => apps/dashboard/.rubocop.yml | 0 apps/dashboard/app/models/allowlist_policy.rb | 17 +++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) rename .rubocop.yml => apps/dashboard/.rubocop.yml (100%) diff --git a/.rubocop.yml b/apps/dashboard/.rubocop.yml similarity index 100% rename from .rubocop.yml rename to apps/dashboard/.rubocop.yml diff --git a/apps/dashboard/app/models/allowlist_policy.rb b/apps/dashboard/app/models/allowlist_policy.rb index efe8f25b1a..299bf233b7 100644 --- a/apps/dashboard/app/models/allowlist_policy.rb +++ b/apps/dashboard/app/models/allowlist_policy.rb @@ -1,5 +1,6 @@ require 'pathname' +# AllowlistPolicy allows or denies access to directories based off of a configuration. class AllowlistPolicy attr_reader :allowlist @@ -16,7 +17,7 @@ def initialize(allowlist) # @raises ArgumentError if any allowlist path or permitted? argument # has the form ~user/some/path where user doesn't exist def permitted?(path) - allowlist.blank? || allowlist.any?{ |parent| child?(Pathname.new(parent), real_expanded_path(path)) } + allowlist.blank? || allowlist.any? { |parent| child?(Pathname.new(parent), real_expanded_path(path)) } end # @raises AllowlistPolicy::Forbidden if path is not permitted by allowlist @@ -30,12 +31,12 @@ def validate!(path) # call realpath to ensure symlinks are handled def real_expanded_path(path) - # call realpath to ensure symlinks are resolved - Pathname.new(path).expand_path.realpath - rescue SystemCallError - # path doesn't exist, so we just get absolute version then - Pathname.new(path).expand_path - end + # call realpath to ensure symlinks are resolved + Pathname.new(path).expand_path.realpath + rescue SystemCallError + # path doesn't exist, so we just get absolute version then + Pathname.new(path).expand_path + end # Determine if child is a subpath of parent # @@ -46,7 +47,7 @@ def real_expanded_path(path) # @param child [Pathname] # @return Boolean def child?(parent, child) - ! child.expand_path.relative_path_from( + !child.expand_path.relative_path_from( parent.expand_path ).each_filename.to_a.include?( '..'