WebSphere Automation "How To" Series #17 : How to retrieve fixes using APIs
Previous blogs in this WebSphere Automation "How To" series :
WebSphere Automation "How To" Series #1 : How to get WebSphere Automation UI URL
WebSphere Automation "How To" Series #2 : How to specify user roles and permissions
WebSphere Automation "How To" Series #3 : How to configure WebSphere Automation with an Enterprise LDAP
WebSphere Automation "How To" Series #4 : How to register WebSphere Application Server traditional servers using configuretWasUsageMetering.py script
WebSphere Automation "How To" Series #5 : How to register WebSphere Liberty servers
WebSphere Automation "How To" Series #6 : How to configure email server and email addresses for notifications
WebSphere Automation "How To" Series #7 : How to setup Instana to send alerts to WebSphere Automation
WebSphere Automation "How To" Series #8 : How to setup secure access to Linux or UNIX servers
WebSphere Automation "How To" Series #9 : How to trigger a memory leak health investigation when used heap is over 80 percent
WebSphere Automation "How To" Series #10 : How to view WebSphere Automation REST APIs using Swagger UI
WebSphere Automation "How To" Series #11 : How to get and delete assets using APIs
WebSphere Automation "How To" Series #12 : How to get security bulletins using APIs
WebSphere Automation "How To" Series #13 : How to retrieve a list of vulnerabilities using APIs
WebSphere Automation "How To" Series #14 : How to get CVE impact summaries using APIs
WebSphere Automation "How To" Series #15 : How to install interim fixes and fix packs using WebSphere Automation UI
WebSphere Automation "How To" Series #16 : How to retrieve and delete installations using APIs
This post will focus on how to retrieve fixes using APIs.
The WebSphere Automation REST APIs are technology preview in this release. IBM Docs directly related to WebSphere Automation REST API are located at https://www.ibm.com/docs/en/ws-automation?topic=technology-preview-viewing-rest-api.
To utilize WebSphere Automation REST APIs through CLI, we need the URL and token values. IBM Docs https://www.ibm.com/docs/en/ws-automation?topic=technology-preview-viewing-rest-api shows the following details on how to acquire the necessary token value for an authorized user profile.
Get the password for the administrator account.
oc -n WSA_INSTANCE_NAMESPACE get secret admin-user-details -o jsonpath='{.data.initial_admin_password}' | base64 -d && echo
WSA_INSTANCE_NAMESPACE is the namespace of the instance where WebSphere Automation is installed.
Replace <password> in the following command with the value returned from the command above, and use the correct value for WSA_INSTANCE_NAMESPACE.
curl -k -X POST -H 'Content-Type: application/json' -d '{"username":"admin","password":"<password>"}' https://$(oc get route -n WSA_INSTANCE_NAMESPACE -o jsonpath='{.items[?(@.spec.to.name=="ibm-nginx-svc")].spec.host}')/icp4d-api/v1/authorize | jq -r .token
To get the necessary URL value to use in the curl commands, we can append a prefix of 'https://' and a suffix of '/websphereauto/secvul/apis' around the result of the following command.
oc get route -n WSA_INSTANCE_NAMESPACE -o jsonpath='{.items[?(@.spec.to.name=="ibm-nginx-svc")].spec.host}'
To set a URL variable on Linux, we could use the following
URL=https://$(oc get route -n WSA_INSTANCE_NAMESPACE -o jsonpath='{.items[?(@.spec.to.name=="ibm-nginx-svc")].spec.host}')/websphereauto/secvul/apis
Now that we've captured the token and URL values, we can show how to utilize the WebSphere Automation REST APIs to retrieve fixes.
For this example, we've registered a WebSphere Application Server traditional v9.0.5.10 server and a WebSphere Liberty 21.0.0.12 server with several fixes applied as shown in the following screenshot.
The Swagger UI shows the following available Fixes operations.
Using CLI with the token value set in a variable TOKEN and url set in a variable URL, we can issue the following command to retrieve a list of all the fixes and use jq to pretty print the json output. The following is the command with a snippet showing the first fix returned.
[root@api.XXX.ibm.com Installations]# curl -k -X GET "${URL}/fixes?limit=100" -H "accept: application/json" -H "Authorization: Bearer $TOKEN" | jq .
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 60618 0 60618 0 0 1644k 0 --:--:-- --:--:-- --:--:-- 1691k
{
"offset": 0,
"limit": 100,
"total_count": 53,
"results": [
{
"id": "8316ccf1-1522-32ca-8cb4-339ad23792ac",
"name": "21.0.0.12-WS-WLPWithExtensions-IFPH42074",
"description": "IBM WebSphere Application Server Liberty is vulnerable to Information Disclosure (CVE-2022-22310 CVSS 4.8)",
"type": "interim-fix",
"productType": "liberty",
"appliesToVersions": [
"21.0.0.12"
],
"editions": [
"nd"
],
"status": "downloaded",
"apars": [
"PH42074"
],
"releaseDate": "2022-01-18T16:56:59Z",
"files": [
{
"fileName": "21.0.0.12-WS-WLPWithExtensions-IFPH42074-ReadMe.txt",
"fileSize": 2315,
"created": "2022-08-15T11:56:49Z",
"description": "Readme",
"hashCode": "l+uQqxpeJ5BUORj3yUW2sSZ6yLFzaCaghLqV7UznaVY=",
"hashAlgorithm": "SHA-256"
},
{
"fileName": "21.0.0.12-ws-wlpwithextensions-ifph42074.zip",
"fileSize": 1612945,
"created": "2022-08-15T11:56:49Z",
"description": "installable zip",
"hashCode": "LS8JWs4Gde2B7nh/ksCTL6KndKVuOciQC/x7z1DUkf0=",
"hashAlgorithm": "SHA-256"
},
{
"fileName": "21.0.0.12-WS-WLPWithExtensions-IFPH42074.sha",
"fileSize": 64,
"created": "2022-08-15T11:56:49Z",
"description": "sha256sum",
"hashCode": "oz8Yp8ReAZTjIdh484fh+yMFvnV6+14V8x8XI2BL63k=",
"hashAlgorithm": "SHA-256"
}
],
"created": "2022-08-10T20:24:01Z",
"createdBy": "fix-manager",
"updated": "2022-08-16T12:35:40Z",
"updatedBy": "fix-manager",
"platforms": [
"windows-64-bit-x86",
"ibmi",
"linux-64-bit-ia64",
"aix-64-bit-pSeries",
"linux-64-bit-x86-64",
"aix-32-bit-pseries",
"windows-64-bit-ia64",
"linux-ppc",
"aix",
"linux-ppc64le",
"mac-os-x",
"linux-pseries",
"linux-zSeries",
"linux-32-bit-x86",
"linux-64-bit-zseries",
"linux-z9-and-zseries",
"linux",
"windows",
"linux-64-bit-pseries",
"windows-32-bit-x86"
]
},
...
]
}
For this example, we can see that there were 53 fixes retrieved. Using the APIs, the maximum number of results returned is determined by the 'limit' parameter. The value must be an integer between 1 and 100. The default 'limit' parameter is 25.
You can find more IBM Docs related to WebSphere Automation at
https://www.ibm.com/docs/en/ws-automation.
#WebSphere#Automation#WebSphereAutomation