snyk api的交互式shell接口
snyksh的Python项目详细描述
SNYK外壳
snyk shell为snyk api提供了一个方便的shell接口。你可以 使用任何有效的python表达式,并使用 预先配置的snyk api客户端。当你装上外壳的时候 预先加载组织和项目的列表,以便您有一些数据可供探索。
安装
snyk shell可从pypi获得。使用首选的python依赖项管理工具安装:
pip install snyksh
snyk shell也可用作docker映像。
docker pull garethr/snyksh
配置
为了访问snyk api,您需要提供api令牌。这是用
名为SNYK_TOKEN
:
export SNYK_TOKEN=<your-token-goes-here>
snyksh
docker run --rm -it -e SNYK_TOKEN=<your-token> garethr/snyksh
用法
运行snyk shell可以与snyk中的数据交互。这包括您的项目 以及更一般的漏洞数据。
这里有几个例子。
Welcome to Snyk Shell The following objects and methods are currently available: client - An instance of the Snyk client, which can be used to make requests to the API organizations - A prepopulated list of the Snyk organizations you are a member of projects - A prepopulated list of all of your Snyk projects pprint() - A pretty printer for objects returns by the API In [1]: organizations Out[1]: [Organization(name='garethr', id='<not-the-read-organization-id>', group=None)] In [2]: pprint(organizations) [ snyk.models.Organization( name='garethr', id='<not-the-real-organization-id>' ) ] In [3]: results = client.organizations.first().test_python("django", "2.0.0") In [4]: len(results.issues.vulnerabilities) Out[4]: 6 In [5]: [x.identifiers["CVE"][0] for x in results.issues.vulnerabilities] Out[5]: ['CVE-2019-6975', 'CVE-2018-7536', 'CVE-2018-7537', 'CVE-2018-6188', 'CVE-2018-14574', 'CVE-2019-3498']
snyk api客户端
snyk shell使用snyk python api客户端pysnyk
。如果您想构建自己的应用程序
它们与snyk api交互,或者您想知道所有可用的属性和方法
对于您,请参阅客户机文档和示例。