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')
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)
def testNoClientSelected(self): with self.assertRaises(magics_impl.NoClientSelectedError): magics_impl.grr_yara_impl('foo')