-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from koenrh/add-aws-plugin
Add support for AWS credentials
- Loading branch information
Showing
7 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
require 'rake/testtask' | ||
|
||
Rake::TestTask.new(:test) do |t| | ||
t.pattern = 'test/**/*_test.rb' | ||
end | ||
|
||
task default: :test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Vcsmap | ||
module Plugin | ||
class AwsAccessToken < Vcsmap::Plugin::BasePlugin | ||
def initialize | ||
@search_string = ['aws_secret_access_key', | ||
'filename:config', | ||
'filename:credentials'].join('+') | ||
@access_key_id_regex = /=\s+(AKIA[0-9A-Z]{16})/ | ||
@secret_access_key_regex = %r{=\s+([0-9a-zA-Z\/+]{40})} | ||
end | ||
|
||
def credentials(file) | ||
@access_key_id = capture_match(@access_key_id_regex, file) | ||
@secret_access_key = capture_match(@secret_access_key_regex, file) | ||
[@access_key_id, @secret_access_key] | ||
rescue NoMethodError | ||
[] | ||
end | ||
|
||
def table_header | ||
['Access Key ID', 'Secret Access Key'] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require_relative '../test_helper' | ||
|
||
require 'plugins/base_plugin' | ||
require 'plugins/aws_access_token' | ||
|
||
describe Vcsmap::Plugin::AwsAccessToken do | ||
let(:plugin) { Vcsmap::Plugin::AwsAccessToken.new } | ||
|
||
let(:file) do | ||
<<-eos | ||
[contoso] | ||
aws_access_key_id = AKIAED8B369A90EDAB2A | ||
aws_secret_access_key = EAB37ae33174B8A2B0f0/3798C78ca26EAB37AE3 | ||
eos | ||
end | ||
|
||
describe '#capture_match' do | ||
it 'must return the matched AWS key pair' do | ||
credentials = plugin.credentials(file) | ||
|
||
expected = ['AKIAED8B369A90EDAB2A', 'EAB37ae33174B8A2B0f0/3798C78ca26EAB37AE3'] | ||
credentials.must_equal expected | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__) | ||
|
||
require 'minitest/autorun' |