Skip to content

Commit

Permalink
🐛 Link java dependencies that don't have a sha (#1983)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
sjd78 authored Jun 25, 2024
1 parent 153ae06 commit 7c84e60
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions client/src/app/pages/dependencies/dependency-apps-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<TextContent>
Expand Down

0 comments on commit 7c84e60

Please sign in to comment.