Ejemplo n.º 1
0
def test_get_filtered_config_remove_sensitive_keys(base_world, data_svc):
    test_conf = {
        'users': 'this should be filtered',
        'host': 'this should be filtered',
        'foo': '1',
        'bar': '2',
        'baz': '3'
    }
    base_world.apply_config('test', test_conf)

    manager = ConfigApiManager(data_svc, None)
    filtered = manager.get_filtered_config('test')
    expected = {'foo': '1', 'bar': '2', 'baz': '3'}

    assert filtered == expected
Ejemplo n.º 2
0
async def test_update_global_agent_config_updates_list_properties(
        base_world, ability):
    stub_data_svc = StubDataService()
    stub_data_svc.abilities = [
        ability('ability-1'),
        ability('ability-2'),
        ability('ability-3')
    ]

    manager = ConfigApiManager(data_svc=stub_data_svc, file_svc=None)
    await manager.update_global_agent_config(
        deadman_abilities=['ability-1', 'ability-2'],
        bootstrap_abilities=['ability-3'])

    agent_config = manager.get_filtered_config('agents')
    assert agent_config['deadman_abilities'] == ['ability-1', 'ability-2']
    assert agent_config['bootstrap_abilities'] == ['ability-3']
Ejemplo n.º 3
0
async def test_update_main_config_throws_validation_error_empty_prop(
        base_world, data_svc):
    manager = ConfigApiManager(data_svc, None)

    with pytest.raises(errors.DataValidationError):
        await manager.update_main_config(prop='', value=1234)
Ejemplo n.º 4
0
async def test_update_global_agent_config_throws_validation_error_bad_implant_name(
        base_world, data_svc):
    manager = ConfigApiManager(data_svc, None)

    with pytest.raises(errors.DataValidationError):
        await manager.update_global_agent_config(implant_name='')
Ejemplo n.º 5
0
async def test_update_global_agent_config_throws_validation_error_bad_untrusted_timer(
        base_world, data_svc):
    manager = ConfigApiManager(data_svc, None)

    with pytest.raises(errors.DataValidationError):
        await manager.update_global_agent_config(untrusted_timer=-1)
Ejemplo n.º 6
0
 def __init__(self, services):
     super().__init__(auth_svc=services['auth_svc'])
     self._api_manager = ConfigApiManager(data_svc=services['data_svc'],
                                          file_svc=services['file_svc'])
Ejemplo n.º 7
0
async def test_update_global_agent_config_throws_validation_error_bad_watchdog(
        base_world, data_svc):
    manager = ConfigApiManager(data_svc)

    with pytest.raises(errors.DataValidationError):
        await manager.update_global_agent_config(watchdog=-1)