Skip to content

Commit

Permalink
scripts: sbom: Fix derivation of package name from URL
Browse files Browse the repository at this point in the history
Fix the string operations so that the following URL types are supported:

- git@github.com:<user>/<repo>
- ssh://git@github.com/<user>/<repo>
- https://github.com/<user>/<repo>

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
  • Loading branch information
carlescufi committed Oct 4, 2023
1 parent 3003f42 commit da74901
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/west_commands/sbom/output_pre_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ def lic_reorder(id: str):
for package in data.packages.values():
if (package.url is None) or (package.version is None):
continue
if (package.name is None) and (package.url.startswith('https://github.com/')):
package.name = package.url.replace('https://github.com/', '')
if (package.name is None) and ('github.com' in package.url):
offs = package.url.find('github.com') + len('github.com') + 1
package.name = package.url[offs:]
if package.name.endswith('.git'):
package.name = package.name[:-4]
if package.name in package_name_map:
Expand Down

0 comments on commit da74901

Please sign in to comment.