Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -22,6 +22,7 @@
import org.apache.commons.io.FileUtils;
import org.commonjava.util.sidecar.services.ArchiveRetrieveService;
import org.commonjava.util.sidecar.services.ProxyService;
import org.commonjava.util.sidecar.services.ReportService;
import org.commonjava.util.sidecar.util.TransferStreamingOutput;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
Expand Down Expand Up @@ -65,6 +66,9 @@ public class FoloContentAccessResource
@Inject
ArchiveRetrieveService archiveService;

@Inject
ReportService reportService;

@Operation( description = "Retrieve Maven/NPM artifact content from historical archive or proxy" )
@APIResponse( responseCode = "200", description = "Content stream" )
@APIResponse( responseCode = "404", description = "Content is not available" )
Expand All @@ -86,7 +90,7 @@ public Uni<Response> get( @Parameter( in = PATH, required = true ) @PathParam( "
}

Optional<File> download = archiveService.getLocally( path );
if ( download.isPresent() && download.get().isFile() )
if ( download.isPresent() && download.get().isFile() && reportService.checkValidHistoricalEntryMeta( path ) )
{
Uni<Boolean> checksumValidation =
proxyService.validateChecksum( id, packageType, type, name, path, request );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,7 @@ public void storeTrackedDownload( JsonObject message )
logger.debug( "Consuming folo record seal event for path:{}, trackingId:{}", trackingPath, trackingId );

HistoricalEntryDTO entryDTO = historicalContentMap.get( trackingPath );
if ( null == entryDTO )
{
logger.warn( "No historical entry meta is found for tracking {}.", trackingPath );
return;
}
StoreKey storeKey = entryDTO.getStoreKey();
if ( null == storeKey )
{
logger.warn( "No StoreKey is found for tracking {} historical entry.", trackingPath );
return;
}
String originalUrl = entryDTO.getOriginUrl() == null ? "" : entryDTO.getOriginUrl();
boolean exception = false;
try
Expand Down Expand Up @@ -151,4 +141,21 @@ public HashMap<String, HistoricalEntryDTO> getHistoricalContentMap()
{
return historicalContentMap;
}

public boolean checkValidHistoricalEntryMeta( String trackingPath )
{
HistoricalEntryDTO entryDTO = historicalContentMap.get( trackingPath );
if ( entryDTO == null )
{
logger.warn( "Check no matched historical entry meta is found for tracking path: {}.", trackingPath );
return false;
}
StoreKey storeKey = entryDTO.getStoreKey();
if ( storeKey == null )
{
logger.warn( "Check no valid historical StoreKey is found for tracking path: {}.", trackingPath );
return false;
}
return true;
}
}