-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't set Allow from all
by default for apache::vhost::directories
#416
Conversation
@@ -28,8 +28,11 @@ | |||
<%- if directory['deny'] and directory['deny'] != '' -%> | |||
Deny <%= directory['deny'] %> | |||
<%- end -%> | |||
<%- if directory['allow'] and directory['allow'] != '' -%> | |||
<%- if directory['allow'] and ! [ false, 'false', '' ].include? directory['allow'] -%> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably nitpicking but can we reverse these to be:
and ! directory['allow'].include?([ false, 'false', '' ])
Mostly just as I find it confusing to read in reverse. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand, directory['allow'].include?([ false, 'false', '' ])
is not correct in ruby.
As directory['allow']
is likely to be a string, the include?
method only accepts a string as parameter. (Please correct me if I'm wrong here.)
I will however put parentheses around directory['allow']
for clarity's sake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way to express this differently in ruby would be to check for an intersection:
<%- f = [ false, :false, 'false', ''] -%
<%- if ( [directory['allow']] & f ) == [directory['allow']] -%>
We create an array f
with all valid values for false
. This way we can now short-circuit the check whether directory['allow']
is set or not, since nil is not part of f
. Witness:
irb(main):001:0> f = [ false, :false, 'false', '' ]
=> [false, :false, "false", ""]
irb(main):002:0> ( f & [directory['allow']]) == [directory['allow']]
NameError: undefined local variable or method `directory' for main:Object
from (irb):2
from /usr/bin/irb:12:in `<main>'
irb(main):004:0> directory = {}
=> {}
irb(main):005:0> ( f & [directory['allow']]) == [directory['allow']]
=> false
irb(main):008:0> directory = { 'allow' => false }
=> {"allow"=>false}
irb(main):009:0> ( f & [directory['allow']]) == [directory['allow']]
=> true
irb(main):010:0>
This other way to express the same intent may not necessarily be a better way ;)
could you please amend your commit message to be a little more descriptive than "fix for link to $issue-tracker-link' i.e.: What does this change do? (and if it is interesting enough, how does it do that?) |
Hey, @RPDiep, could you please rebase, squash these commits and make the commit message a bit easier to understand. Please see our CONTRIBUTING |
Yes, I will do that. Expect it tomorrow. |
Rebased and squashed as requested. |
Don't set `Allow from all` by default for apache::vhost::directories
readme udpate
Do not to set
Allow from all
when eitherDeny from all
is set orallow
is set empty or false inapache::vhost::directories