Example #1
0
def load_script(zap_helper, **options):
    """Load a script from a file."""
    with zap_error_handler():
        if not os.path.isfile(options['file_path']):
            raise ZAPError(
                'No file found at "{0}", cannot load script.'.format(
                    options['file_path']))

        if not _is_valid_script_engine(zap_helper.zap, options['engine']):
            engines = zap_helper.zap.script.list_engines
            raise ZAPError(
                'Invalid script engine provided. Valid engines are: {0}'.
                format(', '.join(engines)))

        console.debug('Loading script "{0}" from "{1}"'.format(
            options['name'], options['file_path']))
        result = zap_helper.zap.script.load(
            options['name'],
            options['script_type'],
            options['engine'],
            options['file_path'],
            scriptdescription=options['description'])

        if result != 'OK':
            raise ZAPError('Error loading script: {0}'.format(result))

    console.info('Script "{0}" loaded'.format(options['name']))
Example #2
0
def load_session(zap_helper, file_path):
    """Load a given session."""
    with zap_error_handler():
        if not os.path.isfile(file_path):
            raise ZAPError('No file found at "{0}", cannot load session.'.format(file_path))
        console.debug('Loading session from "{0}"'.format(file_path))
        zap_helper.zap.core.load_session(file_path)
Example #3
0
def load_session(zap_helper, file_path):
    """Load a given session."""
    with zap_error_handler():
        if not os.path.isfile(file_path):
            raise ZAPError(
                'No file found at "{0}", cannot load session.'.format(
                    file_path))
        console.debug('Loading session from "{0}"'.format(file_path))
        zap_helper.zap.core.load_session(file_path)
Example #4
0
def remove_script(zap_helper, script_name):
    """Remove a script."""
    with zap_error_handler():
        console.debug('Removing script "{0}"'.format(script_name))
        result = zap_helper.zap.script.remove(script_name)

        if result != 'OK':
            raise ZAPError('Error removing script: {0}'.format(result))

    console.info('Script "{0}" removed'.format(script_name))
Example #5
0
def disable_script(zap_helper, script_name):
    """Disable a script."""
    with zap_error_handler():
        console.debug('Disabling script "{0}"'.format(script_name))
        result = zap_helper.zap.script.disable(script_name)

        if result != 'OK':
            raise ZAPError('Error disabling script: {0}'.format(result))

    console.info('Script "{0}" disabled'.format(script_name))
Example #6
0
def remove_script(zap_helper, script_name):
    """Remove a script."""
    with zap_error_handler():
        console.debug('Removing script "{0}"'.format(script_name))
        result = zap_helper.zap.script.remove(script_name)

        if result != 'OK':
            raise ZAPError('Error removing script: {0}'.format(result))

    console.info('Script "{0}" removed'.format(script_name))
Example #7
0
def disable_script(zap_helper, script_name):
    """Disable a script."""
    with zap_error_handler():
        console.debug('Disabling script "{0}"'.format(script_name))
        result = zap_helper.zap.script.disable(script_name)

        if result != 'OK':
            raise ZAPError('Error disabling script: {0}'.format(result))

    console.info('Script "{0}" disabled'.format(script_name))
Example #8
0
def load_script(zap_helper, **options):
    """Load a script from a file."""
    with zap_error_handler():
        if not os.path.isfile(options['file_path']):
            raise ZAPError('No file found at "{0}", cannot load script.'.format(options['file_path']))

        if not _is_valid_script_engine(zap_helper.zap, options['engine']):
            engines = zap_helper.zap.script.list_engines
            raise ZAPError('Invalid script engine provided. Valid engines are: {0}'.format(', '.join(engines)))

        console.debug('Loading script "{0}" from "{1}"'.format(options['name'], options['file_path']))
        result = zap_helper.zap.script.load(options['name'], options['script_type'], options['engine'],
                                            options['file_path'], scriptdescription=options['description'])

        if result != 'OK':
            raise ZAPError('Error loading script: {0}'.format(result))

    console.info('Script "{0}" loaded'.format(options['name']))
Example #9
0
def save_session(zap_helper, file_path):
    """Save the session."""
    console.debug('Saving the session to "{0}"'.format(file_path))
    zap_helper.zap.core.save_session(file_path, overwrite='true')
Example #10
0
def new_session(zap_helper):
    """Start a new session."""
    console.debug('Starting a new session')
    zap_helper.zap.core.new_session()
Example #11
0
def save_session(zap_helper, file_path):
    """Save the session."""
    console.debug('Saving the session to "{0}"'.format(file_path))
    zap_helper.zap.core.save_session(file_path, overwrite='true')
Example #12
0
def new_session(zap_helper):
    """Start a new session."""
    console.debug('Starting a new session')
    zap_helper.zap.core.new_session()