Skip to content

Commit

Permalink
Avoid potential cache collisions
Browse files Browse the repository at this point in the history
Use secure hash for determining path for local checkout.
  • Loading branch information
findepi authored and nineinchnick committed Feb 16, 2024
1 parent 0750a98 commit 679b268
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/pl/net/was/trino/git/GitRecordSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package pl.net.was.trino.git;

import com.google.common.collect.ImmutableList;
import com.google.common.hash.Hashing;
import io.trino.spi.connector.RecordCursor;
import io.trino.spi.connector.RecordSet;
import io.trino.spi.type.Type;
Expand All @@ -33,6 +34,7 @@
import java.util.Map;
import java.util.Optional;

import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Objects.requireNonNull;

public class GitRecordSet
Expand Down Expand Up @@ -155,6 +157,6 @@ public static File ensureDir(String prefix)
}
}

return new File(tmpDir, Integer.toHexString(prefix.hashCode()));
return new File(tmpDir, Hashing.sha256().hashString(prefix, UTF_8).toString());
}
}

0 comments on commit 679b268

Please sign in to comment.