Skip to content

Make sure encrypted file env variable names are unique per filename#678

Merged
svenfuchs merged 3 commits into
masterfrom
sf-fix-file-encryption-var-names
Aug 8, 2019
Merged

Make sure encrypted file env variable names are unique per filename#678
svenfuchs merged 3 commits into
masterfrom
sf-fix-file-encryption-var-names

Conversation

@svenfuchs

Copy link
Copy Markdown
Contributor

As per this comment #239 (comment) encrypted file env variable names should be unique per filename:

Each file should have its own set of variables (that's why there's a hash in the var name).

But they are not, because all we hash is the current working directory Dir.pwd. This PR addresses that.

@svenfuchs

Copy link
Copy Markdown
Contributor Author

The tests fail because the Ruby versions 1.9.2 and 1.9.3 cannot be installed. Apparently they have been removed? In any case that's unrelated :)


def env_name(name)
@env_prefix ||= "encrypted_#{Digest.hexencode(Digest::SHA1.digest(Dir.pwd)[0..5])}"
def env_name(input_path, name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tiny caveat here is that, as it was before, this command is context dependent. If we execute travis encrypt-file from a different directory, even if the command is invoked on the same file, we will compute a different hash. This is not documented anywhere, but it is worth pointing it out.

@svenfuchs svenfuchs Aug 5, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@BanzaiMan without having verified it, i believe that input_path is whatever path is passed to travis encrypt path/to/file (i.e. it would be path/to/file). so yes, i guess that counts as context dependent, but it kinda makes sense to me, as such paths would be considered unique per repo, too (and so would the resulting env vars)?

@BanzaiMan BanzaiMan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Other than that small caveat, this looks good to me.

@svenfuchs
svenfuchs merged commit 12182e0 into master Aug 8, 2019
@svenfuchs
svenfuchs deleted the sf-fix-file-encryption-var-names branch August 8, 2019 18:24
@oblador

oblador commented Sep 14, 2019

Copy link
Copy Markdown

Any chance of this being released soon?

sauloperez added a commit to coopdevs/timeoverflow-provisioning that referenced this pull request Nov 11, 2019
Unfortunatley, Travis does not support encrypting multiple files (see:
travis-ci/travis.rb#239) and although it's
been solved in travis-ci/travis.rb#678 there's
still no release including it. I followed the documentation at
https://docs.travis-ci.com/user/encrypting-files/?source=post_page---------------------------#encrypting-multiple-files
and encrypted a tar file that contains all files: the deployment private
key and the vault password file.

Yet another reason to switch to an alternative like Circe CI or
GitLab...
@sfc-gh-japatel

Copy link
Copy Markdown

How to fetch key and iv values to put as env variable in repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants