Created
April 13, 2018 18:23
-
-
Save kmcminn/714734d7bb61a6e3a8e36c349d497c9d to your computer and use it in GitHub Desktop.
nginx gixy plugin to test min folder depth of docroot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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