Skip to content

Commit

Permalink
Ha, this already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
aednichols committed Jan 18, 2024
1 parent 77ca754 commit d72f7cf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion common/src/main/scala/common/util/UriUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ object UriUtil {
private val SensitiveKeyParts =
List(
"credential",
"signature"
"signature",
"sig"
)

private def isSensitiveKey(name: String): Boolean = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,10 @@ final case class Input(name: Option[String],
content: Option[String]
) {
override def toString: String = {
import akka.http.scaladsl.model.Uri
import common.util.StringUtil.EnhancedString

// Remove query that may contain SAS token
val cleanUrl = url map { Uri(_).copy(rawQueryString = None).toString() }
this.getClass.getName + Seq(name, description, cleanUrl, path, `type`, content).mkString("(",",",")")
// Mask SAS token signature in query
this.getClass.getName + Seq(name, description, url.map(_.maskSensitiveUri), path, `type`, content).mkString("(",",",")")

Check warning on line 375 in supportedBackends/tes/src/main/scala/cromwell/backend/impl/tes/TesTask.scala

View check run for this annotation

Codecov / codecov/patch

supportedBackends/tes/src/main/scala/cromwell/backend/impl/tes/TesTask.scala#L375

Added line #L375 was not covered by tests
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,15 @@ class TesTaskSpec extends AnyFlatSpec with CromwellTimeoutSpec with Matchers wit
val input = Input(
Option("asdf"),
Option("asdf"),
url = Option("https://example.com?secret=Zardoz&password=Blah"),
url = Option("https://lz304a1e79fd7359e5327eda.blob.core.windows.net/sc-705b830a-d699-478e-9da6-49661b326e77" +
"?sv=2021-12-02&spr=https&st=2023-12-13T20%3A27%3A55Z&se=2023-12-14T04%3A42%3A55Z&sr=c&sp=racwdlt&sig=SECRET&rscd=foo"),
"asdf",
Option("asdf"),
Option("asdf")
)

input.toString shouldBe "cromwell.backend.impl.tes.Input(Some(asdf),Some(asdf),Some(https://example.com),asdf,Some(asdf),Some(asdf))"
input.toString shouldBe "cromwell.backend.impl.tes.Input(Some(asdf),Some(asdf),Some(https://lz304a1e79fd7359e5327eda.blob.core.windows.net/sc-705b830a-d699-478e-9da6-49661b326e77" +
"?sv=2021-12-02&spr=https&st=2023-12-13T20:27:55Z&se=2023-12-14T04:42:55Z&sr=c&sp=racwdlt&sig=masked&rscd=foo),asdf,Some(asdf),Some(asdf))"
}

it should "not crash if the URL is missing" in {
Expand Down

0 comments on commit d72f7cf

Please sign in to comment.