本文整理汇总了Python中esapi.core.ESAPI.intrusion_detector方法的典型用法代码示例。如果您正苦于以下问题:Python ESAPI.intrusion_detector方法的具体用法?Python ESAPI.intrusion_detector怎么用?Python ESAPI.intrusion_detector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类esapi.core.ESAPI
的用法示例。
在下文中一共展示了ESAPI.intrusion_detector方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_event
# 需要导入模块: from esapi.core import ESAPI [as 别名]
# 或者: from esapi.core.ESAPI import intrusion_detector [as 别名]
def test_add_event(self):
username = "testAddEventIDS"
password = "addEvent"
auth = ESAPI.authenticator()
user = auth.create_user(username, password, password)
user.enable()
request = MockHttpRequest()
response = MockHttpResponse()
ESAPI.http_utilities().set_current_http(request, response)
user.login_with_password(password)
# Generate some events to disable the account
for i in range(15):
ESAPI.intrusion_detector().add_event("test", "test message")
self.assertTrue(user.is_locked())
示例2: __init__
# 需要导入模块: from esapi.core import ESAPI [as 别名]
# 或者: from esapi.core.ESAPI import intrusion_detector [as 别名]
def __init__(self, user_message, log_message, cause=None):
"""
Creates a new instance of IntrusionException.
@param user_message: the message displayed to the user
@param log_message: the message logged
@param cause: the Exception that caused this one
"""
Exception.__init__(self, user_message)
self.user_message = user_message
self.log_message = log_message
self.cause = cause
self.logger = ESAPI.logger("IntrusionException")
self.logger.error(Logger.SECURITY_FAILURE, _("INTRUSION") + " - " + self.log_message)
ESAPI.intrusion_detector().add_exception(self)
示例3: test_add_exception
# 需要导入模块: from esapi.core import ESAPI [as 别名]
# 或者: from esapi.core.ESAPI import intrusion_detector [as 别名]
def test_add_exception(self):
ESAPI.intrusion_detector().add_exception( RuntimeError('message') )
ESAPI.intrusion_detector().add_exception(
ValidationException("user message", "log message") )
ESAPI.intrusion_detector().add_exception(
IntrusionException("user message", "log message") )
username = "testAddException"
password = "addException"
auth = ESAPI.authenticator()
user = auth.create_user(username, password, password)
user.enable()
request = MockHttpRequest()
response = MockHttpResponse()
ESAPI.http_utilities().set_current_http(request, response)
user.login_with_password(password)
# Generate some exceptions to disable the account
for i in range(15):
IntegrityException(
"IntegrityException %s" % i,
"IntegrityException %s" % i )
self.assertFalse(user.is_logged_in())
self.assertTrue(user.is_locked())