Skip to content

Commit c3d97c6

Browse files
committed
add keyth_check_file, update gemspec and readme, alter shebang paths on commands
1 parent cd597c1 commit c3d97c6

4 files changed

Lines changed: 34 additions & 8 deletions

File tree

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ For example, my_values.yml was:
4343

4444
### TOOLS:
4545

46-
bin/keyth_admin allows you to add, remove, or list keys in your local store
46+
keyth_admin allows you to add, remove, or list keys in your local store
4747

48-
### TODO:
48+
keyth_check_file checks to see if a supplied file contains any of the keys listed in the keystore, and fails with suggested replacements if any are found. This can be called from (for example) a git hook to check that committed files don't contain any of the keys you're storing locally.
4949

50-
Support code for Ruby GitHooks that will automatically flag any key listed in the key repository that has somehow escaped into commitable files.

bin/keyth_admin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /usr/bin/ruby
1+
#! /usr/bin/env ruby
22
# encoding: utf-8
33
require 'keyth'
44

bin/keyth_check_file

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#! /usr/bin/env ruby
2+
# encoding: utf-8
3+
require 'keyth'
4+
5+
unless ARGV[0]
6+
puts 'Usage: keyth_check_file <file>'
7+
exit 1
8+
end
9+
10+
unless File.file?(ARGV[0])
11+
puts "ERROR: #{ARGV[0]} not found"
12+
exit 1
13+
end
14+
15+
errors = []
16+
file_contents = File.read(ARGV[0])
17+
Keyth.keys.each do |k, v|
18+
if file_contents.include?(v)
19+
errors << "Found: #{v} replace with keyth:#{k}"
20+
end
21+
end
22+
23+
exit 0 if errors.empty?
24+
25+
errors.each { |e| puts e }
26+
exit 1

keyth.gemspec

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# encoding: utf-8
22
Gem::Specification.new do |s|
33
s.name = 'keyth'
4-
s.version = '0.1.0'
5-
s.date = '2014-08-16'
4+
s.version = '0.2.0'
5+
s.date = '2014-08-17'
66
s.summary = 'Keyth!'
77
s.description = 'Handles named keys for use in config files'
88
s.authors = ['K M Lawrence']
99
s.email = 'keith@kludge.co'
10-
s.executables = ['keyth_admin']
11-
s.files = ['lib/keyth.rb', 'lib/keyth/yaml.rb', 'lib/keyth/dotenv.rb', 'bin/keyth_admin']
10+
s.executables = ['keyth_admin', 'keyth_check_file']
11+
s.files = ['lib/keyth.rb', 'lib/keyth/yaml.rb', 'lib/keyth/dotenv.rb',
12+
'bin/keyth_admin', 'bin/keyth_check_file']
1213
s.homepage = 'http://rubygems.org/gems/keyth'
1314
s.license = 'MIT'
1415
end

0 commit comments

Comments
 (0)