How to use the pyzabbix.logger.HideSensitiveService.HIDEMASK function in pyzabbix

To help you get started, we’ve selected a few pyzabbix examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adubkov / py-zabbix / tests / test_api.py View on Github external
'key_': 'system.cpu.switches',
                    'description': '',
                }],
                'id': 1,
            }
            self.urlopen_mock.return_value = MockResponse(json.dumps(ret))
            zapi.get_id('item', item='Test Item')

        log_string = "".join(cm.output)

        self.assertNotIn('PASSWORD', log_string)
        self.assertNotIn('0424bd59b807674191e7d77572075f33', log_string)

        # count number or passwords/token replacements
        # (including 'DEBUG:pyzabbix.api:ZabbixAPI.login(Admin,********)')
        self.assertEqual(log_string.count(HideSensitiveService.HIDEMASK), 4)
github adubkov / py-zabbix / tests / test_hide_sensitive_filter.py View on Github external
def test_hide_filter_multi(self):

        test_message = '"password": "hide_this", ' \
                       '"result": "0424bd59b807674191e7d77572075f33", ' \
                       '"result": "do_not_hide_this", ' \
                       '"auth": "0424bd59b807674191e7d77572075f33"'
        expected = ('"password": "{}", '
                    '"result": "{}", '
                    '"result": "do_not_hide_this", '
                    '"auth": "{}"').format(
                        HideSensitiveService.HIDEMASK,
                        HideSensitiveService.HIDEMASK,
                        HideSensitiveService.HIDEMASK)

        self.assertEqual(HideSensitiveService.hide_sensitive(test_message),
                         expected)
github adubkov / py-zabbix / tests / test_hide_sensitive_filter.py View on Github external
def test_hide_filter_do_not_change_url(self):

        # Filter should not hide 'zabbix' in URL:
        # https://localhost/zabbix/api_jsonrpc.php
        test = 'urllib2.Request(https://localhost/zabbix/api_jsonrpc.php,' \
            '{ ... "params": {"user": "Admin", "password": "zabbix"}, '\
            '"id": "1"}))'
        expected = 'urllib2.Request(https://localhost/zabbix/api_jsonrpc.php,'\
            '{ ... "params": {"user": "Admin", "password": "' + \
            HideSensitiveService.HIDEMASK + '"}, "id": "1"}))'

        self.assertEqual(HideSensitiveService.hide_sensitive(test),
                         expected)