mirror of
https://github.com/YunoHost/package_linter.git
synced 2024-09-03 20:06:12 +02:00
Hack to auto install dependencies if inside a venv
This commit is contained in:
parent
8a62054f34
commit
3399c15f73
1 changed files with 32 additions and 11 deletions
|
@ -8,6 +8,7 @@ import json
|
|||
import shlex
|
||||
import urllib.request
|
||||
import codecs
|
||||
import subprocess
|
||||
|
||||
reader = codecs.getreader("utf-8")
|
||||
|
||||
|
@ -184,9 +185,6 @@ class App():
|
|||
#
|
||||
# Path traversal issues
|
||||
#
|
||||
from lib.nginxparser import nginxparser
|
||||
nginxconf = nginxparser.load(open(self.path + "/conf/" + filename))
|
||||
|
||||
def find_location_with_alias(locationblock):
|
||||
|
||||
if locationblock[0][0] != "location":
|
||||
|
@ -221,6 +219,29 @@ class App():
|
|||
and (alias_path.endswith("/") or "__FINALPATH__" not in alias_path):
|
||||
yield location
|
||||
|
||||
do_path_traversal_check = False
|
||||
try:
|
||||
import pyparsing, six
|
||||
do_path_traversal_check = True
|
||||
except:
|
||||
# If inside a venv, try to magically install pyparsing
|
||||
if 'VIRTUAL_ENV' in os.environ:
|
||||
try:
|
||||
print("(Trying to auto install pyparsing...)")
|
||||
subprocess.check_output("pip3 install pyparsing six", shell=True)
|
||||
import pyparsing
|
||||
print("Ok!")
|
||||
do_path_traversal_check = True
|
||||
except Exception as e:
|
||||
print("Failed :[ : %s" % str(e))
|
||||
|
||||
if not do_path_traversal_check:
|
||||
print("N.B.: The package linter need you to run 'pip3 install pyparsing six' if you want it to be able to check for path traversal issue in nginx confs")
|
||||
|
||||
if do_path_traversal_check:
|
||||
from lib.nginxparser import nginxparser
|
||||
nginxconf = nginxparser.load(open(self.path + "/conf/" + filename))
|
||||
|
||||
for location in find_path_traversal_issue(nginxconf):
|
||||
print_error(
|
||||
"The nginx configuration (especially location %s) "
|
||||
|
|
Loading…
Reference in a new issue