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

A secret step #34

Closed
wants to merge 7 commits into from
Closed

A secret step #34

wants to merge 7 commits into from

Conversation

rsandell
Copy link
Member

That can decrypt a string literal.
The Snippetizer page provides a way to encrypt a plain text string.

This can be considered a PoC for how I interpreted the examples of this step.

@reviewbybees

The test case worksInEnvironment currently fails, I'm trying to figure out why. Somehow the descriptor is complaining that the parameter is of the wrong type when called from inside environment {}

That can decrypt a string literal.
The Snippetizer page provides a way to encrypt a plain text string

@Override
public Step newInstance(@CheckForNull StaplerRequest req, @Nonnull JSONObject formData) throws FormException {
if (req.findAncestor(Snippetizer.class) != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you do not just want to declare the parameter to be of type Secret? Would need a little work in structs but probably easy enough.

String plainText = "Bobby`s lil secret";
String script = "pipeline {\n" +
" environment {\n" +
" FOO = secret('"+encrypt(plainText)+"')\n" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not being run as a regular Step in a stage, so I have no idea how this is implemented. Does not look like a bug in SecretStep per se.

@ghost
Copy link

ghost commented Oct 21, 2016

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

@abayer
Copy link
Member

abayer commented Oct 22, 2016

fwiw, I think foo = "${secret('whatever')}" would work. But we do need something better here. That said, I'm not sure if we actually want secret to be a Step and not just a method?

@abayer
Copy link
Member

abayer commented Oct 22, 2016

Ok, found the problem - PropertiesToMapTranslator.methodMissing(String, args) was just passing args on untouched, but in every other place, I massage that to take the first element if it's a one-length array. So - fixed that, and fixed the nonLiteralEnvironment test accordingly. So - passes!

@rsandell
Copy link
Member Author

I guess we now need to figure out if this is what @kohsuke intended :)

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this tries to implement JENKINS-27386, though it makes little sense to do it in this plugin, since there is no apparent reason why this would not be usable in non-declarative scripts.

I believe JENKINS-27398 would be a better approach as it integrates with Credentials and allows for better safety.


@Override
public String run() throws Exception {
return DescriptorImpl.decrypt(step.getText());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will leave the plaintext in program.dat. Also it does nothing to prevent you from accidentally disclosing the secret in the log.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the intention of this step as I understand it is to avoid having plain text secrets in your repo.
Whatever happens to it on the Jenkins master is of a lot lower concern. And afaiu the same this could be said about withCredentials.

@rsandell
Copy link
Member Author

@jglick Implementing credentials is a different task from this one

@jglick
Copy link
Member

jglick commented Oct 28, 2016

the same this could be said about withCredentials

No, that step both masks log occurrences, and keeps the secret encrypted in program.dat—check its test coverage.

Implementing credentials is a different task from this one

My argument is that implementing Credentials is the only reasonable way to accomplish the goal here. You want to not merely load some passwords in Groovy, you want interoperability with the wide array of plugins which expect secrets to be passed in as a credentialsId argument, and would not accept a “raw” password.

@rsandell
Copy link
Member Author

rsandell commented Dec 16, 2016

So decision is that this approach is not feasible.

@rsandell rsandell closed this Dec 16, 2016
@bitwiseman bitwiseman deleted the secret-step branch November 4, 2019 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants