我可以使用HP的REST创建项目吗?这个方法可以很好地获取项目列表:
import requests
import getpass
import json
url = "https://www.example.com/ssc/api/v1/"
endpoint = "auth/obtain_token"
headers = {"Content-Type": "application/json",
"Accept": "application/json"}
username = getpass.getuser()
password = getpass.getpass()
auth = (username, password)
r = requests.post("{url}{endpoint}".format(url=url, endpoint=endpoint), headers=headers, auth=auth)
data = r.json().get("data")
token = data.get("token")
endpoint = "projects"
headers["Authentication"] = "FortifyToken {token}".format(token=token)
r = requests.get("{url}{endpoint}".format(url=url, endpoint=endpoint), headers=headers)
print json.dumps(r.json(), sort_keys=True, indent=4, separators=(',', ': '))..。但是我在API文档中没有看到任何实际创建项目的例子。我特别感兴趣的是使用Python请求库这样做。我做了,而不是想要在Java中做任何事情(这就是Fortify SSC包附带的所有示例)。
如果有人对SSC有任何经验(或者可以向我介绍一些更好的文档),我希望您能提供任何帮助。
发布于 2016-08-16 18:34:26
我终于从HPE技术支持中获得了一些很好的信息,并能够为使用Python中的script创建项目编写一个脚本。SSC (17.10)的最新版本使Swaggerized更加容易。
发布于 2017-12-28 00:42:41
感谢SonarQube增强插件的作者(不是Fortify SSC文档,也不是它的自动生成的ssc/html/docs/api-引用),我想我需要对令牌进行base64 64编码。
if len(auth) == 1:
headers.update((("Authorization", "FortifyToken " + base64.b64encode(auth[0])),))
elif len(auth) == 2:
headers.update((("Authorization", "Basic " + base64.b64encode("{}:{}".format(*auth))),))auth/token调用有助于避免重新发送用户名/密码对。Fortify SCA bin目录中的fortifyclient脚本可以预先执行调用。
https://stackoverflow.com/questions/36414245
复制相似问题