-
Notifications
You must be signed in to change notification settings - Fork 5k
Limit env variables propagated #13922
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
Conversation
@bot-gradle test QF |
OK, I've already triggered QuickFeedback build for you. |
5abd10c
to
bf2bd3e
Compare
@bot-gradle test QF |
Sorry some internal error occurs, please contact the administrator @blindpirate |
OK, I've already cancelled the old build and triggered a new QuickFeedback build for you. |
buildSrc/subprojects/jvm/src/main/kotlin/gradlebuild/propagated-env-variables.kt
Outdated
Show resolved
Hide resolved
buildSrc/subprojects/jvm/src/main/kotlin/gradlebuild/propagated-env-variables.kt
Outdated
Show resolved
Hide resolved
buildSrc/subprojects/jvm/src/main/kotlin/gradlebuild/propagated-env-variables.kt
Outdated
Show resolved
Hide resolved
bf2bd3e
to
8f44394
Compare
@bot-gradle test QF |
OK, I've already triggered QuickFeedback build for you. |
8f44394
to
9995e10
Compare
@bot-gradle test QF |
OK, I've already cancelled the old build and triggered a new QuickFeedback build for you. |
7ed8b95
to
7cbcc1a
Compare
buildSrc/subprojects/jvm/src/main/kotlin/gradlebuild/propagated-env-variables.kt
Outdated
Show resolved
Hide resolved
buildSrc/subprojects/jvm/src/main/kotlin/gradlebuild/propagated-env-variables.kt
Outdated
Show resolved
Hide resolved
32cf9d1
to
2e65f1f
Compare
@bot-gradle test RFN |
OK, I've already triggered ReadyForNightly build for you. |
|
||
fun Test.configurePropagatedEnvVariables() { | ||
if (BuildEnvironment.isCiServer) { | ||
environment = System.getenv().entries.mapNotNull(::sanitize).toMap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also have something that looks at the propagated environment variables and does a sanity check for "bad words"?
e.g., things like BUILD_CACHE_PASSWORD
and TEAMCITY_TOKEN
would make it through our filter, so I think we should make it so the build fails at this point if any env var contains (case insensitive) "password" or "token" so we're forced to pick a different name.
The failures at the test level below are OK, but it's too late at that point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few candidates to blacklist:
- apikey
- secret
- auth
- credential
buildSrc/subprojects/jvm/src/main/kotlin/gradlebuild/propagated-env-variables.kt
Outdated
Show resolved
Hide resolved
|
||
|
||
fun Test.configurePropagatedEnvVariables() { | ||
if (BuildEnvironment.isCiServer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ Local builds might also leak credentials. I think we should filter env vars for all builds.
@bot-gradle test RFN |
OK, I've already triggered ReadyForNightly build for you. |
fea444e
to
47f2b60
Compare
@bot-gradle test RFN |
OK, I've already triggered ReadyForNightly build for you. |
Now finally it passes all check, anyone wanna take an another look? |
buildSrc/subprojects/jvm/src/main/kotlin/gradlebuild/propagated-env-variables.kt
Outdated
Show resolved
Hide resolved
buildSrc/subprojects/jvm/src/main/kotlin/gradlebuild/propagated-env-variables.kt
Outdated
Show resolved
Hide resolved
buildSrc/subprojects/jvm/src/main/kotlin/gradlebuild/propagated-env-variables.kt
Outdated
Show resolved
Hide resolved
buildSrc/subprojects/jvm/src/main/kotlin/gradlebuild/propagated-env-variables.kt
Outdated
Show resolved
Hide resolved
buildSrc/subprojects/jvm/src/main/kotlin/gradlebuild/propagated-env-variables.kt
Outdated
Show resolved
Hide resolved
buildSrc/subprojects/jvm/src/main/kotlin/gradlebuild/unittest-and-compile.gradle.kts
Outdated
Show resolved
Hide resolved
@bot-gradle test RFN |
OK, I've already triggered ReadyForNightly build for you. |
2a25f70
to
5ada5ad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we shouldn't pass BUILD_
to the test JVM, since I don't need that variable on my machine either. Apart from that the PR looks good now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
We fork some more processes from the build of |
@wolfs you mean |
I think exec and javaexec. We should only check what we use there, there is probably no need to do anything. And that is some follow up work. |
As another follow up, we should probably convert this new code into a plugin and use it on the other public projects as well. It could be part of the GE conventions plugin. |
…d-env-variables.kt Co-authored-by: Stefan Wolf <[email protected]>
…d-env-variables.kt Co-authored-by: Stefan Wolf <[email protected]>
bdfac88
to
78cfa12
Compare
Limit environment variables propagated to test JVMs to avoid leaking credentials
Cherry-picked to |
* origin/release: Update to 6.6 RC5 Fix ktlint in Kotlin DSL Only use e.grdev.net for test distribution builds Upgrade conventions plugin to 0.7.1 Fix build logic instrumentation when a static interface method creates an instance of a serializable lambda. Limit env variables propagated (#13922) Merge pull request #13904 from gradle/blindpirate/remove-cmd-line-args-in-bat
No description provided.