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

Remove scalajs-fake-insecure-java-securerandom dependency #465

Merged
merged 2 commits into from
May 31, 2022
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
10 changes: 0 additions & 10 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,6 @@ lazy val runtime = CrossProject(
.jvmSettings(
Test / fork := true
)
.jsSettings(
scalaJSStage := FastOptStage,
// While not exactlu ideal, this is only used in the invoker to assign a
// unique id to ensure measurements have unique ids. It's never exposed to
// the user and doesn't touch anything sensitve, so we should have no
// issues here. Still, I don't like having this, so we should try to
// replace it.
libraryDependencies += ("org.scala-js" %%% "scalajs-fake-insecure-java-securerandom" % "1.0.0")
.cross(CrossVersion.for3Use2_13)
ckipp01 marked this conversation as resolved.
Show resolved Hide resolved
)

lazy val `runtimeJVM` = runtime.jvm
lazy val `runtimeJS` = runtime.js
Expand Down
11 changes: 11 additions & 0 deletions runtime/js/src/main/scala/scoverage/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,15 @@ object Platform {

lazy val Source = SupportSource

def insecureRandomUUID() = {
import scala.util.Random
var msb = Random.nextLong()
var lsb = Random.nextLong()
msb &= 0xffffffffffff0fffL // clear version
msb |= 0x0000000000004000L // set to version 4
lsb &= 0x3fffffffffffffffL // clear variant
lsb |= 0x8000000000000000L // set to IETF variant
new java.util.UUID(msb, lsb)
}

}
3 changes: 3 additions & 0 deletions runtime/jvm/src/main/scala/scoverage/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ object Platform {
type FileFilter = SupportFileFilter

lazy val Source = SupportSource

def insecureRandomUUID() = java.util.UUID.randomUUID()

}
2 changes: 1 addition & 1 deletion runtime/shared/src/main/scala/scoverage/Invoker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import scoverage.Platform._
/** @author Stephen Samuel */
object Invoker {

private val runtimeUUID = java.util.UUID.randomUUID()
private val runtimeUUID = Platform.insecureRandomUUID()

private val MeasurementsPrefix = "scoverage.measurements."
private val threadFiles = new ThreadLocal[mutable.HashMap[String, FileWriter]]
Expand Down