From 78731ceb485970f10a4b1a7156ce083fcb36f063 Mon Sep 17 00:00:00 2001 From: prabhu Date: Sun, 10 Dec 2023 20:00:24 +0000 Subject: [PATCH] Fixes #768. Retain full name of the jar if there are no versions (#769) * Fixes #768. Retain full name of the jar if there are no versions Signed-off-by: Prabhu Subramanian * Fixes #768. Retain full name of the jar if there are no versions Signed-off-by: Prabhu Subramanian --------- Signed-off-by: Prabhu Subramanian --- package-lock.json | 4 ++-- package.json | 2 +- utils.js | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index d16aa0fc7..2915d8b02 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@cyclonedx/cdxgen", - "version": "9.9.6", + "version": "9.9.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@cyclonedx/cdxgen", - "version": "9.9.6", + "version": "9.9.7", "license": "Apache-2.0", "dependencies": { "@babel/parser": "^7.23.5", diff --git a/package.json b/package.json index 66a38b4ce..f15d0c065 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cyclonedx/cdxgen", - "version": "9.9.6", + "version": "9.9.7", "description": "Creates CycloneDX Software Bill of Materials (SBOM) from source or container image", "homepage": "http://github.com/cyclonedx/cdxgen", "author": "Prabhu Subramanian ", diff --git a/utils.js b/utils.js index 0f863ff61..f3fd40b68 100644 --- a/utils.js +++ b/utils.js @@ -6827,17 +6827,17 @@ export const extractJarArchive = function ( if (!name || !version || name === "" || version === "") { confidence = 0.5; technique = "filename"; + name = jarname.replace(".jar", ""); const tmpA = jarname.split("-"); if (tmpA && tmpA.length > 1) { const lastPart = tmpA[tmpA.length - 1]; - if (!version || version === "") { - version = lastPart.replace(".jar", ""); - } - if (!name || name === "") { + // Bug #768. Check if we have any number before simplifying the name. + if (/\d/.test(lastPart)) { + if (!version || version === "") { + version = lastPart.replace(".jar", ""); + } name = jarname.replace("-" + lastPart, "") || ""; } - } else { - name = jarname.replace(".jar", ""); } } if (