-
Notifications
You must be signed in to change notification settings - Fork 547
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
pipenv enviroment #325
pipenv enviroment #325
Conversation
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.
There's also alot of partial commits here from the workflow process. When you've made these changes can you please use git squash to condense them down into a single commit? If there are more changes we can build on that one base commit instead of 10 / 11.
.gitignore
Outdated
@@ -24,6 +24,7 @@ yacctab.py | |||
DODO | |||
todo.txt | |||
notes.txt | |||
Pipfile.lock |
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 file shouldn't be ignored, it specifies the versions we should be using. It's recommended by the author of pipenv.
KingPhisher
Outdated
@@ -1,7 +1,7 @@ | |||
#!/usr/bin/python3 -B | |||
# -*- coding: utf-8 -*- | |||
# | |||
# KingPhisher | |||
# KingPhisherVENV.py |
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 wrong.
KingPhisher
Outdated
@@ -34,74 +34,59 @@ import argparse | |||
import logging | |||
import os | |||
import sys | |||
import threading | |||
import time | |||
import subprocess |
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.
subprocess
should be before sys
.
KingPhisher
Outdated
parser.add_argument('--no-plugins', dest='use_plugins', default=True, action='store_false', help='disable all plugins') | ||
parser.add_argument('--no-style', dest='use_style', default=True, action='store_false', help='disable interface styling') | ||
arguments = parser.parse_args() | ||
parser = argparse.ArgumentParser(description='King Phisher pipenv wrapper', conflict_handler='resolve') |
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.
The description should still be King Phisher Client GUI
.
KingPhisher
Outdated
if sys.version_info < (3, 4): | ||
color.print_error('the Python version is too old (minimum required is 3.4)') | ||
print('the Python version is too old (minimum required is 3.4)') |
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.
Still add in the [-]
prefix that the color.print_error
would add.
king_phisher/clean_utilities.py
Outdated
return parser | ||
|
||
def argp_add_wrapper(parser): | ||
parser.add_argument('--env_update', dest='pipenv_update', default=False, action='store_true', help='update pipenv requirments and exit') |
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.
Please put these into a group, and use dashes in the names not underscores for consistency. You also misspelled requirements.
king_phisher/client/__main__.py
Outdated
@@ -0,0 +1,106 @@ | |||
#!/usr/bin/python3 -B |
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 should be removed since this file is no longer executable. Correct these first 4 lines to look like the other files, including the file name.
king_phisher/server/__main__.py
Outdated
@@ -0,0 +1,244 @@ | |||
#!/usr/bin/python3 -B |
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.
Same here, these first 4 lines should be updated.
king_phisher/clean_utilities.py
Outdated
return os.path.abspath(program) | ||
return None | ||
|
||
def argp_add_defualt_args(parser, default_root=''): |
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.
You misspelled "default" in the function name, but oddly enough it's spelled correctly in the keyword argument.
tools/development/pipenv_wrapper
Outdated
@@ -0,0 +1,138 @@ | |||
#!/usr/bin/python3 -B |
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.
I don't see where this file is referenced at all or why it is necessary. It seems redundant.
king_phisher/clean_utilities.py
Outdated
|
||
def argp_add_wrapper(parser): | ||
parser.add_argument('--env_update', dest='pipenv_update', default=False, action='store_true', help='update pipenv requirments and exit') | ||
parser.add_argument('--env_install', dest='pipenv_install', default=False, action='store_true', help='install pipenv enviroment and exit') |
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.
The word environment is misspelled here.
Pipenv install updates Set entries as the wrapper Updated basemaps to v1.2.0 pipenv pip18 fix add clean utilities Install pipenv from github Added gobject-interspection for package installs Pipenv enviroment
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.
Please also remove tools/development/pipenv_wrapper
.
logger.info('installing pipenv') | ||
process_output, return_code = startup.run_process([sys.executable, '-m', 'pip', 'install', 'pipenv'], cwd=target_directory) | ||
if return_code: | ||
logger.warning("the following issue occurred during installation of pipenv: {}".format(process_output)) |
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.
Since we're not continuing here, this should be an error and you should be returning non-zero. I think returning return_code
would actually be a good idea so the error status "bubbles up".
KingPhisher
Outdated
arguments = parser.parse_args() | ||
startup.argp_add_wrapper(parser) | ||
startup.argp_add_client(parser) | ||
startup.argb_add_default_args(parser) |
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.
It looks like argb_add_default_args
should be argp_add_default_args
. Not sure why that one is argB.
logger.warning("the following error occurred during pipenv environment setup: {}".format(process_output)) | ||
return 0 | ||
logger.debug('pipenv Pipfile: {}'.format(os.environ['PIPENV_PIPFILE'])) | ||
passing_argv = [' ', 'run', os.path.basename(__file__)] + sys_argv |
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.
Add a comment here that the ' '
is necessary.
king_phisher/client/__main__.py
Outdated
@@ -0,0 +1,105 @@ | |||
# -*- coding: utf-8 -*- | |||
# | |||
# client/__main__.py |
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.
Should actually be king_phisher/client/__main__.py
.
king_phisher/server/__main__.py
Outdated
@@ -0,0 +1,243 @@ | |||
# -*- coding: utf-8 -*- | |||
# | |||
# server/__main__.py |
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.
Should actually be king_phisher/server/__main__.py
.
king_phisher/startup.py
Outdated
|
||
def argp_add_wrapper(parser): | ||
kpw_group = parser.add_argument_group('King Phisher pipenv wrapper') | ||
kpw_group.add_argument('--env-update', dest='pipenv_update', default=False, action='store_true', help='update pipenv requirments and exit') |
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.
The word "requirments" is misspelled, it should be "requirements".
Landed with some minor changes in 2605856. |
This PR creates a python virtual environment to run King Phisher in.
This is done by utilizing pipenv. This python library makes it easy for configuration of both a production, development environments. As will as supporting different versions of python all contained within their own environment. Making this change allows easier development on the King Phisher project while making a more ease of use for end users, as it does not effect any python packages that may have been installed with their package manager, or breaking other python programs by changing system package versions.
tools/install.sh
will now install all required system packages and then call./KingPhisher
to set up the pipenv environment.In addition to this, when starting King Phisher's Client or Server if the virtual environment is not found it will set it up prior to launching the application.
As there is no longer a
requirements.txt
file, upgrading is now handled by./KingPhisher
or./KingPhisherServer
with the switch--env_update
. Which will callpipenv
to sync, recreate thePipefile.lock
and reinstall the virtual environment.Please Note at the time of this PR their is an issue with pipenv 2018.7.1 and pip 18.1. The issue has been resolved with 2018.7.1.dev0, but is not released with pypi. The installation script and pipenv wrapper for the client and server will install pipenv directly from github as a work around. Once the next version of pipenv is released to pypi this should be revisited.
To support having a wrapper for King Phisher's applications, a new utilities file has been created called
clean_utilities.py
this file should only contain functions and or classes that does only utilizes native python libraries. As this is imported for key functionality of the wrapper prior to the virtual environment being set up.testing:
tools/install.sh
installs King Phisher on supported operating systems (I have tested it on Ubuntu 18, Fedora, and Kali rolling)and
/KingPhisherServerwill check for the virtual enviroment and if not call
pipenv` to install it.and
/KingPhisherServerand
--env_install` update/install the pipenv environment and cleanly exits.