如何通过 pyTenable 库批量编辑 Tenable.sc 资产?

问题描述

利用 PyTenable 库,我试图找出通过删除所有空格并用下划线替换来更改所有 Tenable 资产名称的最佳方法。例如。 - 将“资产 1”更改为“资产_1”,然后迭代到下一个资产并执行相同的操作。

这是我引用代码链接 - https://pytenable.readthedocs.io/en/stable/sc.html#asset-lists

我开始使用的方法edit 方法,我在这里使用的方法是:

from tenable.sc import TenableSC

#Login
sc = TenableSC('0.0.0.0',username='user1',password='pass1')

#Rename the asset with ID 1
asset1 = sc.asset_lists.edit(1,name='Renamed_Asset1')

#display the asset with the new name
print(asset1)

sc.logout()

我知道您可以使用这样的方法用下划线替换空格,但我不确定如何将函数作为输入传递给 Tenable 实例:

def replace_empty(name):
name.replace(" ","_")

返回的输出是字典格式,但是我认为这并不重要,因为我将更改单个值发送到资产的名称 key:value 对。

所使用的 Tenable 方法将在此链接中 - https://docs.tenable.com/tenablesc/api/Asset.htm

有人知道如何迭代更改所有资产吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)