3

尝试使用自动化 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 方法的对象中填充散列、描述对。

4

1 回答 1

2

我假设您想使用 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)

PS 我在趋势科技的 Deep Security 团队工作。

于 2019-08-15T17:56:18.557 回答