Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions gixy/plugins/try_files_is_evil_too.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ class try_files_is_evil_too(Plugin):
directives = ["try_files"]

def audit(self, directive):
found_real_try_files = False
for arg in directive.args:
if arg and not arg.startswith('@'):
found_real_try_files = True
break

if not found_real_try_files:
return

# search for open_file_cache ...; on the same or higher level
open_file_cache = directive.find_single_directive_in_scope("open_file_cache")
if not open_file_cache or open_file_cache.args[0] == "off":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
location @say_hi {
internal;
default_type text/plain;
return 200 "hi";
}
location /abc {
try_files "" @say_hi;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try_files is not less evil if it uses a named location. The first args matter: here you are checking for file with empty name… have you confirmed this hack does not do a stat for "" ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I did check with gdb to see whether stat was running, but I don't remember; it was so long ago. I no longer have the ability to test.

}