apple_certs_cleaner 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c97fada1ee4e7f3f260642966a159abc8c98912a9bec5d783cbb30d8eff5e04c
4
+ data.tar.gz: 63eaaaee5528a7f05c327f9a43968ad8e97736b0086e9a2b9190d8d0daa70800
5
+ SHA512:
6
+ metadata.gz: 8d2a2528984b1bcc3d375d059b614630ed353eb45514f5a1944972b34c642a55271db88329ddb6248171c74b042b2ebd02604cdf99437e17269ed1dc870bae60
7
+ data.tar.gz: 9514757c26f591c79acd0604a89f54883652628e162191998cb6319132f9b9b9b4cddd5e91da97f6bfc33bccdb23e7117845f2031b3e95232b1b1ee7e67e37b6
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
@@ -0,0 +1,46 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ChangeListManager">
4
+ <list default="true" id="bad0e46d-329b-4e98-9555-178826c9a104" name="Default Changelist" comment="">
5
+ <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
6
+ <change beforePath="$PROJECT_DIR$/spec/apple_certs_cleaner_spec.rb" beforeDir="false" afterPath="$PROJECT_DIR$/spec/apple_certs_cleaner_spec.rb" afterDir="false" />
7
+ </list>
8
+ <option name="SHOW_DIALOG" value="false" />
9
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
10
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
11
+ <option name="LAST_RESOLUTION" value="IGNORE" />
12
+ </component>
13
+ <component name="Git.Settings">
14
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
15
+ </component>
16
+ <component name="ProjectId" id="1ooe3ebKYqD5vREFtY43Sr6eSQF" />
17
+ <component name="ProjectViewState">
18
+ <option name="hideEmptyMiddlePackages" value="true" />
19
+ <option name="showLibraryContents" value="true" />
20
+ </component>
21
+ <component name="PropertiesComponent">
22
+ <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
23
+ <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
24
+ <property name="WebServerToolWindowFactoryState" value="false" />
25
+ <property name="last_opened_file_path" value="$PROJECT_DIR$" />
26
+ </component>
27
+ <component name="SpringUtil" SPRING_PRE_LOADER_OPTION="true" RAKE_SPRING_PRE_LOADER_OPTION="true" RAILS_SPRING_PRE_LOADER_OPTION="true" />
28
+ <component name="SvnConfiguration">
29
+ <configuration />
30
+ </component>
31
+ <component name="TaskManager">
32
+ <task active="true" id="Default" summary="Default task">
33
+ <changelist id="bad0e46d-329b-4e98-9555-178826c9a104" name="Default Changelist" comment="" />
34
+ <created>1613957172072</created>
35
+ <option name="number" value="Default" />
36
+ <option name="presentableId" value="Default" />
37
+ <updated>1613957172072</updated>
38
+ <workItem from="1613957173552" duration="162000" />
39
+ <workItem from="1613957351508" duration="6645000" />
40
+ </task>
41
+ <servers />
42
+ </component>
43
+ <component name="TypeScriptGeneratedFilesManager">
44
+ <option name="version" value="2" />
45
+ </component>
46
+ </project>
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -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 tarappo@gmail.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,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in apple_certs_cleaner.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
8
+ gem "apple_certs_info"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
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
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.
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # AppleCertsCleaner
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/apple_certs_cleaner`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'apple_certs_cleaner'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install apple_certs_cleaner
22
+
23
+ ## Usage
24
+
25
+ ```
26
+ # remove duplicate certificate file
27
+ AppleCertsCleaner.remove_duplicate_certificate
28
+
29
+ # remove expired files
30
+ AppleCertsCleaner.remove_expired_certificate
31
+ AppleCertsCleaner.remove_expired_provisioning_profile
32
+
33
+ # remove invalid(revoked) certificate file
34
+ AppleCertsCleaner.remove_invalid_certificate
35
+ ```
36
+
37
+ ## Development
38
+
39
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
40
+
41
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
+
43
+ ## Contributing
44
+
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/apple_certs_cleaner. 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_cleaner/blob/master/CODE_OF_CONDUCT.md).
46
+
47
+
48
+ ## License
49
+
50
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
51
+
52
+ ## Code of Conduct
53
+
54
+ Everyone interacting in the AppleCertsCleaner project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/apple_certs_cleaner/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -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_cleaner/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "apple_certs_cleaner"
5
+ spec.version = AppleCertsCleaner::VERSION
6
+ spec.authors = ["tarappo"]
7
+ spec.email = ["tarappo@gmail.com"]
8
+
9
+ spec.summary = %q{clean Apple Certificate files and Provisioning Profile.}
10
+ spec.homepage = "https://github.com/tarappo/apple_certs_cleaner"
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = "https://github.com/tarappo/apple_certs_cleaner"
16
+ spec.metadata["changelog_uri"] = "https://github.com/tarappo/apple_certs_cleaner/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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "apple_certs_cleaner"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,83 @@
1
+ require "apple_certs_info"
2
+ require "apple_certs_cleaner/version"
3
+
4
+ module AppleCertsCleaner
5
+
6
+ # Remove duplicate Certificate files
7
+ # note: remove first data
8
+ def self.remove_duplicate_certificate
9
+ list = []
10
+
11
+ dist_list = AppleCertsInfo.certificate_distribution_list
12
+ develop_list = AppleCertsInfo.certificate_development_list
13
+ list.concat(dist_list) unless dist_list.nil?
14
+ list.concat(develop_list) unless develop_list.nil?
15
+
16
+ duplicate_cname = list.group_by{ |e| e[:cname] }.select { |k, v| v.size > 1 }.map(&:first)
17
+ duplicate_cname.each do |cname|
18
+ delete_first_match_keychain(name: cname)
19
+ end
20
+ end
21
+
22
+ # Remove expired Certificate files
23
+ def self.remove_expired_certificate
24
+ list = []
25
+
26
+ dist_list = AppleCertsInfo.certificate_distribution_list
27
+ develop_list = AppleCertsInfo.certificate_development_list
28
+ list.concat(dist_list) unless dist_list.nil?
29
+ list.concat(develop_list) unless develop_list.nil?
30
+
31
+ list.each do |certificate|
32
+ puts certificate
33
+
34
+ if certificate[:limit_days].to_i < 0
35
+ puts "Delete Provisioning Profile: #{certificate[:cname]}(expired: #{certificate[:limit_days]})"
36
+ delete_first_match_keychain(name: certificate[:cname])
37
+ end
38
+ end
39
+ end
40
+
41
+ # Remove expired Provisioning Profile
42
+ def self.remove_expired_provisioning_profile
43
+ list = AppleCertsInfo.provisioning_profile_list
44
+
45
+ list.each do |pp_file|
46
+ next if pp_file[:file_path].nil?
47
+
48
+ if pp_file[:limit_days].to_i < 0
49
+ puts "Delete Provisioning Profile: #{pp_file[:app_id_name]}(expired: #{pp_file[:limit_days]})"
50
+ File.delete(pp_file[:file_path])
51
+ end
52
+ end
53
+ end
54
+
55
+ # Remove revoked Certificate files
56
+ def self.remove_invalid_certificate
57
+ result = `security find-identity -v -p codesigning`
58
+ invalid_cert_sha1 = result.scan(/[0-9]+\) ([a-zA-Z0-9]+) \".*\" .*CSSMERR_TP_CERT_REVOKED.*/)
59
+
60
+ invalid_cert_sha1.each do |sha1|
61
+ delete_keychain_for(sha1: sha1.first)
62
+ end
63
+ end
64
+
65
+ private
66
+ # delete keychain using sha1
67
+ def self.delete_keychain_for(sha1:)
68
+ result = `security delete-certificate -Z #{sha1}`
69
+ end
70
+
71
+ # delete keychain using name
72
+ def self.delete_first_match_keychain(name:)
73
+ result = `security find-certificate -a -c "#{name}" -Z`
74
+ sha_match = result.match(/SHA-1 hash: (.*)/)
75
+ keychain_path = result.match(/keychain: (.*)/)
76
+ raise "not exits sha-1" if sha_match.nil?
77
+ raise "not exits keychain_path" if keychain_path.nil?
78
+ sha1 = sha_match[1]
79
+ puts "Delete #{name} / SHA-1: #{sha1}"
80
+
81
+ result = `security delete-certificate -Z #{sha1} #{keychain_path[1]}`
82
+ end
83
+ end
@@ -0,0 +1,3 @@
1
+ module AppleCertsCleaner
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: apple_certs_cleaner
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - tarappo
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-02-22 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - tarappo@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".idea/workspace.xml"
22
+ - ".rspec"
23
+ - CODE_OF_CONDUCT.md
24
+ - Gemfile
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - apple_certs_cleaner.gemspec
29
+ - bin/console
30
+ - bin/setup
31
+ - lib/apple_certs_cleaner.rb
32
+ - lib/apple_certs_cleaner/version.rb
33
+ homepage: https://github.com/tarappo/apple_certs_cleaner
34
+ licenses:
35
+ - MIT
36
+ metadata:
37
+ homepage_uri: https://github.com/tarappo/apple_certs_cleaner
38
+ source_code_uri: https://github.com/tarappo/apple_certs_cleaner
39
+ changelog_uri: https://github.com/tarappo/apple_certs_cleaner/releases
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 2.5.0
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubygems_version: 3.0.3
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: clean Apple Certificate files and Provisioning Profile.
59
+ test_files: []