Skip to content

Instantly share code, notes, and snippets.

@kmcminn
Created April 13, 2018 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmcminn/714734d7bb61a6e3a8e36c349d497c9d to your computer and use it in GitHub Desktop.
Save kmcminn/714734d7bb61a6e3a8e36c349d497c9d to your computer and use it in GitHub Desktop.
nginx gixy plugin to test min folder depth of docroot
import gixy
from gixy.plugins.plugin import Plugin
class nonspecific_root(Plugin):
"""
Insecure example:
root /home/nginx
Secure example:
root /home/nginx/src/www
"""
summary = 'The root path for locations may not be specific enough.'
severity = gixy.severity.MEDIUM
description = 'root path should be never be a high-level folder like /home or /home/someuser.'
help_url = 'uber.com'
directives = ['root']
folder_depth = 4
def audit(self, directive):
path = directive.args[0]
folders = [n for n in path.split('/') if n]
if len(folders) < self.folder_depth:
self.add_issue(directive=directive)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment