Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Travis Public Repository how to add a Secure variable that works on Pull requests too

I have Travis-ci on a public repository. After finishing the execution it generates a image that I want to upload to cloudinary.com, but it could be any other service.

The problem is that to do it, I need to add in .travis.yml the auth token. But I don't want to expose it publicly, and for that travis offers a way to secure Env variables: http://docs.travis-ci.com/user/environment-variables/#Secure-Variables. However they do not work on PULL requests:

Secure Env variables are not available on pull requests from forks due to security risk of exposing such information to unknown code. Encryption and decryption keys are tied to the repository. If you fork a project and add it to Travis CI, it will have different keys to the original.

Anyone has any idea about how could I add an hidden value that is available for PUSH and PULL REQUESTS?

like image 352
javigomez Avatar asked Jul 03 '15 14:07

javigomez


People also ask

Which of the following permissions are accepted by public repositories in Travis CI?

On https://travis-ci.com, via our GitHub Apps integration, we ask for the following permissions: Read access to code. Read access to metadata and pull requests. Read and write access to administration, checks, commit statuses, and deployments.

Which of the following encryption scheme is used by Travis CI?

Encryption scheme # Travis CI uses asymmetric cryptography. For each registered repository, Travis CI generates an RSA keypair.

What is build in pull request?

A Pull Request Build is a build of a non-production branch of your site. Pull Request Builds are intended to show the impact of potential code changes before merging those changes into your production branch.


1 Answers

As you already wrote in your question: according to the official Travis CI documentation https://docs.travis-ci.com/user/environment-variables you won't have access to these variables from untrusted builds such as pull requests. This makes sense, since someone could submit a pull request to your repository containing malicious code which then exposes your secret value.

Bottom line: if you want to make secret values available to pull requests, you have to assume they're not secret anymore - therefore you could also just hard code the unencrypted value to your .travis.yml and use it from there. Which doesn't seem like a good idea. ;-)

Possible solution in your case: you could just use an image hoster which provides anonymous uploading? You wouldn't need an auth key, so your pull requests would be able to upload, too.

like image 179
finefoot Avatar answered Oct 20 '22 23:10

finefoot