Ejemplo n.º 1
0
def test_exception():
    s = utils.exception_message()
    assert "Cuckoo version: %s" % cuckoo.__version__ in s
    assert "alembic:" in s
    assert "django-extensions:" in s
    assert "peepdf:" in s
    assert "sflock:" in s
Ejemplo n.º 2
0
def test_exception():
    s = utils.exception_message()
    assert "Cuckoo version: %s" % cuckoo.__version__ in s
    assert "alembic:" in s
    assert "django-extensions:" in s
    assert "peepdf:" in s
    assert "sflock:" in s
Ejemplo n.º 3
0
def main(ctx, debug, quiet, nolog, maxcount, user, cwd):
    """Invokes the Cuckoo daemon or one of its subcommands.

    To be able to use different Cuckoo configurations on the same machine with
    the same Cuckoo installation, we use the so-called Cuckoo Working
    Directory (aka "CWD"). A default CWD is available, but may be overridden
    through the following options - listed in order of precedence.

    \b
    * Command-line option (--cwd)
    * Environment option ("CUCKOO_CWD")
    * Environment option ("CUCKOO")
    * Current directory (if the ".cwd" file exists)
    * Default value ("~/.cuckoo")
    """
    decide_cwd(cwd)

    # Drop privileges.
    user and drop_privileges(user)
    ctx.user = user

    ctx.log = not nolog

    if quiet:
        level = logging.WARN
    elif debug:
        level = logging.DEBUG
    else:
        level = logging.INFO

    ctx.level = level

    # Update the Config.configuration object to have configuration info
    # from plugins.
    update_config()

    # A subcommand will be invoked, so don't run Cuckoo itself.
    if ctx.invoked_subcommand:
        return

    try:
        cuckoo_init(level, ctx)
        cuckoo_main(maxcount)
    except CuckooCriticalError as e:
        log.critical(red("{0}: {1}".format(e.__class__.__name__, e)))
        sys.exit(1)
    except SystemExit as e:
        if e.code:
            print e
    except Exception as e:
        # Deal with an unhandled exception.
        sys.stderr.write(exception_message())
        log.exception(red("{0}: {1}".format(e.__class__.__name__, e)))
        sys.exit(1)
Ejemplo n.º 4
0
def main(ctx, debug, quiet, nolog, maxcount, user, cwd):
    """Invokes the Cuckoo daemon or one of its subcommands.

    To be able to use different Cuckoo configurations on the same machine with
    the same Cuckoo installation, we use the so-called Cuckoo Working
    Directory (aka "CWD"). A default CWD is available, but may be overridden
    through the following options - listed in order of precedence.

    \b
    * Command-line option (--cwd)
    * Environment option ("CUCKOO_CWD")
    * Environment option ("CUCKOO")
    * Current directory (if the ".cwd" file exists)
    * Default value ("~/.cuckoo")
    """
    decide_cwd(cwd)

    # Drop privileges.
    user and drop_privileges(user)
    ctx.user = user

    ctx.log = not nolog

    if quiet:
        level = logging.WARN
    elif debug:
        level = logging.DEBUG
    else:
        level = logging.INFO

    ctx.level = level

    # A subcommand will be invoked, so don't run Cuckoo itself.
    if ctx.invoked_subcommand:
        return

    try:
        cuckoo_init(level, ctx)
        cuckoo_main(maxcount)
    except CuckooCriticalError as e:
        message = red("{0}: {1}".format(e.__class__.__name__, e))
        if len(log.handlers):
            log.critical(message)
        else:
            sys.stderr.write("{0}\n".format(message))
        sys.exit(1)
    except SystemExit as e:
        if e.code:
            print e
    except:
        # Deal with an unhandled exception.
        message = exception_message()
        print message, traceback.format_exc()