Skip to content
This repository has been archived by the owner on May 10, 2018. It is now read-only.

Commit

Permalink
whitelisting jwt and enabling decryption of whitelisted addons
Browse files Browse the repository at this point in the history
  • Loading branch information
sebv authored and Gavin Mogan committed Jul 19, 2016
1 parent 20523d5 commit 104fe4c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/travis/model/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Job < Travis::Model
mariadb
postgresql
ssh_known_hosts
jwt
).freeze

class << self
Expand Down Expand Up @@ -133,13 +134,8 @@ def decrypted_config
normalize_config(self.config).deep_dup.tap do |config|
config[:env] = process_env(config[:env]) { |env| decrypt_env(env) } if config[:env]
config[:global_env] = process_env(config[:global_env]) { |env| decrypt_env(env) } if config[:global_env]
if config[:addons]
if addons_enabled?
config[:addons] = decrypt_addons(config[:addons])
else
delete_addons(config)
end
end
delete_addons(config) if config[:addons] && !addons_enabled?
config[:addons] = decrypt_addons(config[:addons]) if config[:addons]
end
rescue => e
logger.warn "[job id:#{id}] Config could not be decrypted due to #{e.message}"
Expand Down
20 changes: 20 additions & 0 deletions spec/travis/model/job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,26 @@
}
}
end

it 'decrypts whitelisted addons', :only => true do
config = { rvm: '1.8.7',
addons: {
jwt: {
secret: job.repository.key.secure.encrypt('ABC=foobar')
}
}
}
job.config = config

job.decrypted_config.should == {
rvm: '1.8.7',
addons: {
jwt: {
secret: 'ABC=foobar'
}
}
}
end
end

context 'when job has secure env enabled' do
Expand Down

0 comments on commit 104fe4c

Please sign in to comment.