Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compare tarball string as well in the generation phase to prevent bad tarball url #2487

Merged
merged 5 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,18 @@ private boolean writePackageMetadata( List<StoreResource> firstLevelFiles, Artif
}

// Generate tarball url if missing
String tarball = "http://indy/" + packagePath.getTarPath(); // here we use mock host. indy will amend it with the right hostname
if ( versionMetadata.getDist() == null )
{
String tarball = "http://indy/" + packagePath.getTarPath(); // here we use mock host. indy will amend it with the right hostname
//logger.debug( "Generate dist tarball: {}", tarball );
versionMetadata.setDist( new Dist( tarball ) );
versionMetadata.setDist( new Dist( tarball ) );
} else {
if ( !versionMetadata.getDist().getTarball().endsWith(packagePath.getTarPath()) )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a potential NULL pointer exception if the getTarball() returning NULL.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought tarball can't be null if dist is not
fixed

{
versionMetadata.setDist( new Dist( tarball, versionMetadata.getDist().getShasum(), versionMetadata.getDist().getIntegrity(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better way to avoid repeating call of versionMetadata.getDist() ? And seems we just need to update tarball, how about adding setter in Dist ?

versionMetadata.getDist().getFileCount(), versionMetadata.getDist().getUnpackedSize(),
versionMetadata.getDist().getSignatures(), versionMetadata.getDist().getNpmSignature() ) );
}
}
}
catch ( IOException e )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ public Dist( final String tarball )
this.npmSignature = null;
}

public Dist( final String tarball, final String shasum, final String integrity, final Integer fileCount, final Long unpackedSize, final List<Map<String, String>> signatures, final String npmSignature )
{
this.tarball = tarball;
this.shasum = shasum;
this.integrity = integrity;
this.fileCount = fileCount;
this.unpackedSize = unpackedSize;
this.signatures = signatures;
this.npmSignature = npmSignature;
}

public String getShasum()
{
return shasum;
Expand Down
Loading