Open adubey8 opened 2 years ago
Hi @adubey8 ,
I would recommend using one of the following Whitesource's API calls :
Our Python sdk's get_scopes_from_name method
ws_conn = ws_sdk.web.WSApp(url='https://app.whitesourcesoftware.com',user_key='123456789',token='987654321')
project_token = ws_conn.get_scopes_from_name('project_name', token_type='project')
In addition, please notice that before running the "Generate WhiteSource SPDX Report" task , you will require to validate that the scan results were uploaded to the the Whitesource organization , otherwise , the sbom report might return empty ( mainly when the scan project has a lot of data and it takes time to be processed by Whitesource application ).
You can do so with the getRequestState API call +You will need to retrieve the support_token
for that.
Here is a python sample of such implementation :
def scan_with_unified_agent(dirs_to_scan):
unified_agent = ws_sdk.web.WSClient(user_key'123456789', token='987654321', url='https://app.whitesourcesoftware.com')
output = unified_agent.scan(scan_dir=dirs_to_scan,product_token=1a2b3c4d5f6g,project_token='d8ac08821aca430fa8b5e747aef32bdee0f559727ed94140a3a4d7943d68dbee')
support_token = output[2] # gets Support Token from scan output
scan_status = True
while scan_status:
new_status = ws_conn.get_last_scan_process_status(support_token)
logging.info(f"Scan data upload status :{new_status}")
if new_status in ['UPDATED', 'FINISHED']:
logging.info('scan upload completed')
scan_status = False
elif new_status in ['UNKNOWN', 'FAILED']:
logging.warning('scan failed to upload...exiting program')
sys.exit(1)
else:
time.sleep(10.0)
Hi @adubey8 , did my comment answer your question ?
Sorry to say, but this makes no sense because I did not find a way to generate on project level... I would suggest #136
Question
Can you provide a yaml example for running a
wss-unified-agent.jar
agent for scanning an artifact (published as a new project) and then run sbom generator to get all the dependencies. I am trying it as below, but I have below question when following this approach: How to obtain the project token from wss-unified-agent scan to be further used by another command task to run the ws_sbom_generator?Environment Details