예제 #1
0
    def testWithClientSet(self):
        mock_client = mock.MagicMock()

        with mock.patch.object(magics_impl._state, 'client', mock_client):
            magics_impl.grr_yara_impl('foo', [42], 'bar')

            mock_client.yara.assert_called_once_with('foo', [42], 'bar')
예제 #2
0
def grr_yara(line: Text) -> pd.DataFrame:
    """Scans processes using provided YARA rule.

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

  Returns:
    A sequence of YARA matches.

  Raises:
    NoClientSelectedError: Client is not selected to perform this operation.
  """
    args = grr_yara.parser.parse_args(shlex.split(line))
    return magics_impl.grr_yara_impl(args.signature, args.pids, args.regex)
예제 #3
0
 def testNoClientSelected(self):
     with self.assertRaises(magics_impl.NoClientSelectedError):
         magics_impl.grr_yara_impl('foo')