首页 > 解决方案 > Fortify API Start Scan with Default - 如何发送包裹

问题描述

我正在尝试使用来自https://api.emea.fortify.com/swagger/ui/index#/的 API, 名为 Start Scan with Default。

我找不到任何文件来建议如何设置帖子。

这是我到目前为止所拥有的,但我收到了一个错误,当然我也没有发送文件进行扫描,所以我知道这是不对的。

我尝试了一个 Get 请求,该请求有效,因此我知道它已通过身份验证等。

我只需要知道参数格式是否正确以及如何上传实际文件进行扫描。

POST /api/v3/releases/43579/static-scans/start-scan-with-defaults?releaseId=43579& fragNo=22& offset=22& isRemediationScan=false& notes=hello HTTP/1.1
Host: api.emea.fortify.com
Content-Type: application/json
Authorization: Bearer [TOKEN HERE]
User-Agent: PostmanRuntime/7.13.0
Accept: */*
Cache-Control: no-cache
Postman-Token: 57e40c1d-c99c-40a4-a79b-06ef9a678a07,8ef4ad1e-327f-4eee-b6bb-bddb21b18d50
Host: api.emea.fortify.com
accept-encoding: gzip, deflate
content-length: 
Connection: keep-alive
cache-control: no-cache

回复:

{
    "errors": [
        {
            "errorCode": null,
            "message": "Unexpected error processing request"
        }
    ]
}

更新

我在用 Java 编写的 Git 上找到了这个 repo,我试图在 PowerShell 中重新创建它,但没有成功。

https://github.com/fod-dev/fod-uploader-java

My PowerShell:

[System.Net.WebRequest]::DefaultWebProxy = [System.Net.WebRequest]::GetSystemWebProxy()
[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials

$zipDetails = Get-Content C:\Users\patemanc\Desktop\types.zip -Encoding Byte

Write-Host $zipDetails.Length

$releaseId = "43576"

$url = "https://api.emea.fortify.com/api/v3/releases/$releaseId/static-scans/start-scan-with-defaults?"
$url += "releaseId=$releaseId"
$url += "&fragNo=-1"
$url += "&offset=0"
$url += "&isRemediationScan=false"
$url += "&notes=PowrShell Test"


$long_lived_access_token = "ENTER TOKEN HERE"
$headers = @{Authorization = "bearer:$long_lived_access_token"}

$response = Invoke-WebRequest -ContentType "application/octet-stream"  -Uri $url -Method POST -Body $zipDetails -Headers $headers -UseBasicParsing


Write-Host "Here is the end"

Write-Host $response

错误响应:

79212
Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
At line:22 char:13
+ $response = Invoke-WebRequest -ContentType "application/json"  -Uri $ ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

标签: apifortify

解决方案


为什么是邮递员?如果您使用一些插件来运行它,例如来自 Jenkins,它可以正常工作。我不知道插件如何从 API 调用它。


推荐阅读