-
Notifications
You must be signed in to change notification settings - Fork 2
Update gem dependencies #7
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
Changes from 19 commits
759d70c
48d9fea
fd61483
6b6346c
df57020
22da276
a275c64
a4bf6db
b3ac79b
8fa8023
3fe7b0e
4a32047
10f1e48
9afc055
f38f176
586d47f
7cf84be
941ea8d
5d43d4e
7fb5e05
02d2408
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Run Tests | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
# Test on code-dot-org Ruby version | ||
test_3_0_5: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 3.0.5 | ||
bundler-cache: true | ||
|
||
- name: Install gems | ||
run: bundle install | ||
|
||
- name: Run tests | ||
run: bundle exec rake test | ||
|
||
#Test on latest Ruby | ||
test_3_3: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 3.3 | ||
bundler-cache: true | ||
|
||
- name: Install gems | ||
run: bundle install | ||
|
||
- name: Run tests | ||
run: bundle exec rake test |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.0.5 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM ruby:3.0.5 | ||
cat5inthecradle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
WORKDIR /app | ||
|
||
# Copy bare minimum files to install gems | ||
COPY Gemfile aws-google.gemspec /app/ | ||
COPY lib /app/lib | ||
RUN bundle install |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: '3' | ||
services: | ||
ruby: | ||
build: . | ||
volumes: | ||
- .:/app | ||
working_dir: /app | ||
command: bash |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,22 +23,31 @@ def initialize(options = {}) | |
end | ||
|
||
def refresh_if_near_expiration | ||
if near_expiration?(SYNC_EXPIRATION_LENGTH) | ||
@mutex.synchronize do | ||
if near_expiration?(SYNC_EXPIRATION_LENGTH) | ||
refresh | ||
write_credentials | ||
end | ||
return unless near_expiration?(SYNC_EXPIRATION_LENGTH) | ||
|
||
@mutex.synchronize do | ||
if near_expiration?(SYNC_EXPIRATION_LENGTH) | ||
refresh | ||
write_credentials | ||
end | ||
end | ||
end | ||
|
||
# Write credentials and expiration to AWS credentials file. | ||
def write_credentials | ||
# AWS CLI is needed because writing AWS credentials is not supported by the AWS Ruby SDK. | ||
# Ensure the AWS CLI is available before attempting to write credentials. | ||
return unless system('which aws >/dev/null 2>&1') | ||
Aws::SharedCredentials::KEY_MAP.transform_values(&@credentials.method(:send)). | ||
merge(expiration: @expiration).each do |key, value| | ||
|
||
# Manually map the credentials to the keys used by AWS CLI | ||
credentials_map = { | ||
'aws_access_key_id' => @credentials.access_key_id, | ||
'aws_secret_access_key' => @credentials.secret_access_key, | ||
'aws_session_token' => @credentials.session_token, | ||
'expiration' => @expiration | ||
} | ||
|
||
# Use the AWS CLI to set the credentials in the session profile | ||
credentials_map.each do |key, value| | ||
system("aws configure set #{key} #{value} --profile #{@session_profile}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not an issue with your current code changes, just a vulnerability in general. This putting secrets on CLI arguments allows other people to sniff the creds with a simple
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, sounds like a good idea |
||
end | ||
cat5inthecradle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,9 +83,9 @@ | |
it 'refreshes expired Google auth token credentials' do | ||
m = mock | ||
m.stubs(:refresh!) | ||
m.stubs(:id_token). | ||
returns(JWT.encode({ email: 'email', exp: Time.now.to_i - 1 }, '')). | ||
then.returns(JWT.encode({ email: 'email' }, '')) | ||
m.stubs(:id_token) | ||
.returns(JWT.encode({ email: 'email', exp: Time.now.to_i - 1 }, '')) | ||
.then.returns(JWT.encode({ email: 'email' }, '')) | ||
Google::Auth.stubs(:get_application_default).returns(m) | ||
|
||
system.times(5) | ||
|
@@ -108,6 +108,7 @@ | |
expiration = provider.expiration | ||
_(expiration).must_equal(provider.expiration) | ||
Timecop.travel(1.5.hours.from_now) do | ||
provider.refresh! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Hamms The newer versions of aws-sdk-core do not automatically refresh when you check the |
||
_(expiration).wont_equal(provider.expiration) | ||
end | ||
end | ||
|
@@ -124,7 +125,7 @@ | |
Aws::Google.any_instance.expects(:refresh).never | ||
Aws::Google.new(config).credentials | ||
end | ||
|
||
it 'uses config defaults for new AWS clients' do | ||
Aws::Google.stubs(:config).returns(config) | ||
@oauth_default.once | ||
|
@@ -204,7 +205,7 @@ | |
Aws::Google.new(config).credentials | ||
end | ||
end | ||
|
||
describe 'no shared config' do | ||
before do | ||
Aws.shared_config.fresh( | ||
|
Uh oh!
There was an error while loading. Please reload this page.