cert-help 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +66 -0
- data/Rakefile +132 -0
- data/bin/cert-help +7 -0
- data/cert-help.gemspec +72 -0
- data/lib/cert-help.rb +15 -0
- data/lib/cert-help/apple.rb +42 -0
- data/lib/cert-help/command.rb +50 -0
- data/lib/cert-help/search.rb +46 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e5c791cbcae51df5276d87f676e86906d01e59a1
|
4
|
+
data.tar.gz: eaaf96c4ff2084d8a66dfb91492966c975d41dfd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fc8f5fc3fcb24e8acf43c207e9d6442fb345099aaf4ad504ef8da1c30f10f3570f996e501d5345c5267a08f13aa365e0df1fb2f214aab82c4293aff121208bb1
|
7
|
+
data.tar.gz: 1c1348d9e1e88711625532eaf6fc8fb9a6994cad9d2c194252a1c5aef01c213bc3783a5a9f8ae8c6205621daa6a7e37d056f2cca074969f6db28cfc7d4d5a54e
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 iShoutOut
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
#cert-help
|
2
|
+
|
3
|
+
A helper which will let you find certificates on OSX
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
**General Help**
|
8
|
+
|
9
|
+
```
|
10
|
+
$ cert-help --help
|
11
|
+
cert-help <command>
|
12
|
+
-h --help prints this help screen
|
13
|
+
-v --version show the current version
|
14
|
+
search <term> search for a certificate
|
15
|
+
apple <method> find apple certificates
|
16
|
+
```
|
17
|
+
|
18
|
+
**Command Specific Help**
|
19
|
+
|
20
|
+
```
|
21
|
+
$ cert-help search --help
|
22
|
+
cert-help search <term>
|
23
|
+
<term> search for a particular term
|
24
|
+
```
|
25
|
+
|
26
|
+
##Development
|
27
|
+
|
28
|
+
###Dependencies
|
29
|
+
|
30
|
+
Dependencies are handled with __Bundler__ and stored in _Gemfile_.
|
31
|
+
|
32
|
+
```
|
33
|
+
bundle install
|
34
|
+
```
|
35
|
+
|
36
|
+
###Running in console
|
37
|
+
|
38
|
+
The _Rakefile_ contains a task for loading the project into __irb__
|
39
|
+
|
40
|
+
```
|
41
|
+
$ rake console
|
42
|
+
irb -rubygems -r ./lib/cert-help.rb
|
43
|
+
irb(main):001:0>
|
44
|
+
```
|
45
|
+
|
46
|
+
###Packaging Gem
|
47
|
+
|
48
|
+
Update `VERSION` in _lib/cert-help.rb_ with the correct new version
|
49
|
+
then run the __build__ task.
|
50
|
+
|
51
|
+
The task will update `s.files = %w[` with the contents of `git ls-files`,
|
52
|
+
meaning **files not added to git will not be packaged (few exceptions)**.
|
53
|
+
|
54
|
+
The resulting _gem_ will then be moved to the _pkg_ folder.
|
55
|
+
|
56
|
+
```
|
57
|
+
$ rake build
|
58
|
+
Updated cert-help.gemspec
|
59
|
+
mkdir -p pkg
|
60
|
+
gem build cert-help.gemspec
|
61
|
+
Successfully built RubyGem
|
62
|
+
Name: cert-help
|
63
|
+
Version: 0.1
|
64
|
+
File: cert-help-0.1.gem
|
65
|
+
mv cert-help-0.1.gem pkg
|
66
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
#############################################################################
|
6
|
+
#
|
7
|
+
# Helper functions
|
8
|
+
#
|
9
|
+
#############################################################################
|
10
|
+
|
11
|
+
def name
|
12
|
+
@name = 'cert-help'
|
13
|
+
end
|
14
|
+
|
15
|
+
def version
|
16
|
+
line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
|
17
|
+
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
18
|
+
end
|
19
|
+
|
20
|
+
def date
|
21
|
+
Date.today.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def rubyforge_project
|
25
|
+
name
|
26
|
+
end
|
27
|
+
|
28
|
+
def gemspec_file
|
29
|
+
"#{name}.gemspec"
|
30
|
+
end
|
31
|
+
|
32
|
+
def gem_file
|
33
|
+
"#{name}-#{version}.gem"
|
34
|
+
end
|
35
|
+
|
36
|
+
def replace_header(head, header_name)
|
37
|
+
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
|
38
|
+
end
|
39
|
+
|
40
|
+
#############################################################################
|
41
|
+
#
|
42
|
+
# Standard tasks
|
43
|
+
#
|
44
|
+
#############################################################################
|
45
|
+
|
46
|
+
task :default => :test
|
47
|
+
|
48
|
+
desc "Run tests for boom"
|
49
|
+
task :test do
|
50
|
+
exec "test/run"
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Open an irb session preloaded with this library"
|
54
|
+
task :console do
|
55
|
+
sh "irb -rubygems -r ./lib/#{name}.rb"
|
56
|
+
end
|
57
|
+
|
58
|
+
#############################################################################
|
59
|
+
#
|
60
|
+
# Custom tasks (add your own tasks here)
|
61
|
+
#
|
62
|
+
#############################################################################
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
#############################################################################
|
67
|
+
#
|
68
|
+
# Packaging tasks
|
69
|
+
#
|
70
|
+
#############################################################################
|
71
|
+
|
72
|
+
desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
|
73
|
+
task :release => :build do
|
74
|
+
unless `git branch` =~ /^\* master$/
|
75
|
+
puts "You must be on the master branch to release!"
|
76
|
+
exit!
|
77
|
+
end
|
78
|
+
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
79
|
+
sh "git tag v#{version}"
|
80
|
+
sh "git push origin master"
|
81
|
+
sh "git push origin v#{version}"
|
82
|
+
sh "gem push pkg/#{name}-#{version}.gem"
|
83
|
+
end
|
84
|
+
|
85
|
+
desc "Build #{gem_file} into the pkg directory"
|
86
|
+
task :build => :gemspec do
|
87
|
+
sh "mkdir -p pkg"
|
88
|
+
sh "gem build #{gemspec_file}"
|
89
|
+
sh "mv #{gem_file} pkg"
|
90
|
+
end
|
91
|
+
|
92
|
+
desc "Generate #{gemspec_file}"
|
93
|
+
task :gemspec => :validate do
|
94
|
+
# read spec file and split out manifest section
|
95
|
+
spec = File.read(gemspec_file)
|
96
|
+
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
97
|
+
|
98
|
+
# replace name version and date
|
99
|
+
replace_header(head, :name)
|
100
|
+
replace_header(head, :version)
|
101
|
+
replace_header(head, :date)
|
102
|
+
#comment this out if your rubyforge_project has a different name
|
103
|
+
replace_header(head, :rubyforge_project)
|
104
|
+
|
105
|
+
# determine file list from git ls-files
|
106
|
+
files = `git ls-files`.
|
107
|
+
split("\n").
|
108
|
+
sort.
|
109
|
+
reject { |file| file =~ /^\./ }.
|
110
|
+
reject { |file| file =~ /^(rdoc|pkg)/ }.
|
111
|
+
map { |file| " #{file}" }.
|
112
|
+
join("\n")
|
113
|
+
|
114
|
+
# piece file back together and write
|
115
|
+
manifest = " s.files = %w[\n#{files}\n ]\n"
|
116
|
+
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
|
117
|
+
File.open(gemspec_file, 'w') { |io| io.write(spec) }
|
118
|
+
puts "Updated #{gemspec_file}"
|
119
|
+
end
|
120
|
+
|
121
|
+
desc "Validate #{gemspec_file}"
|
122
|
+
task :validate do
|
123
|
+
libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
|
124
|
+
unless libfiles.empty?
|
125
|
+
puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
|
126
|
+
exit!
|
127
|
+
end
|
128
|
+
unless Dir['VERSION*'].empty?
|
129
|
+
puts "A `VERSION` file at root level violates Gem best practices."
|
130
|
+
exit!
|
131
|
+
end
|
132
|
+
end
|
data/bin/cert-help
ADDED
data/cert-help.gemspec
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
## This is the rakegem gemspec template. Make sure you read and understand
|
2
|
+
## all of the comments. Some sections require modification, and others can
|
3
|
+
## be deleted if you don't need them. Once you understand the contents of
|
4
|
+
## this file, feel free to delete any comments that begin with two hash marks.
|
5
|
+
## You can find comprehensive Gem::Specification documentation, at
|
6
|
+
## http://docs.rubygems.org/read/chapter/20
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
9
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
10
|
+
s.rubygems_version = '1.3.5'
|
11
|
+
|
12
|
+
## Leave these as is they will be modified for you by the rake gemspec task.
|
13
|
+
## If your rubyforge_project name is different, then edit it and comment out
|
14
|
+
## the sub! line in the Rakefile
|
15
|
+
s.name = 'cert-help'
|
16
|
+
s.version = '0.1'
|
17
|
+
s.date = '2014-07-15'
|
18
|
+
s.rubyforge_project = 'cert-help'
|
19
|
+
|
20
|
+
## Make sure your summary is short. The description may be as long
|
21
|
+
## as you like.
|
22
|
+
s.summary = "cert-help lets you search through installed certficates on OSX."
|
23
|
+
s.description = "Simple helpers like cert-help apple will display certificates
|
24
|
+
related to iOS development, while cert-help search <term> will allow you to
|
25
|
+
search for any certificate alias"
|
26
|
+
|
27
|
+
## List the primary authors. If there are a bunch of authors, it's probably
|
28
|
+
## better to set the email to an email list or something. If you don't have
|
29
|
+
## a custom homepage, consider using your GitHub URL or the like.
|
30
|
+
s.authors = ["Nick Otter"]
|
31
|
+
s.email = 'notter@ishoutout.com'
|
32
|
+
s.homepage = 'https://bitbucket.org/ishoutout/gem-cert-search'
|
33
|
+
s.license = 'MIT'
|
34
|
+
|
35
|
+
## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
|
36
|
+
## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
|
37
|
+
s.require_paths = %w[lib]
|
38
|
+
|
39
|
+
## This sections is only necessary if you have C extensions.
|
40
|
+
#s.require_paths << 'ext'
|
41
|
+
#s.extensions = %w[ext/extconf.rb]
|
42
|
+
|
43
|
+
## If your gem includes any executables, list them here.
|
44
|
+
s.executables = ["cert-help"]
|
45
|
+
s.default_executable = 'cert-help'
|
46
|
+
|
47
|
+
## Specify any RDoc options here. You'll want to add your README and
|
48
|
+
## LICENSE files to the extra_rdoc_files list.
|
49
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
50
|
+
s.extra_rdoc_files = %w[README.md LICENSE]
|
51
|
+
|
52
|
+
## Leave this section as-is. It will be automatically generated from the
|
53
|
+
## contents of your Git repository via the gemspec task. DO NOT REMOVE
|
54
|
+
## THE MANIFEST COMMENTS, they are used as delimiters by the task.
|
55
|
+
# = MANIFEST =
|
56
|
+
s.files = %w[
|
57
|
+
LICENSE
|
58
|
+
README.md
|
59
|
+
Rakefile
|
60
|
+
bin/cert-help
|
61
|
+
cert-help.gemspec
|
62
|
+
lib/cert-help.rb
|
63
|
+
lib/cert-help/apple.rb
|
64
|
+
lib/cert-help/command.rb
|
65
|
+
lib/cert-help/search.rb
|
66
|
+
]
|
67
|
+
# = MANIFEST =
|
68
|
+
|
69
|
+
## Test files will be grabbed from the file list. Make sure the path glob
|
70
|
+
## matches what you actually use.
|
71
|
+
s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
|
72
|
+
end
|
data/lib/cert-help.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
begin
|
2
|
+
require 'rubygems'
|
3
|
+
rescue LoadError
|
4
|
+
end
|
5
|
+
|
6
|
+
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
7
|
+
|
8
|
+
require 'cert-help/apple'
|
9
|
+
require 'cert-help/command'
|
10
|
+
require 'cert-help/search'
|
11
|
+
|
12
|
+
module Certs
|
13
|
+
VERSION = "0.1"
|
14
|
+
COMMAND = 'cert-help'
|
15
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Certs
|
2
|
+
class Apple
|
3
|
+
class << self
|
4
|
+
|
5
|
+
def execute(command)
|
6
|
+
|
7
|
+
return apple(command) if ['dev', 'dist', 'all'].includes?(command)
|
8
|
+
return help
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
def apple(command)
|
13
|
+
|
14
|
+
certs = []
|
15
|
+
|
16
|
+
searches = []
|
17
|
+
|
18
|
+
searches << "iPhone Distribution" if command == 'dist' || command == 'all'
|
19
|
+
searches << "iPhone Developer" if command == 'dev' || command == 'all'
|
20
|
+
|
21
|
+
searches.each do |term|
|
22
|
+
Certs::Search.searchAux(certs, term)
|
23
|
+
end
|
24
|
+
|
25
|
+
if certs.size > 0
|
26
|
+
puts certs
|
27
|
+
else
|
28
|
+
puts "Couldn't find any certs"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
def help
|
34
|
+
puts "#{Certs::COMMAND} apple <command>"
|
35
|
+
puts "<command> is optional"
|
36
|
+
puts "\tdist search for distribution certificates"
|
37
|
+
puts "\tdev search for development certificates"
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Certs
|
2
|
+
|
3
|
+
# Provides terminal access to the ruby api
|
4
|
+
#
|
5
|
+
# Deligates commands based on user input, displaying
|
6
|
+
# version, help, and listing certificates based on searches
|
7
|
+
#
|
8
|
+
# @author Nick Otter <notter@ishoutout.com>
|
9
|
+
class Command
|
10
|
+
class << self
|
11
|
+
|
12
|
+
# Terns ARGV to marjor, minor commands
|
13
|
+
#
|
14
|
+
# @param [Array] *args The user input
|
15
|
+
def execute(*args)
|
16
|
+
|
17
|
+
major = args.shift
|
18
|
+
minor = args.shift
|
19
|
+
|
20
|
+
deligate(major, minor)
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
# Decides which command to execute based on major, minor
|
25
|
+
def deligate(major, minor)
|
26
|
+
return version if ['-v', '--version'].include?(major)
|
27
|
+
|
28
|
+
return Certs::Apple.execute(minor) if major == 'apple'
|
29
|
+
return Certs::Search.execute(minor) if major == 'search'
|
30
|
+
|
31
|
+
help
|
32
|
+
end
|
33
|
+
|
34
|
+
# Informs the user how to use this program
|
35
|
+
def help
|
36
|
+
puts "#{Certs::COMMAND} <command>"
|
37
|
+
puts "\t-h --help prints this help screen"
|
38
|
+
puts "\t-v --version show the current version"
|
39
|
+
puts "\tsearch <term> search for a certificate"
|
40
|
+
puts "\tapple <method> find apple certificates"
|
41
|
+
end
|
42
|
+
|
43
|
+
# Shows the user which version is being used
|
44
|
+
def version
|
45
|
+
puts "Version: #{Certs::VERSION}"
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Certs
|
2
|
+
class Search
|
3
|
+
class << self
|
4
|
+
|
5
|
+
def execute(command)
|
6
|
+
|
7
|
+
return help if command.nil? || ['help', '-h', '--help'].include?(command)
|
8
|
+
return certs(command)
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
def help
|
13
|
+
puts "#{Certs::COMMAND} search <term>"
|
14
|
+
puts "<term> search for a particular term"
|
15
|
+
end
|
16
|
+
|
17
|
+
def certs(term)
|
18
|
+
|
19
|
+
certs = []
|
20
|
+
searchAux(certs, term)
|
21
|
+
|
22
|
+
if certs.size > 0
|
23
|
+
puts certs
|
24
|
+
else
|
25
|
+
puts "Couldn't find any certs"
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def searchAux(certs, term)
|
31
|
+
|
32
|
+
results = `security find-certificate -a -c "#{term}"`
|
33
|
+
|
34
|
+
match = /"alis"<blob>="(.*)"$/.match(results)
|
35
|
+
|
36
|
+
return false if match.nil?
|
37
|
+
|
38
|
+
match.captures.each do |c|
|
39
|
+
certs << c
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cert-help
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nick Otter
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-15 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: |-
|
14
|
+
Simple helpers like cert-help apple will display certificates
|
15
|
+
related to iOS development, while cert-help search <term> will allow you to
|
16
|
+
search for any certificate alias
|
17
|
+
email: notter@ishoutout.com
|
18
|
+
executables:
|
19
|
+
- cert-help
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files:
|
22
|
+
- README.md
|
23
|
+
- LICENSE
|
24
|
+
files:
|
25
|
+
- LICENSE
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- bin/cert-help
|
29
|
+
- cert-help.gemspec
|
30
|
+
- lib/cert-help.rb
|
31
|
+
- lib/cert-help/apple.rb
|
32
|
+
- lib/cert-help/command.rb
|
33
|
+
- lib/cert-help/search.rb
|
34
|
+
homepage: https://bitbucket.org/ishoutout/gem-cert-search
|
35
|
+
licenses:
|
36
|
+
- MIT
|
37
|
+
metadata: {}
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options:
|
40
|
+
- --charset=UTF-8
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project: cert-help
|
55
|
+
rubygems_version: 2.0.14
|
56
|
+
signing_key:
|
57
|
+
specification_version: 2
|
58
|
+
summary: cert-help lets you search through installed certficates on OSX.
|
59
|
+
test_files: []
|
60
|
+
has_rdoc:
|