-
-
Notifications
You must be signed in to change notification settings - Fork 414
Don't accept CI secrets on CLI in SonatypeCentralPublishModule #5543
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
base: main
Are you sure you want to change the base?
Don't accept CI secrets on CLI in SonatypeCentralPublishModule #5543
Conversation
These secrets might leak with Mill's prompt, that tries to print back the command arguments. These might be truncated in particular, which can make parts of these secrets slip through output secret detection.
Conflicts: libs/javalib/src/mill/javalib/SonatypeCentralPublishModule.scala
Perhaps we should make Mill support taking in |
@arturaz Maybe at some point, yes. We need better secret management overall, some secrets might leak in serialized task results under |
Conflicts: libs/javalib/src/mill/javalib/SonatypeCentralPublishModule.scala
val isCI = Task.env.get("CI").nonEmpty | ||
if (!force && isCI && (usernameParameterValue.nonEmpty || passwordParameterValue.nonEmpty)) | ||
sys.error( | ||
"--username and --password options forbidden on CI. " + | ||
"Their use might leak secrets. " + | ||
s"Pass those values via environment variables instead ($USERNAME_ENV_VARIABLE_NAME and $PASSWORD_ENV_VARIABLE_NAME), or pass --force alongside them. " + | ||
"You might want to check the output of this job for a leak of those secrets or parts of them." | ||
) |
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.
Since we consider this unsafe, we might as well print the same message as warning in all other cases.
Also, instead of sys.error
use Task.fail
.
This PR makes
SonatypeCentralPublishModule
refuse credentials passed via--username
and--password
if it detects it's running on a CI. Using these arguments poses security issues: the Mill's prompt tries to print them back, like in(prompt obtained by running a command like
./mill -i mill.scalalib.SonatypeCentralPublishModule/ --username … --password …
, containing parts of a now revoked token)These secrets might be truncated in particular, which can make parts of these secrets slip through output secret detection.