Esempio n. 1
0
    def testTskPathType(self):
        mock_client = mock.MagicMock()

        with mock.patch.object(magics_impl._state, 'client', mock_client):
            magics_impl.grr_stat_impl('/foo/bar', path_type=magics_impl.TSK)

            mock_client.tsk.glob.assert_called_once_with('/foo/bar')
Esempio n. 2
0
  def testRegistryPathType(self):
    mock_client = mock.MagicMock()

    with mock.patch.object(magics_impl._state, 'client', mock_client):
      magics_impl.grr_stat_impl('/foo/bar', path_type=magics_impl.REGISTRY)

      mock_client.registry.glob.assert_called_once_with('/foo/bar')
Esempio n. 3
0
    def testAbsolutePath(self):
        mock_client = mock.MagicMock()

        with mock.patch.object(magics_impl._state, 'client', mock_client):
            with mock.patch.object(magics_impl._state, 'cur_dir', '/quux'):
                magics_impl.grr_stat_impl('/foo/bar')

                mock_client.os.glob.assert_called_once_with('/foo/bar')
Esempio n. 4
0
def grr_stat(line: Text) -> pd.DataFrame:
    """Stats the file specified.

  Accepts glob expressions as a file path.

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

  Returns:
    A sequence of stat entries.

  Raises:
    NoClientSelectedError: Client is not selected to perform this operation.
  """
    args = grr_stat.parser.parse_args(shlex.split(line))
    return magics_impl.grr_stat_impl(path=args.path, path_type=args.path_type)
Esempio n. 5
0
 def testNoClientSelected(self):
     with self.assertRaises(magics_impl.NoClientSelectedError):
         magics_impl.grr_stat_impl('foo')