From 7c84e600cbdd21267eb0b5ca63b8d4ea374c29fd Mon Sep 17 00:00:00 2001 From: Scott Dickerson Date: Tue, 25 Jun 2024 18:35:38 -0400 Subject: [PATCH] :bug: Link java dependencies that don't have a sha (#1983) Resolves: #1982 In some analysis cases, java dependencies may be generated with the full `name` (group id + artifact id) and `version` but lack a `sha` value. When this occurs, a maven central search string can still be created. Now, for any java dependency, link to maven central: - Use the dependency's `sha`, or - Use the `name` and `version` Signed-off-by: Scott J Dickerson --- .../dependencies/dependency-apps-table.tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/client/src/app/pages/dependencies/dependency-apps-table.tsx b/client/src/app/pages/dependencies/dependency-apps-table.tsx index e5a1f46c7..0fca60754 100644 --- a/client/src/app/pages/dependencies/dependency-apps-table.tsx +++ b/client/src/app/pages/dependencies/dependency-apps-table.tsx @@ -285,11 +285,21 @@ const DependencyVersionColumn = ({ }: { appDependency: AnalysisAppDependency; }) => { - const isJavaDependency = name && version && sha && provider === "java"; + let mavenCentralLink; - const mavenCentralLink = isJavaDependency - ? `https://search.maven.org/search?q=1:${extractFirstSha(sha)}` - : undefined; + if (name && version && provider === "java") { + if (sha) { + mavenCentralLink = `https://search.maven.org/#search|1:${extractFirstSha( + sha + )}`; + } else { + const group = name.substring(0, name.lastIndexOf(".")); + const artifact = name.substring(name.lastIndexOf(".") + 1); + mavenCentralLink = encodeURI( + `https://search.maven.org/#search|g:${group} a:${artifact} v:${version}` + ); + } + } return (