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 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
7 changes: 6 additions & 1 deletion common/src/main/scala/common/util/UriUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,13 @@
"signature"
)

private val SensitiveKeys =
List(
"sig"
)

private def isSensitiveKey(name: String): Boolean = {
val lower = name.toLowerCase
SensitiveKeyParts.exists(lower.contains(_))
SensitiveKeyParts.exists(lower.contains(_)) || SensitiveKeys.exists(lower.equals(_))

Check warning on line 97 in common/src/main/scala/common/util/UriUtil.scala

View check run for this annotation

Codecov / codecov/patch

common/src/main/scala/common/util/UriUtil.scala#L97

Added line #L97 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,15 @@ final case class Input(name: Option[String],
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("(", ",", ")")
}
}

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,34 @@ 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