Beispiel #1
0
 def test_no(self):
     self.assertEqual(to_yes_no(None), 'no')
     self.assertEqual(to_yes_no(False), 'no')
     self.assertEqual(to_yes_no(1), 'no')
     self.assertEqual(to_yes_no(0), 'no')
     self.assertEqual(to_yes_no(123), 'no')
     self.assertEqual(to_yes_no('foo'), 'no')
Beispiel #2
0
    def mutate(_root, info, input_object):

        task_id = str(input_object.task_id)
        name = input_object.name
        comment = input_object.comment
        alterable = input_object.alterable

        if input_object.alert_ids is not None:
            alert_ids = [str(alert_id) for alert_id in input_object.alert_ids]
        else:
            alert_ids = []

        target_id = str(input_object.target_id)
        scanner_id = str(input_object.scanner_id)
        config_id = str(input_object.scan_config_id)

        schedule_id = (str(input_object.schedule_id)
                       if input_object.schedule_id is not None else RESET_UUID)

        preferences = {}

        input_preferences = input_object.preferences

        if input_preferences:
            if input_preferences.create_assets_apply_overrides is not None:
                preferences['assets_apply_overrides'] = to_yes_no(
                    input_preferences.create_assets_apply_overrides)

            if input_preferences.create_assets_min_qod is not None:
                preferences[
                    'assets_min_qod'] = input_preferences.create_assets_min_qod

            if input_preferences.auto_delete_reports is not None:
                preferences['auto_delete'] = "keep"
                preferences[
                    'auto_delete_data'] = input_preferences.auto_delete_reports
            else:
                preferences['auto_delete'] = "no"

            if input_preferences.create_assets is not None:
                preferences['in_assets'] = to_yes_no(
                    input_preferences.create_assets)

            if input_preferences.max_concurrent_nvts is not None:
                preferences[
                    'max_checks'] = input_preferences.max_concurrent_nvts

            if input_preferences.max_concurrent_hosts is not None:
                preferences[
                    'max_hosts'] = input_preferences.max_concurrent_hosts

        gmp = get_gmp(info)

        gmp.modify_task(
            task_id,
            name=name,
            config_id=config_id,
            target_id=target_id,
            scanner_id=scanner_id,
            alterable=alterable,
            schedule_id=schedule_id,
            comment=comment,
            alert_ids=alert_ids,
            preferences=preferences,
        )

        return ModifyTask(ok=True)
Beispiel #3
0
    def mutate(_root, info, input_object):

        name = input_object.name
        alterable = input_object.alterable
        comment = input_object.comment

        if input_object.alert_ids is not None:
            alert_ids = [str(alert_id) for alert_id in input_object.alert_ids]
        else:
            alert_ids = None

        schedule_id = (str(input_object.schedule_id)
                       if input_object.schedule_id is not None else None)
        scanner_id = (str(input_object.scanner_id)
                      if input_object.scanner_id is not None else None)
        target_id = (str(input_object.target_id)
                     if input_object.target_id is not None else None)
        config_id = (str(input_object.scan_config_id)
                     if input_object.scan_config_id is not None else None)

        preferences = {}

        input_preferences = input_object.preferences

        if input_preferences:
            if input_preferences.create_assets_apply_overrides is not None:
                preferences['assets_apply_overrides'] = to_yes_no(
                    input_preferences.create_assets_apply_overrides)

            if input_preferences.create_assets_min_qod is not None:
                preferences[
                    'assets_min_qod'] = input_preferences.create_assets_min_qod

            if input_preferences.auto_delete_reports is not None:
                preferences['auto_delete'] = "keep"
                preferences[
                    'auto_delete_data'] = input_preferences.auto_delete_reports
            else:
                preferences['auto_delete'] = "no"

            if input_preferences.create_assets is not None:
                preferences['in_assets'] = to_yes_no(
                    input_preferences.create_assets)

            if input_preferences.max_concurrent_nvts is not None:
                preferences[
                    'max_checks'] = input_preferences.max_concurrent_nvts

            if input_preferences.max_concurrent_hosts is not None:
                preferences[
                    'max_hosts'] = input_preferences.max_concurrent_hosts

        gmp = get_gmp(info)

        resp = gmp.create_task(
            name,
            str(config_id),
            str(target_id),
            str(scanner_id),
            alterable=alterable,
            comment=comment,
            alert_ids=alert_ids,
            schedule_id=schedule_id,
            preferences=preferences,
        )
        return CreateTask(task_id=resp.get('id'))
Beispiel #4
0
 def test_yes(self):
     self.assertEqual(to_yes_no(True), 'yes')