Pep8 corrections
This commit is contained in:
parent
f5c53add9c
commit
f7d8df69cc
3 changed files with 75 additions and 69 deletions
|
@ -16,6 +16,7 @@ except ImportError:
|
||||||
from base64 import b64encode, b64decode
|
from base64 import b64encode, b64decode
|
||||||
from os import getcwd, sep, path, urandom
|
from os import getcwd, sep, path, urandom
|
||||||
|
|
||||||
|
|
||||||
class Compress(object):
|
class Compress(object):
|
||||||
def __init__(self, sessconfig):
|
def __init__(self, sessconfig):
|
||||||
self.config = sessconfig
|
self.config = sessconfig
|
||||||
|
@ -63,7 +64,7 @@ class Compress(object):
|
||||||
try:
|
try:
|
||||||
zf.extract("config.json")
|
zf.extract("config.json")
|
||||||
except zipfile.BadZipfile as e:
|
except zipfile.BadZipfile as e:
|
||||||
raise PappyException("Project archive contents corrupted. Error: ", e)
|
raise PappyException("Zip archive corrupted. Error: ", e)
|
||||||
|
|
||||||
zf.extractall()
|
zf.extractall()
|
||||||
|
|
||||||
|
@ -80,4 +81,4 @@ class Compress(object):
|
||||||
with tarfile.open(self.bz2_archive, "r:bz2") as archive:
|
with tarfile.open(self.bz2_archive, "r:bz2") as archive:
|
||||||
archive.extractall()
|
archive.extractall()
|
||||||
except tarfile.ExtractError as e:
|
except tarfile.ExtractError as e:
|
||||||
raise PappyException("Project archive contents corrupted. Error: ", e)
|
raise PappyException("Tar archive corrupted. Error: ", e)
|
||||||
|
|
|
@ -14,6 +14,7 @@ from base64 import b64encode, b64decode
|
||||||
from cryptography.fernet import Fernet, InvalidToken
|
from cryptography.fernet import Fernet, InvalidToken
|
||||||
from twisted.internet import reactor, defer
|
from twisted.internet import reactor, defer
|
||||||
|
|
||||||
|
|
||||||
class Crypto(object):
|
class Crypto(object):
|
||||||
def __init__(self, sessconfig):
|
def __init__(self, sessconfig):
|
||||||
self.config = sessconfig
|
self.config = sessconfig
|
||||||
|
@ -25,7 +26,8 @@ class Crypto(object):
|
||||||
|
|
||||||
def encrypt_project(self):
|
def encrypt_project(self):
|
||||||
"""
|
"""
|
||||||
Compress and encrypt the project files, deleting clear-text files afterwards
|
Compress and encrypt the project files,
|
||||||
|
deleting clear-text files afterwards
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Leave the crypto working directory
|
# Leave the crypto working directory
|
||||||
|
@ -54,13 +56,13 @@ class Crypto(object):
|
||||||
# Delete clear-text files
|
# Delete clear-text files
|
||||||
self.delete_clear_files()
|
self.delete_clear_files()
|
||||||
|
|
||||||
|
|
||||||
def decrypt_project(self):
|
def decrypt_project(self):
|
||||||
"""
|
"""
|
||||||
Decrypt and decompress the project files
|
Decrypt and decompress the project files
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# If project hasn't been encrypted before, setup crypt working directory
|
# If project hasn't been encrypted before,
|
||||||
|
# setup crypt working directory
|
||||||
if not os.path.isfile(self.config.crypt_file):
|
if not os.path.isfile(self.config.crypt_file):
|
||||||
os.mkdir(self.config.crypt_dir)
|
os.mkdir(self.config.crypt_dir)
|
||||||
|
|
||||||
|
@ -107,7 +109,7 @@ class Crypto(object):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def confirm_password_retry(self):
|
def confirm_password_retry(self):
|
||||||
answer = raw_input("Would you like to re-enter your password? (y/n)").strip()
|
answer = raw_input("Re-enter your password? (y/n)").strip()
|
||||||
if answer[0] == "y" or answer[0] == "Y":
|
if answer[0] == "y" or answer[0] == "Y":
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
@ -181,7 +183,8 @@ class Crypto(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not self.key:
|
if not self.key:
|
||||||
self.key = b64encode(scrypt.hash(self.password, self.salt, buflen=32))
|
shash = scrypt.hash(self.password, self.salt, buflen=32)
|
||||||
|
self.key = b64encode(shash)
|
||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
raise PappyException("Scrypt failed with type error: ", e)
|
raise PappyException("Scrypt failed with type error: ", e)
|
||||||
except scrypt.error, e:
|
except scrypt.error, e:
|
||||||
|
@ -200,5 +203,4 @@ class Crypto(object):
|
||||||
Forces generation of new salt after opening and closing the project.
|
Forces generation of new salt after opening and closing the project.
|
||||||
Adds security in the case of a one-time compromise of the system.
|
Adds security in the case of a one-time compromise of the system.
|
||||||
"""
|
"""
|
||||||
#os.remove(self.config.salt_file)
|
|
||||||
os.remove(self.config.crypt_file)
|
os.remove(self.config.crypt_file)
|
||||||
|
|
|
@ -181,7 +181,10 @@ def parse_args():
|
||||||
parser = argparse.ArgumentParser(description='An intercepting proxy for testing web applications.')
|
parser = argparse.ArgumentParser(description='An intercepting proxy for testing web applications.')
|
||||||
parser.add_argument('-l', '--lite', help='Run the proxy in "lite" mode', action='store_true')
|
parser.add_argument('-l', '--lite', help='Run the proxy in "lite" mode', action='store_true')
|
||||||
try:
|
try:
|
||||||
parser.add_argument('-c', '--crypt', type=str, nargs=1, help='Start pappy in "crypto" mode, must supply a name for the encrypted project archive [CRYPT]')
|
hlpmsg = 'Start pappy in "crypto" mode,'+
|
||||||
|
'must supply a name for the encrypted'+
|
||||||
|
'project archive [CRYPT]'
|
||||||
|
parser.add_argument('-c', '--crypt', type=str, nargs=1, help=hlpmsg)
|
||||||
except:
|
except:
|
||||||
print 'Must supply a project name: pappy -c <project_name>'
|
print 'Must supply a project name: pappy -c <project_name>'
|
||||||
reactor.stop()
|
reactor.stop()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue