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

WX-1385 Remove SAS tokens from TES input log printouts #7358

Merged
merged 10 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
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 @@ -367,7 +367,14 @@
path: String,
`type`: Option[String],
content: Option[String]
)
) {
override def toString: String = {
import common.util.StringUtil.EnhancedString

// 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
}
}

final case class Output(name: Option[String],
description: Option[String],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,32 @@ class TesTaskSpec extends AnyFlatSpec with CromwellTimeoutSpec with Matchers wit
"parent_workflow_id" -> Option(subWorkflowId.toString)
)
}

it should "not leak secrets when printing file paths" in {
val input = Input(
Option("asdf"),
Option("asdf"),
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://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 {
val input = Input(
Option("asdf"),
Option("asdf"),
url = None,
"asdf",
Option("asdf"),
Option("asdf")
)

input.toString shouldBe "cromwell.backend.impl.tes.Input(Some(asdf),Some(asdf),None,asdf,Some(asdf),Some(asdf))"
}
}
Loading