Beispiel #1
0
    def test_unicode_val_scrubbing(self):
        s = '%s is a unicode snowman!' % SNOWMAN
        obj = {'password': s}

        scrubbed = rollbar._scrub_obj(obj)

        self.assertDictEqual(scrubbed, {'password': ''.join(['*'] * len(s))})
Beispiel #2
0
    def test_unicode_key_scrubbing(self):
        s = 'is a unicode snowman!'
        obj = {SNOWMAN: s}

        rollbar.SETTINGS['scrub_fields'].append(SNOWMAN)
        scrubbed = rollbar._scrub_obj(obj)

        self.assertDictEqual(scrubbed, {SNOWMAN: ''.join(['*'] * len(s))})

        obj2 = {SNOWMAN: s}

        rollbar.SETTINGS['scrub_fields'].pop()
        rollbar.SETTINGS['scrub_fields'].append(SNOWMAN)
        scrubbed = rollbar._scrub_obj(obj2)

        self.assertDictEqual(scrubbed, {SNOWMAN: ''.join(['*'] * len(s))})
    def test_non_dict_scrubbing(self):
        params = "string"
        scrubbed = rollbar._scrub_obj(params)
        self.assertEqual(scrubbed, params)

        params = 1234
        scrubbed = rollbar._scrub_obj(params)
        self.assertEqual(scrubbed, params)

        params = None
        scrubbed = rollbar._scrub_obj(params)
        self.assertEqual(scrubbed, params)

        params = [{'password': '******', 'foo': 'bar'}]
        scrubbed = rollbar._scrub_obj(params)
        self.assertEqual([{'password': '******', 'foo': 'bar'}], scrubbed)
Beispiel #4
0
    def test_non_dict_scrubbing(self):
        params = "string"
        scrubbed = rollbar._scrub_obj(params)
        self.assertEqual(scrubbed, params)

        params = 1234
        scrubbed = rollbar._scrub_obj(params)
        self.assertEqual(scrubbed, params)

        params = None
        scrubbed = rollbar._scrub_obj(params)
        self.assertEqual(scrubbed, params)

        params = [{'password': '******', 'foo': 'bar'}]
        scrubbed = rollbar._scrub_obj(params)
        self.assertEqual([{'password': '******', 'foo': 'bar'}], scrubbed)
Beispiel #5
0
    def test_unicode_key_scrubbing(self):
        s = "is a unicode snowman!"
        obj = {SNOWMAN: s}

        rollbar.SETTINGS["scrub_fields"].append(SNOWMAN)
        scrubbed = rollbar._scrub_obj(obj)

        self.assertDictEqual(scrubbed, {SNOWMAN: "".join(["*"] * len(s))})

        obj2 = {SNOWMAN: s}

        rollbar.SETTINGS["scrub_fields"].pop()
        rollbar.SETTINGS["scrub_fields"].append(SNOWMAN)
        scrubbed = rollbar._scrub_obj(obj2)

        self.assertDictEqual(scrubbed, {SNOWMAN: "".join(["*"] * len(s))})
Beispiel #6
0
    def test_unicode_val_scrubbing(self):
        s = "%s is a unicode snowman!" % SNOWMAN
        obj = {"password": s}

        scrubbed = rollbar._scrub_obj(obj)

        self.assertDictEqual(scrubbed, {"password": "".join(["*"] * len(s))})
Beispiel #7
0
    def test_non_dict_scrubbing(self):
        params = "string"
        scrubbed = rollbar._scrub_obj(params)
        self.assertEqual(scrubbed, params)

        params = 1234
        scrubbed = rollbar._scrub_obj(params)
        self.assertEqual(scrubbed, params)

        params = None
        scrubbed = rollbar._scrub_obj(params)
        self.assertEqual(scrubbed, params)

        params = [{"password": "******", "foo": "bar"}]
        scrubbed = rollbar._scrub_obj(params)
        self.assertEqual([{"password": "******", "foo": "bar"}], scrubbed)
Beispiel #8
0
    def test_json_scrubbing(self):
        params = {
            "foo": "bar",
            "bar": {"foo": {"password": "******", "clear": "text"}, "secret": ["1234"]},
            "passwd": [{"bar": None}, {"password": "******"}],
            "secret": {"password": {"confirm_password": "******", "foo": "bar"}},
            "password_confirmation": None,
            "confirm_password": 341254213,
            333: 444,
        }

        scrubbed = rollbar._scrub_obj(params, replacement_character="-")

        self.assertDictEqual(
            scrubbed,
            {
                "foo": "bar",
                "bar": {"foo": {"password": "******", "clear": "text"}, "secret": ["----"]},
                "passwd": [{"-": "-"}, {"-": "-"}],
                "secret": {"-": "-"},
                "password_confirmation": "-",
                "confirm_password": "******",
                333: 444,
            },
        )
Beispiel #9
0
    def test_param_scrubbing(self):
        params = {
            "foo": "bar",
            "bar": "foo",
            "passwd": "passwd",
            "password": "******",
            "secret": "secret",
            "confirm_password": "******",
            "password_confirmation": "password_confirmation",
        }

        scrubbed = rollbar._scrub_obj(params)

        self.assertDictEqual(
            scrubbed,
            {
                "foo": "bar",
                "bar": "foo",
                "passwd": "******",
                "password": "******",
                "secret": "******",
                "confirm_password": "******",
                "password_confirmation": "*********************",
            },
        )

        rollbar.SETTINGS["scrub_fields"] = ["foo", "password"]

        scrubbed = rollbar._scrub_obj(params)

        self.assertDictEqual(
            scrubbed,
            {
                "foo": "***",
                "bar": "foo",
                "passwd": "passwd",
                "password": "******",
                "secret": "secret",
                "confirm_password": "******",
                "password_confirmation": "password_confirmation",
            },
        )
    def test_unicode_val_scrubbing(self):
        s = '%s is a unicode snowman!' % SNOWMAN
        obj = {
            'password': s
        }

        scrubbed = rollbar._scrub_obj(obj)

        self.assertDictEqual(scrubbed, {
            'password': ''.join(['*'] * len(s))
        })
Beispiel #11
0
    def test_param_scrubbing(self):
        params = {
            'foo': 'bar',
            'bar': 'foo',
            'passwd': 'passwd',
            'password': '******',
            'secret': 'secret',
            'confirm_password': '******',
            'password_confirmation': 'password_confirmation'
        }

        scrubbed = rollbar._scrub_obj(params)

        self.assertDictEqual(
            scrubbed, {
                'foo': 'bar',
                'bar': 'foo',
                'passwd': '******',
                'password': '******',
                'secret': '******',
                'confirm_password': '******',
                'password_confirmation': '*********************'
            })

        rollbar.SETTINGS['scrub_fields'] = ['foo', 'password']

        scrubbed = rollbar._scrub_obj(params)

        self.assertDictEqual(
            scrubbed, {
                'foo': '***',
                'bar': 'foo',
                'passwd': 'passwd',
                'password': '******',
                'secret': 'secret',
                'confirm_password': '******',
                'password_confirmation': 'password_confirmation'
            })
Beispiel #12
0
    def test_json_scrubbing(self):
        params = {
            'foo': 'bar',
            'bar': {
                'foo': {
                    'password': '******',
                    'clear': 'text'
                },
                'secret': ['1234']
            },
            'passwd': [{
                'bar': None
            }, {
                'password': '******'
            }],
            'secret': {
                'password': {
                    'confirm_password': '******',
                    'foo': 'bar'
                }
            },
            'password_confirmation': None,
            'confirm_password': 341254213,
            333: 444
        }

        scrubbed = rollbar._scrub_obj(params, replacement_character='-')

        self.assertDictEqual(
            scrubbed, {
                'foo': 'bar',
                'bar': {
                    'foo': {
                        'password': '******',
                        'clear': 'text'
                    },
                    'secret': ['----']
                },
                'passwd': [{
                    '-': '-'
                }, {
                    '-': '-'
                }],
                'secret': {
                    '-': '-'
                },
                'password_confirmation': '-',
                'confirm_password': '******',
                333: 444
            })
    def test_unicode_key_scrubbing(self):
        s = 'is a unicode snowman!'
        obj = {
            SNOWMAN: s
        }

        rollbar.SETTINGS['scrub_fields'].append(SNOWMAN)
        scrubbed = rollbar._scrub_obj(obj)

        self.assertDictEqual(scrubbed, {
            SNOWMAN: ''.join(['*'] * len(s))
        })

        obj2 = {
            SNOWMAN: s
        }

        rollbar.SETTINGS['scrub_fields'].pop()
        rollbar.SETTINGS['scrub_fields'].append(SNOWMAN)
        scrubbed = rollbar._scrub_obj(obj2)

        self.assertDictEqual(scrubbed, {
            SNOWMAN: ''.join(['*'] * len(s))
        })
    def test_param_scrubbing(self):
        params = {
            'foo': 'bar',
            'bar': 'foo',
            'passwd': 'passwd',
            'password': '******',
            'secret': 'secret',
            'confirm_password': '******',
            'password_confirmation': 'password_confirmation'
        }

        scrubbed = rollbar._scrub_obj(params)

        self.assertDictEqual(scrubbed, {
            'foo': 'bar',
            'bar': 'foo',
            'passwd': '******',
            'password': '******',
            'secret': '******',
            'confirm_password': '******',
            'password_confirmation': '*********************'
        })

        rollbar.SETTINGS['scrub_fields'] = ['foo', 'password']

        scrubbed = rollbar._scrub_obj(params)

        self.assertDictEqual(scrubbed, {
            'foo': '***',
            'bar': 'foo',
            'passwd': 'passwd',
            'password': '******',
            'secret': 'secret',
            'confirm_password': '******',
            'password_confirmation': 'password_confirmation'
        })
    def test_json_scrubbing(self):
        params = {
            'foo': 'bar',
            'bar': {
                'foo': {
                    'password': '******',
                    'clear': 'text'
                },
                'secret': ['1234']
            },
            'passwd': [
                {'bar': None},
                {'password': '******'}
            ],
            'secret': {
                'password': {
                    'confirm_password': '******',
                    'foo': 'bar'
                }
            },
            'password_confirmation': None,
            'confirm_password': 341254213,
            333: 444
        }

        scrubbed = rollbar._scrub_obj(params, replacement_character='-')

        self.assertDictEqual(scrubbed, {
            'foo': 'bar',
            'bar': {
                'foo': {
                    'password': '******',
                    'clear': 'text'
                },
                'secret': ['----']
            },
            'passwd': [{'-': '-'}, {'-': '-'}],
            'secret': {'-': '-'},
            'password_confirmation': '-',
            'confirm_password': '******',
            333: 444
        })