Skip to content

Commit

Permalink
Remove deprecated KeepAlive attribute (#771)
Browse files Browse the repository at this point in the history
  • Loading branch information
jleaniz authored Aug 1, 2023
1 parent c35857f commit c41269d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
12 changes: 1 addition & 11 deletions dftimewolf/lib/collectors/grr_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ class GRRFlow(GRRBaseModule, module.ThreadAwareModule):
"""Launches and collects GRR flows.
Modules that use GRR flows or interact with hosts should extend this class.
Attributes:
keepalive (bool): True if the GRR keepalive functionality should be used.
"""
_CHECK_APPROVAL_INTERVAL_SEC = 10
_CHECK_FLOW_INTERVAL_SEC = 10
Expand All @@ -60,7 +57,6 @@ def __init__(self,
"""
module.ThreadAwareModule.__init__(self, state, name=name, critical=critical)
GRRBaseModule.__init__(self)
self.keepalive = False
self._skipped_flows = [] # type: List[Tuple[str, str]]
self.skip_offline_clients = False

Expand Down Expand Up @@ -216,7 +212,7 @@ def _FindClients(self, selectors: List[str]) -> List[Client]:

# TODO: change object to more specific GRR type information.
def _LaunchFlow(self, client: Client, name: str, args: str) -> str:
"""Creates the specified flow, setting KeepAlive if requested.
"""Creates the specified flow.
Args:
client (object): GRR Client object on which to launch the flow.
Expand All @@ -243,12 +239,6 @@ def _LaunchFlow(self, client: Client, name: str, args: str) -> str:
flow_id = str(grr_flow.flow_id) # pytype: disable=attribute-error
self.PublishMessage(f'{flow_id}: Scheduled')

if self.keepalive:
keepalive_flow = client.CreateFlow(
name='KeepAlive', args=flows_pb2.KeepAliveArgs())
self.logger.info(
f'KeepAlive Flow:{keepalive_flow.flow_id:s} scheduled')

return flow_id

# TODO: change object to more specific GRR type information.
Expand Down
13 changes: 0 additions & 13 deletions tests/lib/collectors/grr_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,6 @@ def testLaunchFlow(self, mock_CreateFlow):
self.assertEqual(flow_id, 'F:12345')
mock_CreateFlow.assert_called_once_with(name="FlowName", args="FlowArgs")

@mock.patch('grr_api_client.client.ClientBase.CreateFlow')
def testLaunchFlowKeepalive(self, mock_CreateFlow):
"""Tests that keepalive flows are correctly created."""
mock_CreateFlow.return_value = mock_grr_hosts.MOCK_FLOW
self.grr_flow_module.keepalive = True
flow_id = self.grr_flow_module._LaunchFlow(
mock_grr_hosts.MOCK_CLIENT, "FlowName", "FlowArgs")
self.assertEqual(flow_id, 'F:12345')
self.assertEqual(mock_CreateFlow.call_count, 2)
self.assertEqual(
mock_CreateFlow.call_args,
((), {'name': 'KeepAlive', 'args': flows_pb2.KeepAliveArgs()}))

@mock.patch('grr_api_client.flow.FlowRef.Get')
def testAwaitFlow(self, mock_FlowGet):
"""Test that no errors are generated when GRR flow succeeds."""
Expand Down

0 comments on commit c41269d

Please sign in to comment.