Closed danielnbalasoiu closed 2 years ago
Something odd is returning in from: _/service/rest/v1/components?repository=
root@4960da47faaa:~# DEBUG=1 ws_nexus_integration param.config
DEBUG 22-01-18 07:40:29 281473656692752 root: Using configuration file: 'param.config'
DEBUG 22-01-18 07:40:29 281473656692752 root: Converting user and password to basic string
DEBUG 22-01-18 07:40:29 281473656692752 ws_sdk.ws_utilities: Executing command: ['java', '-version']
DEBUG 22-01-18 07:40:29 281473656692752 ws_sdk.ws_utilities: Java version: '11.0.13'
DEBUG 22-01-18 07:40:29 281473656692752 ws_sdk.ws_utilities: Executing command: ['java', '-Djava.io.tmpdir=/tmp/ws-nexus-integration', '-jar', '/tmp/ws-nexus-integration/wss-unified-agent.jar', '-v', '-noConfig', 'True']
DEBUG 22-01-18 07:40:31 281473656692752 ws_sdk.client: UA executed successfully. Return Code 0. Message: 21.12.2
DEBUG 22-01-18 07:40:31 281473656692752 ws_sdk.client: Local WhiteSource Unified Agent version 21.12.2
DEBUG 22-01-18 07:40:31 281473656692752 ws_sdk.ws_utilities: Calling url: https://api.github.com/repos/whitesource/unified-agent-distribution/releases/latest
DEBUG 22-01-18 07:40:31 281473656692752 ws_sdk.ws_utilities: Latest Unified Agent version: v21.12.2
DEBUG 22-01-18 07:40:31 281473656692752 ws_sdk.client: Skipping WhiteSource Unified Agent update
DEBUG 22-01-18 07:40:31 281473656692752 root: Sending request for retrieving Nexus repository list
DEBUG 22-01-18 07:40:31 281473656692752 root: Calling Nexus URL: http://nexus.host:8080/service/rest/v1/repositories
INFO 22-01-18 07:40:31 281473656692752 root: Nexus Version: Nexus/3.37.3-02 (OSS)
INFO 22-01-18 07:40:31 281473656692752 root: Validate specified repositories
INFO 22-01-18 07:40:31 281473656692752 root: Getting region parameters has finished
DEBUG 22-01-18 07:40:31 281473656692752 root: Using repository: /service/rest/v1/repositorySettings
INFO 22-01-18 07:40:31 281473656692752 root: Repository: docker-internal
INFO 22-01-18 07:40:31 281473656692752 root: Validate artifact list
DEBUG 22-01-18 07:40:31 281473656692752 root: Calling Nexus URL: http://nexus.host:8080/service/rest/v1/components?repository=docker-internal
DEBUG 22-01-18 07:40:32 281473656692752 root: Calling Nexus URL: http://nexus.host:8080/service/rest/v1/components?repository=docker-internal&continuationToken=REDACTED
DEBUG 22-01-18 07:40:32 281473656692752 root: Calling Nexus URL: http://nexus.host:8080/service/rest/v1/components?repository=docker-internal&continuationToken=REDACTED
Traceback (most recent call last):
File "/usr/local/bin/ws_nexus_integration", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.8/site-packages/ws_nexus_integration/nexus_integration.py", line 461, in main
download_components_from_repositories(selected_repositories)
File "/usr/local/lib/python3.8/site-packages/ws_nexus_integration/nexus_integration.py", line 221, in download_components_from_repositories
for item in cur_comp_response['items']:
TypeError: byte indices must be integers or slices, not str
I think that there is a discrepancy between the actual repositories and the ones configured to be scanned (in params.conf: NexusRepositories=).
I improved the mechanism a bit with additional prints.
Can you test pre release 0.2.10a1 (pip install ws-nexus-integration==0.2.10a1
) and upload the output (DEBUG=1)?
Thanks
params.config
:
root@4960da47faaa:~# grep NexusRepositories param.config
NexusRepositories=docker-internal
Note: Some Nexus repositories were removed but the relevant one (docker-internal
) was kept and a few more for the sake of debugging.
root@4960da47faaa:~# DEBUG=1 ws_nexus_integration param.config
DEBUG 22-01-18 11:15:11 281472821805072 root: Using configuration file: 'param.config'
DEBUG 22-01-18 11:15:11 281472821805072 root: Converting user and password to basic string
DEBUG 22-01-18 11:15:11 281472821805072 ws_sdk.ws_utilities: Executing command: ['java', '-version']
DEBUG 22-01-18 11:15:11 281472821805072 ws_sdk.ws_utilities: Java version: '11.0.13'
DEBUG 22-01-18 11:15:11 281472821805072 ws_sdk.ws_utilities: Executing command: ['java', '-Djava.io.tmpdir=/tmp/ws-nexus-integration', '-jar', '/tmp/ws-nexus-integration/wss-unified-agent.jar', '-v', '-noConfig', 'True']
DEBUG 22-01-18 11:15:12 281472821805072 ws_sdk.client: UA executed successfully. Return Code 0. Message: 21.12.2
DEBUG 22-01-18 11:15:12 281472821805072 ws_sdk.client: Local WhiteSource Unified Agent version 21.12.2
DEBUG 22-01-18 11:15:12 281472821805072 ws_sdk.ws_utilities: Calling url: https://api.github.com/repos/whitesource/unified-agent-distribution/releases/latest
DEBUG 22-01-18 11:15:12 281472821805072 ws_sdk.ws_utilities: Latest Unified Agent version: v21.12.2
DEBUG 22-01-18 11:15:12 281472821805072 ws_sdk.client: Skipping WhiteSource Unified Agent update
DEBUG 22-01-18 11:15:12 281472821805072 root: Sending request for retrieving Nexus repository list
DEBUG 22-01-18 11:15:12 281472821805072 root: Calling Nexus URL: http://nexus.host:8080/service/rest/v1/repositories
INFO 22-01-18 11:15:13 281472821805072 root: Nexus Version: Nexus/3.37.3-02 (OSS)
DEBUG 22-01-18 11:15:13 281472821805072 root: The following repositories were found: ['docker-internal', 'maven-central', 'npm-registry']
DEBUG 22-01-18 11:15:13 281472821805072 root: Repository: 'docker-internal' was added to scan
DEBUG 22-01-18 11:15:13 281472821805072 root: Using repository: /service/rest/v1/repositorySettings
INFO 22-01-18 11:15:13 281472821805072 root: Repository: docker-internal
INFO 22-01-18 11:15:13 281472821805072 root: Validate artifact list
DEBUG 22-01-18 11:15:13 281472821805072 root: Calling Nexus URL: http://nexus.host:8080/service/rest/v1/components?repository=docker-internal
DEBUG 22-01-18 11:15:14 281472821805072 root: Calling Nexus URL: http://nexus.host:8080/service/rest/v1/components?repository=docker-internal&continuationToken=REDACTED
DEBUG 22-01-18 11:15:14 281472821805072 root: Calling Nexus URL: http://nexus.host:8080/service/rest/v1/components?repository=docker-internal&continuationToken=REDACTED
Traceback (most recent call last):
File "/usr/local/bin/ws_nexus_integration", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.8/site-packages/ws_nexus_integration/nexus_integration.py", line 447, in main
download_components_from_repositories(selected_repositories)
File "/usr/local/lib/python3.8/site-packages/ws_nexus_integration/nexus_integration.py", line 221, in download_components_from_repositories
for item in cur_comp_response['items']:
TypeError: byte indices must be integers or slices, not str
OK I think it might be due to the continuationToken (the end URL is empty). The code now will bypass that.
Can you test please test ws-nexus-integration==0.2.10a2
?
The continuationToken
was not empty. It had a string which I replaced with REDACTED
.
root@4960da47faaa:~# DEBUG=1 ws_nexus_integration param.config
DEBUG 22-01-18 14:35:10 281473747169296 root: Using configuration file: 'param.config'
DEBUG 22-01-18 14:35:10 281473747169296 root: Converting user and password to basic string
DEBUG 22-01-18 14:35:10 281473747169296 ws_sdk.ws_utilities: Executing command: ['java', '-version']
DEBUG 22-01-18 14:35:10 281473747169296 ws_sdk.ws_utilities: Java version: '11.0.13'
DEBUG 22-01-18 14:35:10 281473747169296 ws_sdk.ws_utilities: Executing command: ['java', '-Djava.io.tmpdir=/tmp/ws-nexus-integration', '-jar', '/tmp/ws-nexus-integration/wss-unified-agent.jar', '-v', '-noConfig', 'True']
DEBUG 22-01-18 14:35:11 281473747169296 ws_sdk.client: UA executed successfully. Return Code 0. Message: 21.12.2
DEBUG 22-01-18 14:35:11 281473747169296 ws_sdk.client: Local WhiteSource Unified Agent version 21.12.2
DEBUG 22-01-18 14:35:11 281473747169296 ws_sdk.ws_utilities: Calling url: https://api.github.com/repos/whitesource/unified-agent-distribution/releases/latest
DEBUG 22-01-18 14:35:12 281473747169296 ws_sdk.ws_utilities: Latest Unified Agent version: v21.12.2
DEBUG 22-01-18 14:35:12 281473747169296 ws_sdk.client: Skipping WhiteSource Unified Agent update
DEBUG 22-01-18 14:35:12 281473747169296 root: Sending request for retrieving Nexus repository list
DEBUG 22-01-18 14:35:12 281473747169296 root: Calling Nexus URL: http://nexus.host:8080/service/rest/v1/repositories
INFO 22-01-18 14:35:12 281473747169296 root: Nexus Version: Nexus/3.37.3-02 (OSS)
DEBUG 22-01-18 14:35:12 281473747169296 root: The following repositories were found: ['docker-internal', 'maven-central', 'npm-registry']
DEBUG 22-01-18 14:35:12 281473747169296 root: Repository: 'docker-internal' was added to scan
DEBUG 22-01-18 14:35:12 281473747169296 root: Using repository: /service/rest/v1/repositorySettings
INFO 22-01-18 14:35:12 281473747169296 root: Repository: docker-internal
INFO 22-01-18 14:35:12 281473747169296 root: Validate artifact list
DEBUG 22-01-18 14:35:12 281473747169296 root: Calling Nexus URL: http://nexus.host:8080/service/rest/v1/components?repository=docker-internal
DEBUG 22-01-18 14:35:13 281473747169296 root: Calling Nexus URL: http://nexus.host:8080/service/rest/v1/components?repository=docker-internal&continuationToken=4b37REDACTED
DEBUG 22-01-18 14:35:13 281473747169296 root: Calling Nexus URL: http://nexus.host:8080/service/rest/v1/components?repository=docker-internal&continuationToken=4b37REDACTED
Traceback (most recent call last):
File "/usr/local/bin/ws_nexus_integration", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.8/site-packages/ws_nexus_integration/nexus_integration.py", line 451, in main
download_components_from_repositories(selected_repositories)
File "/usr/local/lib/python3.8/site-packages/ws_nexus_integration/nexus_integration.py", line 221, in download_components_from_repositories
for item in cur_comp_response.get('items'):
AttributeError: 'bytes' object has no attribute 'get'
root@4960da47faaa:~# pip show ws_nexus_integration
Name: ws-nexus-integration
Version: 0.2.10a2
Summary: WS Nexus Integration
Home-page: https://github.com/whitesource-ps/ws-nexus-integration
Author: WhiteSource Professional Services
Author-email: ps@whitesourcesoftware.com
License: LICENSE
Location: /usr/local/lib/python3.8/site-packages
Requires: requests, wget, ws-sdk
Required-by:
Hi,
I checked version 0.2.10
:
Traceback (most recent call last):
File "/usr/bin/ws_nexus_integration", line 8, in <module>
sys.exit(main())
File "/usr/lib/python3.9/site-packages/ws_nexus_integration/nexus_integration.py", line 451, in main
download_components_from_repositories(selected_repositories)
File "/usr/lib/python3.9/site-packages/ws_nexus_integration/nexus_integration.py", line 221, in download_components_from_repositories
for item in cur_comp_response.get('items'):
AttributeError: 'bytes' object has no attribute 'get'
and v0.2.11
which fails from the start
/opt/whitesource # DEBUG=1 ws_nexus_integration
DEBUG 22-01-25 08:39:11 281473604283464 root: Using configuration file: 'params.config'
DEBUG 22-01-25 08:39:11 281473604283464 root: Converting user and password to basic string
Traceback (most recent call last):
File "/usr/bin/ws_nexus_integration", line 8, in <module>
sys.exit(main())
File "/usr/lib/python3.9/site-packages/ws_nexus_integration/nexus_integration.py", line 450, in main
config = Configuration()
File "/usr/lib/python3.9/site-packages/ws_nexus_integration/nexus_integration.py", line 146, in __init__
self.ws_conn = WS(user_key=conf['WhiteSource Settings']['WSUserKey'],
File "/usr/lib/python3.9/site-packages/ws_sdk/web.py", line 12, in __init__
self.ws_app = WSApp.__init__(self, **kwargs)
File "/usr/lib/python3.9/site-packages/ws_sdk/app.py", line 120, in __init__
raise WsSdkTokenError(self.user_key)
ws_sdk.ws_errors.WsSdkTokenError: Invalid token: ''
Seems that the token is missing (in 'params.conf' under ['WhiteSource Settings'] -> 'WSUserKey').
Indeed, sorry about that. I missed that config parameter.
I'm having the same error with the latest version:
/opt/whitesource # pip list | grep ws
ws-nexus-integration 0.2.11
ws-sdk 0.9a3
Traceback (most recent call last):
File "/usr/bin/ws_nexus_integration", line 8, in <module>
sys.exit(main())
File "/usr/lib/python3.9/site-packages/ws_nexus_integration/nexus_integration.py", line 453, in main
download_components_from_repositories(selected_repositories)
File "/usr/lib/python3.9/site-packages/ws_nexus_integration/nexus_integration.py", line 221, in download_components_from_repositories
for item in cur_comp_response.get('items'):
AttributeError: 'bytes' object has no attribute 'get'
Thanks.
I create 0.2.12a1. Can you please test? And upload the debug output, if it fails
/opt/whitesource # pip list | grep ws
ws-nexus-integration 0.2.12a1
ws-sdk 0.9.0.2
OK so something returns from the call :) Can you test 0.2.12a2 and upload the debug again? Thanks
/opt/whitesource # pip list | grep ws
ws-nexus-integration 0.2.12a2
ws-sdk 0.9.0.2
Thanks for the update. It seems that the continuationToken (4b378653591c67227180318a3f096283) is not replaced between calls. So the 1st and 2nd calls are mapped with the same token which generate the same URL.
AFAIK the max number of artifacts in a call is 50.
I would like to replicate similar env before providing a fix for this.
There are a loooot of docker images in this repository (> 10k).
I'll check with another one which has fewer images and get back to you.
Thanks. I'll make sure the code can handle the continuationToken.
I just created v0.2.12a3. In this release I refactored the continuationToken mechanism. There was also a bug that caused it to endlessly call the same token.
Can you please re-test and send me the logs? Thanks
Yes. I'll test the new version (v0.2.12a3
).
I was about to paste the output from the other run but nothing changed.
/opt/whitesource # pip list | grep ws
ws-nexus-integration 0.2.12a3
ws-sdk 0.9.1a1
/opt/whitesource # DEBUG=1 ws_nexus_integration
DEBUG 22-01-31 15:53:00 281473411271752 root: Using configuration file: 'params.config'
DEBUG 22-01-31 15:53:00 281473411271752 root: Converting user and password to basic string
DEBUG 22-01-31 15:53:00 281473411271752 ws_sdk.ws_utilities: Executing command: ['java', '-version']
DEBUG 22-01-31 15:53:00 281473411271752 ws_sdk.ws_utilities: Java version: '1.8.0_302'
DEBUG 22-01-31 15:53:00 281473411271752 ws_sdk.ws_utilities: Executing command: ['java', '-Djava.io.tmpdir=/tmp/ws-nexus-integration', '-jar', '/tmp/ws-nexus-integration/wss-unified-agent.jar', '-v', '-noConfig', 'True']
DEBUG 22-01-31 15:53:01 281473411271752 ws_sdk.client: UA executed successfully. Return Code 0. Message: 22.1.1.1
DEBUG 22-01-31 15:53:01 281473411271752 ws_sdk.client: Local WhiteSource Unified Agent version 22.1.1.1
DEBUG 22-01-31 15:53:01 281473411271752 ws_sdk.ws_utilities: Calling url: https://api.github.com/repos/whitesource/unified-agent-distribution/releases/latest
DEBUG 22-01-31 15:53:04 281473411271752 ws_sdk.ws_utilities: Latest Unified Agent version: v22.1.1.1
DEBUG 22-01-31 15:53:04 281473411271752 ws_sdk.client: Skipping WhiteSource Unified Agent update
DEBUG 22-01-31 15:53:04 281473411271752 root: Sending request for retrieving Nexus repository list
DEBUG 22-01-31 15:53:04 281473411271752 root: Calling Nexus URL: http://nexus.host:8080/service/rest/v1/repositories
DEBUG 22-01-31 15:53:05 281473411271752 root: Response return type: <class 'list'>
INFO 22-01-31 15:53:05 281473411271752 root: Nexus Version: Nexus/3.37.3-02 (OSS)
DEBUG 22-01-31 15:53:05 281473411271752 root: The following repositories were found: ['ax-docker']
DEBUG 22-01-31 15:53:05 281473411271752 root: Repository: 'ax-docker' was added to scan
DEBUG 22-01-31 15:53:05 281473411271752 root: Using repository: /service/rest/v1/repositorySettings
INFO 22-01-31 15:53:05 281473411271752 root: Handling repository: ax-docker
DEBUG 22-01-31 15:53:05 281473411271752 root: Calling Nexus URL: http://nexus.host:8080/service/rest/v1/components?repository=ax-docker
DEBUG 22-01-31 15:55:56 281473411271752 root: Response is not JSON
DEBUG 22-01-31 15:55:56 281473411271752 root: Response return type: <class 'bytes'>
Traceback (most recent call last):
File "/usr/bin/ws_nexus_integration", line 8, in <module>
sys.exit(main())
File "/usr/lib/python3.9/site-packages/ws_nexus_integration/nexus_integration.py", line 469, in main
download_components_from_repositories(selected_repositories)
File "/usr/lib/python3.9/site-packages/ws_nexus_integration/nexus_integration.py", line 230, in download_components_from_repositories
all_repo_items = get_items_from_repo(repo_name)
File "/usr/lib/python3.9/site-packages/ws_nexus_integration/nexus_integration.py", line 219, in get_items_from_repo
continuation_token = cur_comp_resp['continuationToken']
TypeError: byte indices must be integers or slices, not str
Still unsure why it happens in the Nexus you are scanning (doesn't happen here). According to Sonatype this shouldn't happen
Can you please try 0.2.12a4? It will not process binary responses. Also did you install manually install pre-release 0.9.1a1? This version contains new caching feature but still has some bugs and missing behaviour). IMO Better stick with 0.9.0.3 for now.
ws-sdk 0.9.1a1
installs automatically as a dependency for either 0.2.12a3
or 0.2.12.a4
:
And I get an error when I install the stable version of the SDK:
I have tested 0.2.12a4
:
Got it. The last log looks better. The failure now looks like incorrect org token/ user key or permissions.
Can you double check that the user key is at least "Product Integrator" on the designated product ('Nexus'), permission of org administrator is also fine. and the org token is correct?
- I've been using this key for other type of scans and it's working fine. I can see the scan reports in WhiteSource Dashboard.
Also it doesn't find any Images 'axiros-docker' (log: Found 0 items in repository: 'axiros-docker'). Is this the actual case?
- No, there are a lot of container images in there.
Can you provide more information on your Nexus setup? How did you install it? Where it is deployed?
- The Nexus server was installed by a colleague in a VM using the Nexus Repository tar.gz file provided by sonatype.
I created a new docker registry just for testing ws-nexus (and avoid waiting to check hundreds of container images) it's working:
ws-nexus-integration 0.2.12a4
ws-sdk 0.9.0.3
[INFO] [2022-02-14 10:14:16,125 +0000] - Project name: IRRELEVANT, URL: https://saas-eu.whitesourcesoftware.com/Wss/WSS.html#!project;id=1195087
[INFO] [2022-02-14 10:14:16,125 +0000] - Support Token: 3b500228c6aa84a71a4f3ce76a16815171644833654373
[INFO] [2022-02-14 10:14:16,130 +0000] -
------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------- WhiteSource Scan Summary: --------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------
======================================================================================================================================================
Scan Origin: Local File System
======================================================================================================================================================
Step Completion Status Elapsed Comments
======================================================================================================================================================
Fetch Configuration COMPLETED 00:00:00.107 --------
Scan Files Matching Includes Pattern COMPLETED 00:00:00.013 0 source/binary files
Update Inventory COMPLETED 00:00:02.605 1 updated projects
======================================================================================================================================================
Elapsed running time: 00:00:02.725
======================================================================================================================================================
Process finished with exit code SUCCESS (0)
DEBUG 22-02-14 10:14:16 281473675177032 ws_sdk.app: Calling: https://saas-eu.whitesourcesoftware.com/api/v1.3 with requestType: getRequestState
DEBUG 22-02-14 10:14:16 281473675177032 ws_sdk.app: API getRequestState call on orgToken 20a**** succeeded
@danielnbalasoiu Thank you for the update!
Bug Description
Running
ws_nexus_integration param.config
w/ the followingparams.config
config:fails w/
Steps to Reproduce
Steps to reproduce the behavior:
pip install ws-nexus-integration[DOCKER]
params.config
file as shown above.ws_nexus_integration param.config
Environment Details
python:3.8-slim-buster