Exemplo n.º 1
0
    def testWithClientSet(self):
        mock_client = mock.MagicMock()

        with mock.patch.object(magics_impl._state, 'client', mock_client):
            magics_impl.grr_osqueryi_impl('foo bar')

            mock_client.osquery.assert_called_once_with('foo bar')
Exemplo n.º 2
0
def grr_osqueryi(line: Text) -> pd.DataFrame:
    """Runs given SQL statement on client osquery.

  Args:
    line: A string representing arguments passed to the magic command.

  Returns:
    Osquery table.

  Raises:
    NoClientSelectedError: Client is not selected to perform this operation.
  """
    args = grr_osqueryi.parser.parse_args(shlex.split(line))
    return magics_impl.grr_osqueryi_impl(args.sql)
Exemplo n.º 3
0
 def testNoClientSelected(self):
     with self.assertRaises(magics_impl.NoClientSelectedError):
         magics_impl.grr_osqueryi_impl('foo bar')