DSaaS 使用 Python 添加全局规则

DSaaS Adding Global Rule with Python

尝试使用自动化 API 示例将全局规则添加到 DSaaS。我不知道如何在 globalrules = deepsecurity.ApplicationControlGlobalRules().

中填充散列、描述对

尝试使用 JSON 但不知道该怎么做。

from __future__ import print_function
import sys, warnings
import deepsecurity
from deepsecurity.rest import ApiException
from pprint import pprint

# Setup
if not sys.warnoptions:
    warnings.simplefilter("ignore")
configuration = deepsecurity.Configuration()
configuration.host = 'YOUR_HOST'

# Authentication
configuration.api_key['api-secret-key'] = 'YOUR_API_KEY'

# Initialization
# Set Any Required Values
api_instance = deepsecurity.GlobalRulesApi(deepsecurity.ApiClient(configuration))
globalrules = deepsecurity.ApplicationControlGlobalRules()
api_version = 'YOUR VERSION'

try:
    api_response = api_instance.add_global_rules(globalrules, api_version)
    pprint(api_response)
except ApiException as e:
    print("An exception occurred when calling GlobalRulesApi.add_global_rules: %s\n" % e)

我想知道如何在传递给 add_global_rules 方法的对象中填充散列、描述对。

我假设您想使用 Python SDK 向您的 DSaaS 帐户添加一些全局应用程序控制规则。为此,首先要创建这样的规则

rules = []
rules.append(deepsecurity.ApplicationControlGlobalRule(sha256="YOUR_SHA256_HERE", description="YOUR_DESCRIPTION_HERE"))
...

根据需要附加更多规则。然后将它们添加到 ApplicationControlGlobalRules 对象

globalrules = deepsecurity.ApplicationControlGlobalRules(application_control_global_rules = rules)

一般来说,您的代码示例如下

from __future__ import print_function
import sys, warnings
import deepsecurity
from deepsecurity.rest import ApiException
from pprint import pprint

# Setup
if not sys.warnoptions:
    warnings.simplefilter("ignore")
configuration = deepsecurity.Configuration()
configuration.host = 'YOUR_HOST'

# Authentication
configuration.api_key['api-secret-key'] = 'YOUR_API_KEY'

# Initialization
# Set Any Required Values
api_instance = deepsecurity.GlobalRulesApi(deepsecurity.ApiClient(configuration))
api_version = 'YOUR VERSION'

# Create empty list for Global Application Control Rules
rules = []
rules.append(deepsecurity.ApplicationControlGlobalRule(sha256="YOUR_SHA256_HERE", description="YOUR_DESCRIPTION_HERE"))
# ... Add more Global Application Control Rules as required here

# Create ApplicationControlGlobalRules object with the rules
globalrules = deepsecurity.ApplicationControlGlobalRules(application_control_global_rules = rules)

try:
    api_response = api_instance.add_global_rules(globalrules, api_version)
    pprint(api_response)
except ApiException as e:
    print("An exception occurred when calling GlobalRulesApi.add_global_rules: %s\n" % e)

P.S。我在趋势科技的 Deep Security 团队工作。