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

Fix cli encrypt-file multi-file issue outlined in #627 #628

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/travis/cli/encrypt_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def run(input_path, output_path = nil)

error "requires --decrypt-to option when reading from stdin" unless decrypt_to?

set_env_vars
set_env_vars(input_path)

command = decrypt_command(output_path)
stage ? store_command(command) : print_command(command)
Expand Down Expand Up @@ -70,14 +70,14 @@ def decrypt_command(path)
"openssl aes-256-cbc -K $#{env_name(:key)} -iv $#{env_name(:iv)} -in #{escape_path(path)} -out #{escape_path(decrypt_to)} -d"
end

def set_env_vars
def set_env_vars(input_path)
say "storing secure env variables for decryption"
repository.env_vars.upsert env_name(:key), key, :public => false
repository.env_vars.upsert env_name(:iv), iv, :public => false
repository.env_vars.upsert env_name(:key, input_path), key, :public => false
repository.env_vars.upsert env_name(:iv, input_path), iv, :public => false
end

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

Expand Down