def test_safe_json_loads_invalid(): """Helpers - Loading invalid JSON""" json_str = 'invalid json string!!!!' loaded_json = base.safe_json_loads(json_str) assert_equal(type(loaded_json), dict) assert_false(loaded_json) assert_equal(loaded_json, {})
def test_safe_json_loads_valid(): """Helpers - Loading valid JSON""" json_str = '{"test": 0, "values": [1, 2, 3]}' loaded_json = base.safe_json_loads(json_str) assert_equal(type(loaded_json), dict) assert_true(loaded_json) assert_equal(loaded_json, {'test': 0, 'values': [1, 2, 3]})
def duo_bypass_code_create_unlimited_use(rec): """ author: @mimeframe description: Alert when a DUO bypass code is created that has unlimited use. reference: https://duo.com/docs/administration-users#generating-a-bypass-code """ return (rec['action'] == 'bypass_create' and safe_json_loads(rec['description']).get('remaining_uses') is None)
def duo_bypass_code_create_non_auto_generated(rec): """ author: @mimeframe description: Alert when a DUO bypass code is artisanly crafted and not auto-generated. reference: https://duo.com/docs/administration-users#generating-a-bypass-code """ return (rec['action'] == 'bypass_create' and safe_json_loads(rec['description']).get('auto_generated') is False)
def duo_bypass_code_create_non_expiring(rec): """ author: @mimeframe description: Alert when a DUO bypass code is created that is non-expiring. reference: https://duo.com/docs/administration-users#generating-a-bypass-code """ return (rec['action'] == 'bypass_create' and safe_json_loads(rec['description']).get('valid_secs') is None)