Пример #1
0
    def test_clone_remote_rules(self, mock_print: mock.MagicMock):
        """Mock out the clone process and verify which rules files were saved/deleted."""
        with mock.patch('subprocess.check_call',
                        side_effect=self._mock_git_clone):
            clone_rules.clone_remote_rules()

        mock_print.assert_has_calls([
            mock.call(
                '[1/2] Cloning https://github.com/test-user1/test-repo1... ',
                end='',
                flush=True),
            mock.call('1 YARA file copied'),
            mock.call(
                '[2/2] Cloning https://github.com/test-user2/test-repo2... ',
                end='',
                flush=True),
            mock.call('1 YARA file copied'),
            mock.call('Done! 2 YARA files cloned from 2 repositories.')
        ])

        expected_files = {
            'github.com/test-user1/test-repo1/yara/cloned.yara',
            'github.com/test-user2/test-repo2/yara/cloned.yara',
            'private/private.yara'
        }
        self.assertEqual(expected_files, set(compile_rules._find_yara_files()))
Пример #2
0
 def clone_rules() -> None:
     """Clone YARA rules from other open-source projects."""
     clone_rules.clone_remote_rules()