apple_certs_info 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 56e6c1da05b6d10dcd280b2752e52c17a8ee4d3839080361aa51417098deba92
4
+ data.tar.gz: 576ecf2cb9fa4885f81f7d7db5f7d496592c56873fa21df6afa18ae2b9603738
5
+ SHA512:
6
+ metadata.gz: 2904963e5ea9478d3761e8b7b090354532ace2a3485849115743105d6f46f2e33678d86ee9080a587aee9c457354f1340e8858c7b943f2cabadf24d3554a4cb2
7
+ data.tar.gz: 402ad5221d20ff8fed0f672040b0c02ffe44d9744a72b3cc45677509dac7619aeec0fed192ac25242d5eae5074e25372b5fce490539df4cf24a9f21a38b74f81
@@ -0,0 +1,56 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ # Ignore Byebug command history file.
17
+ .byebug_history
18
+
19
+ ## Specific to RubyMotion:
20
+ .dat*
21
+ .repl_history
22
+ build/
23
+ *.bridgesupport
24
+ build-iPhoneOS/
25
+ build-iPhoneSimulator/
26
+
27
+ ## Specific to RubyMotion (use of CocoaPods):
28
+ #
29
+ # We recommend against adding the Pods directory to your .gitignore. However
30
+ # you should judge for yourself, the pros and cons are mentioned at:
31
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
+ #
33
+ # vendor/Pods/
34
+
35
+ ## Documentation cache and generated files:
36
+ /.yardoc/
37
+ /_yardoc/
38
+ /doc/
39
+ /rdoc/
40
+
41
+ ## Environment normalization:
42
+ /.bundle/
43
+ /vendor/bundle
44
+ /lib/bundler/man/
45
+
46
+ # for a library or gem, you might want to ignore these files since the code is
47
+ # intended to run in multiple environments; otherwise, check them in:
48
+ # Gemfile.lock
49
+ # .ruby-version
50
+ # .ruby-gemset
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
54
+
55
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
+ # .rubocop-https?--*
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ example_id | status | run_time |
2
+ ------------------------------------ | ------- | --------------- |
3
+ ./spec/apple_certs_info_spec.rb[1:1] | passed | 0.00054 seconds |
4
+ ./spec/apple_certs_info_spec.rb[1:2] | pending | 0.00001 seconds |
5
+ ./spec/apple_certs_info_spec.rb[1:3] | passed | 0.37772 seconds |
6
+ ./spec/apple_certs_info_spec.rb[1:4] | pending | 0.00002 seconds |
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at toshiyuki.hirata@dena.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "rake", "~> 12.0"
6
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,34 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ apple_certs_info (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.4.4)
10
+ rake (12.3.3)
11
+ rspec (3.10.0)
12
+ rspec-core (~> 3.10.0)
13
+ rspec-expectations (~> 3.10.0)
14
+ rspec-mocks (~> 3.10.0)
15
+ rspec-core (3.10.1)
16
+ rspec-support (~> 3.10.0)
17
+ rspec-expectations (3.10.1)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.10.0)
20
+ rspec-mocks (3.10.1)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.10.0)
23
+ rspec-support (3.10.1)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ apple_certs_info!
30
+ rake (~> 12.0)
31
+ rspec (~> 3.0)
32
+
33
+ BUNDLED WITH
34
+ 2.1.4
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 tarappo
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.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Toshiyuki Hirata
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,51 @@
1
+ # AppleCertsInfo
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'apple_certs_info'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle install
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install apple_certs_info
18
+
19
+ ## Usage
20
+
21
+ Information with an expiration date of 55 days or less will return.
22
+
23
+ - Provisioning Profiles
24
+
25
+ ```
26
+ AppleCertsInfo.provisioning_profile_list_limit_days_for(days: 10)
27
+ ```
28
+ - Certificatefiles(Development / Distribution)
29
+
30
+
31
+ ```
32
+ # Development
33
+ AppleCertsInfo.certificate_development_list_limit_days_for(days: 10)
34
+
35
+ # Distribution
36
+ AppleCertsInfo.certificate_distribution_list_limit_days_for(days: 10)
37
+ ```
38
+
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/apple_certs_info. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/apple_certs_info/blob/master/CODE_OF_CONDUCT.md).
43
+
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
48
+
49
+ ## Code of Conduct
50
+
51
+ Everyone interacting in the AppleCertsInfo project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/apple_certs_info/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,26 @@
1
+ require_relative 'lib/apple_certs_info/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "apple_certs_info"
5
+ spec.version = AppleCertsInfo::VERSION
6
+ spec.authors = ["Toshiyuki Hirata"]
7
+ spec.email = ["toshiyuki.hirata@dena.com"]
8
+
9
+ spec.summary = %q{Apple Certificate files and Provisioning Profile information.}
10
+ spec.homepage = "https://github.com/tarappo/apple_certs_info"
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = "https://github.com/tarappo/apple_certs_info"
16
+ spec.metadata["changelog_uri"] = "https://github.com/tarappo/apple_certs_info/releases"
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+ end
@@ -0,0 +1,135 @@
1
+ require "apple_certs_info/version"
2
+ require "time"
3
+ require "tempfile"
4
+
5
+ module AppleCertsInfo
6
+ class Error < StandardError; end
7
+
8
+ def self.certificate_development_list_limit_days_for(days:)
9
+ raise "do not set days param" if days.nil?
10
+ limit_days_for(days: days, type: "certificate_development")
11
+ end
12
+
13
+ def self.certificate_distribution_list_limit_days_for(days:)
14
+ raise "do not set days param" if days.nil?
15
+ limit_days_for(days: days, type: "certificate_distribution")
16
+ end
17
+
18
+ def self.provisioning_profile_list_limit_days_for(days:)
19
+ raise "do not set days param" if days.nil?
20
+ limit_days_for(days: days, type: "provisioning_profile")
21
+ end
22
+
23
+ def self.certificate_development_list
24
+ certificate_list_for(name: "Development")
25
+ end
26
+
27
+ def self.certificate_distribution_list
28
+ certificate_list_for(name: "Distribution")
29
+ end
30
+
31
+ def self.certificate_info_for(name:)
32
+ raise "do not set name param" if name.nil?
33
+
34
+ temp_pem_file = Tempfile.new(::File.basename("temp_pem"))
35
+
36
+ begin
37
+ `security find-certificate -a -c "#{name}" -p > #{temp_pem_file.path}`
38
+ result = `openssl x509 -text -fingerprint -noout -in #{temp_pem_file.path}`
39
+
40
+ expire_datetime_match = result.match(/.*Not After :(.*)/)
41
+ raise "not exits expire date" if expire_datetime_match.nil?
42
+
43
+ expire_datetime = Time.parse(expire_datetime_match[1])
44
+
45
+ cname_match = result.match(/Subject: .* CN=(.*), OU=.*/)
46
+ raise "not exists cname" if cname_match.nil?
47
+ cname = cname_match[1]
48
+
49
+ limit_days = calc_limit_days(datetime: expire_datetime)
50
+
51
+ rescue StandardError => e
52
+ raise(e.message)
53
+ ensure
54
+ temp_pem_file.close && temp_pem_file.unlink
55
+ end
56
+
57
+ return {
58
+ :expire_datetime => expire_datetime,
59
+ :limit_days => limit_days,
60
+ :cname => cname
61
+ }
62
+ end
63
+
64
+ def self.provisioning_profile_list_info(dir: "~/Library/MobileDevice/Provisioning\\ Profiles/*.mobileprovision")
65
+ info = []
66
+ Dir.glob("#{File.expand_path(dir)}") do |file|
67
+ file_name_match = file.match(/.*\/(.*)\.mobileprovision/)
68
+ raise "not exists Provisioning Profile" if file_name_match.nil?
69
+
70
+ file_name = file_name_match[1]
71
+ temp_plist_file = Tempfile.new(::File.basename(file_name))
72
+ plist_file = temp_plist_file.path
73
+
74
+ begin
75
+ # exchange plist file
76
+ system("security cms -D -i '#{file}' > #{plist_file}")
77
+
78
+ # checking plist file
79
+ expire_datetime = Time.parse(`/usr/libexec/PlistBuddy -c 'Print ExpirationDate' #{plist_file}`)
80
+ app_identifier = `/usr/libexec/PlistBuddy -c 'Print Entitlements:application-identifier' #{plist_file}`.chomp
81
+ app_id_name = `/usr/libexec/PlistBuddy -c 'Print AppIDName' #{plist_file}`.chomp
82
+
83
+ limit_days = calc_limit_days(datetime: expire_datetime)
84
+
85
+ rescue StandardError => e
86
+ raise(e.message)
87
+ ensure
88
+ temp_plist_file.close && temp_plist_file.unlink
89
+ end
90
+
91
+ info << {
92
+ :expire_datetime => expire_datetime,
93
+ :limit_days => limit_days,
94
+ :app_identifier => app_identifier,
95
+ :app_id_name => app_id_name
96
+ }
97
+ end
98
+ return info
99
+ end
100
+
101
+ private
102
+ def self.limit_days_for(days:, type:)
103
+ case type
104
+ when "certificate_development" then
105
+ list = certificate_development_list
106
+ when "certificate_distribution" then
107
+ list = certificate_distribution_list
108
+ when "provisioning_profile" then
109
+ list = provisioning_profile_list_info
110
+ end
111
+
112
+ danger_list = []
113
+ list.each do |info|
114
+ danger_list << info if info[:limit_days] <= days
115
+ end
116
+
117
+ danger_list
118
+ end
119
+
120
+ def self.certificate_list_for(name:)
121
+ result = `security find-certificate -a -c "#{name}"`
122
+ name_match_list = result.scan(/.*alis"<blob>=\"(.*)\".*/)
123
+
124
+ info = []
125
+ name_match_list.each do|name_match|
126
+ info << certificate_info_for(name:name_match[0])
127
+ end
128
+
129
+ info
130
+ end
131
+
132
+ def self.calc_limit_days(datetime:)
133
+ ((datetime - Time.now)/(24*60*60)).ceil
134
+ end
135
+ end
@@ -0,0 +1,3 @@
1
+ module AppleCertsInfo
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: apple_certs_info
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Toshiyuki Hirata
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-01-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - toshiyuki.hirata@dena.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".rakeTasks"
22
+ - ".rspec"
23
+ - ".rspec_status"
24
+ - CODE_OF_CONDUCT.md
25
+ - Gemfile
26
+ - Gemfile.lock
27
+ - LICENSE
28
+ - LICENSE.txt
29
+ - README.md
30
+ - Rakefile
31
+ - apple_certs_info.gemspec
32
+ - lib/apple_certs_info.rb
33
+ - lib/apple_certs_info/version.rb
34
+ homepage: https://github.com/tarappo/apple_certs_info
35
+ licenses:
36
+ - MIT
37
+ metadata:
38
+ homepage_uri: https://github.com/tarappo/apple_certs_info
39
+ source_code_uri: https://github.com/tarappo/apple_certs_info
40
+ changelog_uri: https://github.com/tarappo/apple_certs_info/releases
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 2.3.0
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ requirements: []
56
+ rubygems_version: 3.0.3
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: Apple Certificate files and Provisioning Profile information.
60
+ test_files: []