예제 #1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-p",
                        "--project",
                        help="Specify a new or existing project name",
                        action="store",
                        required=False)
    parser.add_argument("-f",
                        "--file",
                        help="Specify a file to be opened directly",
                        action="store",
                        required=False)
    parser.add_argument("--version", action="version", version=__version__)

    args = parser.parse_args()

    if args.project:
        __project__.open(args.project)

    if args.file:
        if not os.path.exists(args.file):
            print("ERROR: The specified path does not exist")
            sys.exit(-1)

        __sessions__.new(args.file)

    c = console.Console()
    c.start()
예제 #2
0
 def test_redirect(self, capsys):
     instance = console.Console()
     if sys.version_info <= (3, 0):
         in_fct = 'viper.core.ui.console.input'
     else:
         in_fct = 'builtins.input'
     with mock.patch(in_fct, return_value='help > ./redirect;exit'):
         instance.start()
     out, err = capsys.readouterr()
     assert re.search(r".*Output written to  ./redirect.*", out)
예제 #3
0
 def test_start(self, capsys):
     instance = console.Console()
     if sys.version_info <= (3, 0):
         in_fct = 'viper.core.ui.console.input'
     else:
         in_fct = 'builtins.input'
     with mock.patch(in_fct, return_value='help;exit'):
         instance.start()
     out, err = capsys.readouterr()
     assert re.search(r".*You have .* files in your .* repository.*", out)
     assert re.search(r".* Commands.*", out)
     assert re.search(r".* Modules.*", out)
예제 #4
0
 def test_opened_session(self, capsys, filename, command, expected):
     if filename == "chromeinstall-8u31.exe":
         __sessions__.new(path=os.path.join(FIXTURE_DIR, filename))
     elif filename == '58e902cd-dae8-49b9-882b-186c02de0b81.json':
         me = MispEvent(os.path.join(FIXTURE_DIR, filename), True)
         __sessions__.new(misp_event=me)
     instance = console.Console()
     if sys.version_info <= (3, 0):
         in_fct = 'viper.core.ui.console.input'
     else:
         in_fct = 'builtins.input'
     with mock.patch(in_fct, return_value='{};exit'.format(command)):
         instance.start()
     out, err = capsys.readouterr()
     assert re.search(r".*{}.*".format(expected), out)
예제 #5
0
#!/usr/bin/env python
# This file is part of Viper - https://github.com/botherder/viper
# See the file 'LICENSE' for copying permission.

import argparse

from viper.core.ui import console
from viper.core.project import __project__

parser = argparse.ArgumentParser()
parser.add_argument('-p',
                    '--project',
                    help='Specify a new or existing project name',
                    action='store',
                    required=False)
args = parser.parse_args()

if args.project:
    __project__.open(args.project)

c = console.Console()
c.start()
예제 #6
0
 def test_init(self):
     instance = console.Console()
     assert isinstance(instance, console.Console)