---
# System prepended metadata

title: sonatype指令

---


使用ID = ui 設置時所建立的ID 
使用id = 使用指令get出來的id

查詢Org

```
GET /api/v2/organizations?organizationName={YourOrganizationName}

curl -u Developer:Developer  -X GET http://192.168.56.101:8070/api/v2/organizations?organizationName=ROOT%20ORGANIZATION

```
有id之後就可以使用Linux查詢
```
curl -u admin:admin123 -X GET http://localhost:8070/api/v2/organizations/{orgID}
```
使用orgID 查詢appcation ID
```
curl -u ${user}:${password} ${iq_url}/api/v2/applications/organization/${org_id}

curl -u admin:admin123 http://localhost:8070/api/v2/applications/organization/8162c39152974035b8d66df12f5abe7d
```

查詢你的Application ID
```
http://192.168.56.101:8070/api/v2/applications?publicId=sam.ch

http://(iqserver url)/api/v2/applications?publicId=(預查詢application_ID)

curl -u Developer:Developer -X GET http://192.168.56.101:8070/api/v2/applications?publicId=Test_bom
```

查詢該Application歷史紀錄
```
http://192.168.56.101:8070/api/v2/reports/applications/6f3c1a57c4a847df9db017326b1ed2b2/history

curl -u admin:admin123 -X GET 'http://localhost:8070/api/v2/reports/applications/4537e6fe68c24dd5ac83efd97d4fc2f4/history'

http://(iq server url)/api/v2/reports/applications/(application_id)/history
```
iq_cli 掃描
-t 可使用build(預設) stage-release release -O 選擇切換Organization
```
java -jar nexus-iq-cli-1.174.0-01.jar -a admin:admin123 -t stage release -i intellij-samples-main -s http://localhost:8070 Scan/intellij-samples-main/



java -jar (iqCli) -a (iqUser:iqpassword) -i (applications_ID) -t (stage) -s (iq_server_url) (project_path) 
```

iq_cli 下載檔案
pdf
```
http://192.168.56.101:8070/rest/report/lifecycle/0900ab098c6d478a9b61891d3827dc40/printReport

http://(iq_url)/rest/report/(applications_ID)/(Scan_id)/printReport
```


(cycloneDx) xml/json
```
"application/xml"

XML

1.1, 1.2, 1.3, 1.4, 1.5

"application/json"

JSON

1.2, 1.3, 1.4, 1.5



http://192.168.56.101:8070/api/v2/cycloneDx/1.5/cb2eb9da0d554e18b4b5d5c70d291f2e/reports/140530c2c6e9489e9fe3dd57f50c3576


http://(iq_url)/api/v2/cycloneDx/${version}/${app_id}/reports/${scan_id}

```

xml from Linux download
```
sudo curl -u admin:admin123 -o /home/sam/Testpdf/output.xml http://192.168.56.101:8070/api/v2/cycloneDx/1.5/cb2eb9da0d554e18b4b5d5c70d291f2e/reports/140530c2c6e9489e9fe3dd57f50c3576

curl -u admin:admin123 -X GET
http://localhost:8070/api/v2/cycloneDx/1.5/b7b2b2cc9c864ea59eb7fa0fb1d7f9ff/reports/bfdb562fad2443e593357b67eb4095e7 -H 'Accept: application/json'


sudo curl -u (iqUser:iqPassword) -o (預下載檔案路徑/檔案名稱.xml)
http://(iqserver_Url)/api/v2/cycloneDx/1.5/(appliction_id)/reports/(Scan_id)

```

json
```
http://192.168.56.101:8070/api/v2/spdx/cb2eb9da0d554e18b4b5d5c70d291f2e/reports/140530c2c6e9489e9fe3dd57f50c3576

http://(iq_url)/api/v2/spdx/(app_id)/reports/(scan_id)

```

json from Linux download
```
sudo curl -u admin:admin123 -o (預下載檔案路徑/檔案名稱.json)http://(iqserver_id)/api/v2/spdx/(app_id)/reports/(scan_id)
```

如果一直下載失敗可以嘗試使用
```
curl -v 剛剛預下載的網址替換上即可

curl -v http://192.168.56.101:8070/api/v2/cycloneDx/cb2eb9da0d554e18b4b5d5c70d291f2e/reports/140530c2c6e9489e9fe3dd57f50c3576    
```

直接下載整包log
```
http://10.95.43.84:8070/rest/support?includeDb=true
```

查詢套件違反政策
```
curl -u admin:admin123 -X POST -H "Content-Type: application/json" -d '{"components":[{"hash": null,"componentIdentifier": {"format":"maven","coordinates": {"artifactId":"tomcat-util","extension":"jar","groupId":"tomcat","version":"5.5.23"}}}]}' 'http://192.168.1.110:8070/api/v2/components/details'

curl -u ${iqserver帳號}:${iqServer 密碼} -X POST -H "Content-Type: application/json" -d '{"components":[{"hash": null,"componentIdentifier": {"format":"maven","coordinates"{"artifactId":"${artifactId}","extension":"jar","groupId":"${套件群組ID}","version":"${套件版本號}"}}}]}' '${iq server url}/api/v2/components/details'

```

查詢該漏洞細節
```
curl -u admin:admin123 'http://localhost:8070/api/v2/vulnerabilities/CVE-2017-5929'

curl -u admin:admin123 '${iq server url}/api/v2/vulnerabilities/${漏洞編號}'

```

刪除lic 指令
```
curl -X 'DELETE' \
  'http://192.168/56.101/service/rest/v1/system/license' \
  -H 'accept: application/json' \
  -u admin:admin123


curl -X 'DELETE' \
  'http://{nexusHost}/service/rest/v1/system/license' \
  -H 'accept: application/json' \
  -u {username}:{password}
```