本文整理汇总了Python中crits.config.config.CRITsConfig.save方法的典型用法代码示例。如果您正苦于以下问题:Python CRITsConfig.save方法的具体用法?Python CRITsConfig.save怎么用?Python CRITsConfig.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类crits.config.config.CRITsConfig
的用法示例。
在下文中一共展示了CRITsConfig.save方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: modify_configuration
# 需要导入模块: from crits.config.config import CRITsConfig [as 别名]
# 或者: from crits.config.config.CRITsConfig import save [as 别名]
def modify_configuration(config_form, analyst):
"""
Modify the configuration with the submitted changes.
:param config_form: The form data.
:type config_form: dict
:param analyst: The user making the modifications.
:type analyst: str
:returns: dict with key "message"
"""
config = CRITsConfig.objects().first()
if not config:
config = CRITsConfig()
data = config_form.cleaned_data
allowed_hosts_list = data['allowed_hosts'].split(',')
allowed_hosts = ()
for allowed_host in allowed_hosts_list:
allowed_hosts = allowed_hosts + (allowed_host.strip(),)
data['allowed_hosts'] = allowed_hosts
service_dirs_list = data['service_dirs'].split(',')
service_dirs = ()
for service_dir in service_dirs_list:
service_dirs = service_dirs + (service_dir.strip(),)
data['service_dirs'] = service_dirs
config.merge(data, overwrite=True)
try:
config.save(username=analyst)
return {'message': "Success!"}
except Exception, e:
return {'message': "Failure: %s" % e}
示例2: force_reset_config
# 需要导入模块: from crits.config.config import CRITsConfig [as 别名]
# 或者: from crits.config.config.CRITsConfig import save [as 别名]
def force_reset_config():
"""
Resets the values for the CRITsConfig class by dropping the
database collection and then saving a new default CRITsConfig.
"""
print "Resetting CRITs configuration settings."
CRITsConfig.drop_collection();
crits_config = CRITsConfig();
crits_config.save();
示例3: get_config
# 需要导入模块: from crits.config.config import CRITsConfig [as 别名]
# 或者: from crits.config.config.CRITsConfig import save [as 别名]
def get_config():
"""
Get the CRITs configuration.
:returns: :class:`crits.config.config.CRITsConfig`
"""
crits_config = CRITsConfig.objects().first()
if not crits_config:
crits_config = CRITsConfig()
crits_config.save()
return crits_config
示例4: create_config_if_not_exist
# 需要导入模块: from crits.config.config import CRITsConfig [as 别名]
# 或者: from crits.config.config.CRITsConfig import save [as 别名]
def create_config_if_not_exist():
"""
If the CRITsConfig already exists then the CRITsConfig is returned,
otherwise a new CRITsConfig will be created, saved, and returned.
Returns:
Returns the CRITsConfig if it already exists, otherwise a
default CRITsConfig is returned.
"""
crits_config = CRITsConfig.objects().first()
if not crits_config:
print "Creating a new CRITs configuration."
crits_config = CRITsConfig()
crits_config.save()
else:
print "A CRITs configuration already exists. Skipping default creation."
return crits_config
示例5: prep_db
# 需要导入模块: from crits.config.config import CRITsConfig [as 别名]
# 或者: from crits.config.config.CRITsConfig import save [as 别名]
def prep_db():
"""
Prep the DB for testing.
"""
clean_db()
# Create a new default config
crits_config = CRITsConfig()
crits_config.save()
# Add Source
handlers.add_new_source(TSRC, TRANDUSER)
# Add User
user = CRITsUser.create_user(username=TUSER_NAME,
password=TUSER_PASS,
email=TUSER_EMAIL
)
user.first_name = TUSER_FNAME
user.last_name = TUSER_LNAME
user.save()
# Add test source object
'''
示例6: prep_db
# 需要导入模块: from crits.config.config import CRITsConfig [as 别名]
# 或者: from crits.config.config.CRITsConfig import save [as 别名]
def prep_db():
"""
Prep the DB for testing.
"""
clean_db()
# Create a new default config
crits_config = CRITsConfig()
crits_config.save()
# Add Source
handlers.add_new_source(TSRC, TRANDUSER)
# Add User
user = CRITsUser.create_user(username=TUSER_NAME,
password=TUSER_PASS,
email=TUSER_EMAIL,
)
user.first_name = TUSER_FNAME
user.last_name = TUSER_LNAME
user.save()
# Add test source object
obj = TestSourceObject()
obj.name = TOBJS_NAME
obj.value = TOBJS_VALUE
obj.add_source(source=TSRC, analyst=TUSER_NAME)
obj.save()
# Add another with Different source
obj = TestSourceObject()
obj.name = TOBJS_NAME
obj.value = TOBJS_VALUE
obj.add_source(source=TUNKSRC, analyst=TRANDUSER)
obj.save()
# Add test non-source object
obj = TestObject()
obj.name = TOBJ_NAME
obj.value = TOBJ_VALUE
obj.save()