security 0.1.4 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0980117aec9bb1d85ec00fefc9ea234d0f66b7b80d3932e6f90c99d606ed6e96'
4
- data.tar.gz: 0f49377f8092f1170da75ffda17f65c0213f77bdc1ed371c6993f4b016b4ca9d
3
+ metadata.gz: d010aca28c455caae65e0063ab5ee35336eace64fd8049012c66f77edc634f20
4
+ data.tar.gz: a46b316771d171579e241b7c875b99bdaaa0f0cc6e7f9312d1627767b90c3c9e
5
5
  SHA512:
6
- metadata.gz: 5899c11de7a95d4babea7edfcdaaa469dbbec27edd2f746afbc276bda596c54f17641db99aed2e362acac66b842c313b29b2345526d4eb8edba228f61d2486f0
7
- data.tar.gz: '08f05552094356cdbe5841deee2316f4ba7ab080026b4a7a77771ae00ae9f7c0920cc9a4946f1bb8c8d4b1523237e4131041a331c69c44f7a0fab32402b44a62'
6
+ metadata.gz: 106ba3c86bc5254bd1d589d1de99ea992b4cb12731761ff79faeed1cbe48f495451520b6ebbf91c50f6fb41b838ecd01de11eec9ca08d97e39c853cc457844e5
7
+ data.tar.gz: 636bfaf6e7a5b88eb38112008d3a46ed13da71cd13e8e16bb9891a24b5fbd8fca85dd58017f505d1c0df45264a1be3773f9bf15e973b688f0069135463407cf6
data/Gemfile CHANGED
@@ -1,3 +1,10 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'rake', '~> 13.4'
6
+ gem 'rspec'
7
+ gem 'rubocop'
8
+ gem 'simplecov'
2
9
 
3
10
  gemspec
data/Gemfile.lock CHANGED
@@ -1,19 +1,68 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- security (0.1.4)
4
+ security (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- rake (12.3.3)
9
+ ast (2.4.3)
10
+ diff-lcs (1.6.2)
11
+ json (2.21.2)
12
+ language_server-protocol (3.17.0.6)
13
+ lint_roller (1.1.0)
14
+ parallel (2.1.0)
15
+ parser (3.3.12.0)
16
+ ast (~> 2.4.1)
17
+ racc
18
+ prism (1.9.0)
19
+ racc (1.8.1)
20
+ rainbow (3.1.1)
21
+ rake (13.4.2)
22
+ regexp_parser (2.12.0)
23
+ rspec (3.13.2)
24
+ rspec-core (~> 3.13.0)
25
+ rspec-expectations (~> 3.13.0)
26
+ rspec-mocks (~> 3.13.0)
27
+ rspec-core (3.13.6)
28
+ rspec-support (~> 3.13.0)
29
+ rspec-expectations (3.13.5)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.13.0)
32
+ rspec-mocks (3.13.8)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.13.0)
35
+ rspec-support (3.13.7)
36
+ rubocop (1.89.0)
37
+ json (~> 2.3)
38
+ language_server-protocol (~> 3.17.0.2)
39
+ lint_roller (~> 1.1.0)
40
+ parallel (>= 1.10)
41
+ parser (>= 3.3.0.2)
42
+ rainbow (>= 2.2.2, < 4.0)
43
+ regexp_parser (>= 2.9.3, < 3.0)
44
+ rubocop-ast (>= 1.49.0, < 2.0)
45
+ ruby-progressbar (~> 1.7)
46
+ unicode-display_width (>= 2.4.0, < 4.0)
47
+ rubocop-ast (1.50.0)
48
+ parser (>= 3.3.7.2)
49
+ prism (~> 1.7)
50
+ ruby-progressbar (1.13.0)
51
+ simplecov (1.1.1)
52
+ unicode-display_width (3.2.0)
53
+ unicode-emoji (~> 4.1)
54
+ unicode-emoji (4.2.0)
10
55
 
11
56
  PLATFORMS
12
57
  ruby
58
+ x86_64-linux
13
59
 
14
60
  DEPENDENCIES
15
- rake (~> 12.3, >= 12.3.3)
61
+ rake (~> 13.4)
62
+ rspec
63
+ rubocop
16
64
  security!
65
+ simplecov
17
66
 
18
67
  BUNDLED WITH
19
- 2.1.4
68
+ 2.6.9
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 – 2021 Mattt (https://mat.tt/)
1
+ Copyright (c) 2012 – 2021 The Fastlane Community Contributors
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,14 +1,19 @@
1
1
  # Security
2
2
 
3
+ [![Build Status][build status badge]][build status]
4
+ [![Gem](https://img.shields.io/gem/v/security.svg?style=flat)](https://rubygems.org/gems/security)
5
+ [![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/fastlane-community/security/blob/main/LICENSE.md)
6
+
3
7
  **A library for interacting with the macOS Keychain**
4
8
 
5
- > This library implements only the commands necessary for password management in
6
- > [Cupertino](https://github.com/mattt/cupertino).
7
- > As such, some methods are stubbed out to raise `NotImplementedError`.
9
+ > This library provides only a subset of `security` subcommands,
10
+ > and is not intended for general use.
8
11
 
9
12
  ## Usage
10
13
 
11
14
  ```ruby
15
+ require 'security'
16
+
12
17
  Security::Keychain::default_keychain.filename #=> "/Users/jappleseed/Library/Keychains/login.keychain"
13
18
 
14
19
  Security::InternetPassword.find(server: "itunesconnect.apple.com").password #=> "p4ssw0rd"
@@ -18,6 +23,5 @@ Security::InternetPassword.find(server: "itunesconnect.apple.com").password #=>
18
23
 
19
24
  MIT
20
25
 
21
- ## Contact
22
-
23
- Mattt ([@mattt](https://twitter.com/mattt))
26
+ [build status]: https://github.com/mattt/Security/actions?query=workflow%3ACI
27
+ [build status badge]: https://github.com/mattt/Security/workflows/CI/badge.svg
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
- require "bundler"
2
- Bundler.setup
1
+ # frozen_string_literal: true
3
2
 
4
- gemspec = eval(File.read("security.gemspec"))
3
+ require 'bundler'
4
+ Bundler.setup
5
5
 
6
- task :build => "#{gemspec.full_name}.gem"
6
+ require 'bundler/gem_tasks'
7
7
 
8
- file "#{gemspec.full_name}.gem" => gemspec.files + ["security.gemspec"] do
9
- system "gem build security.gemspec"
8
+ task :default do
9
+ system 'rake -T'
10
10
  end
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Security
4
+ # :nodoc:
2
5
  class Certificate
3
6
  private_class_method :new
4
7
 
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'shellwords'
2
4
 
3
5
  module Security
6
+ # :nodoc:
4
7
  class Keychain
5
- DOMAINS = [:user, :system, :common, :dynamic]
8
+ DOMAINS = %i[user system common dynamic].freeze
6
9
 
7
10
  attr_reader :filename
8
11
 
@@ -11,19 +14,19 @@ module Security
11
14
  end
12
15
 
13
16
  def info
14
- system %{security show-keychain-info #{@filename.shellescape}}
17
+ system %(security show-keychain-info #{@filename.shellescape})
15
18
  end
16
19
 
17
20
  def lock
18
- system %{security lock-keychain #{@filename.shellescape}}
21
+ system %(security lock-keychain #{@filename.shellescape})
19
22
  end
20
23
 
21
24
  def unlock(password)
22
- system %{security unlock-keychain -p #{password.shellescape} #{@filename.shellescape}}
25
+ system %(security unlock-keychain -p #{password.shellescape} #{@filename.shellescape})
23
26
  end
24
27
 
25
28
  def delete
26
- system %{security delete-keychain #{@filename.shellescape}}
29
+ system %(security delete-keychain #{@filename.shellescape})
27
30
  end
28
31
 
29
32
  class << self
@@ -38,11 +41,11 @@ module Security
38
41
  end
39
42
 
40
43
  def lock
41
- system %{security lock-keychain -a}
44
+ system %(security lock-keychain -a)
42
45
  end
43
46
 
44
47
  def unlock(password)
45
- system %{security unlock-keychain -p #{password.shellescape}}
48
+ system %(security unlock-keychain -p #{password.shellescape})
46
49
  end
47
50
 
48
51
  def default_keychain
@@ -56,7 +59,7 @@ module Security
56
59
  private
57
60
 
58
61
  def keychains_from_output(output)
59
- output.split(/\n/).collect{|line| new(line.strip.gsub(/^\"|\"$/, ""))}
62
+ output.split("\n").collect { |line| new(line.strip.gsub(/^"|"$/, '')) }
60
63
  end
61
64
  end
62
65
  end
@@ -1,6 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'shellwords'
2
4
 
3
5
  module Security
6
+ # :nodoc:
4
7
  class Password
5
8
  attr_reader :keychain, :attributes, :password
6
9
 
@@ -16,17 +19,23 @@ module Security
16
19
  private
17
20
 
18
21
  def password_from_output(output)
19
- return nil if /^security\: / === output
22
+ return nil if output.match?(/^security: /)
20
23
 
21
- keychain, attributes, password = nil, {}, nil
22
- output.split(/\n/).each do |line|
24
+ keychain = nil
25
+ attributes = {}
26
+ password = nil
27
+ output.split("\n").each do |line|
23
28
  case line
24
- when /^keychain\: \"(.+)\"/
25
- keychain = $1
26
- when /\"(\w{4})\".+\=\"(.+)\"/
27
- attributes[$1] = $2
28
- when /^password\: \"(.+)\"/
29
- password = $1
29
+ when /^keychain: "(.+)"/
30
+ keychain = Regexp.last_match(1)
31
+ when /"(\w{4})".+="(.+)"/
32
+ attributes[Regexp.last_match(1)] = Regexp.last_match(2)
33
+ when /"(\w{4})"<blob>=0x([[:xdigit:]]+)/
34
+ attributes[Regexp.last_match(1)] = decode_hex_blob(Regexp.last_match(2))
35
+ when /^password: "(.+)"/
36
+ password = Regexp.last_match(1)
37
+ when /^password: 0x([[:xdigit:]]+)/
38
+ password = decode_hex_blob(Regexp.last_match(1))
30
39
  end
31
40
  end
32
41
 
@@ -42,11 +51,16 @@ module Security
42
51
  flags[:G] ||= flags.delete(:value)
43
52
  flags[:j] ||= flags.delete(:comment)
44
53
 
45
- flags.delete_if{|k,v| v.nil?}.collect{|k, v| "-#{k} #{v.shellescape}".strip}.join(" ")
54
+ flags.delete_if { |_k, v| v.nil? }.collect { |k, v| "-#{k} #{v.shellescape}".strip }.join(' ')
55
+ end
56
+
57
+ def decode_hex_blob(string)
58
+ [string].pack('H*').force_encoding('UTF-8')
46
59
  end
47
60
  end
48
61
  end
49
62
 
63
+ # :nodoc:
50
64
  class GenericPassword < Password
51
65
  class << self
52
66
  def add(service, account, password, options = {})
@@ -69,11 +83,12 @@ module Security
69
83
 
70
84
  def flags_for_options(options = {})
71
85
  options[:s] ||= options.delete(:service)
72
- super(options)
86
+ super
73
87
  end
74
88
  end
75
89
  end
76
90
 
91
+ # :nodoc:
77
92
  class InternetPassword < Password
78
93
  class << self
79
94
  def add(server, account, password, options = {})
@@ -99,7 +114,7 @@ module Security
99
114
  options[:p] ||= options.delete(:path)
100
115
  options[:P] ||= options.delete(:port)
101
116
  options[:r] ||= options.delete(:protocol)
102
- super(options)
117
+ super
103
118
  end
104
119
  end
105
120
  end
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
1
4
  module Security
2
- VERSION = "0.1.4"
5
+ VERSION = '0.2.0'
3
6
  end
data/lib/security.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'security/version'
2
4
  require 'security/keychain'
3
5
  require 'security/certificate'
data/security.gemspec CHANGED
@@ -1,21 +1,21 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "security"
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/security/version'
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = "security"
7
- s.authors = ["Mattt"]
8
- s.email = "mattt@me.com"
9
- s.homepage = "https://mat.tt/"
6
+ s.name = 'security'
7
+ s.authors = ['Josh Holtz', 'Mattt', 'iBotPeaches']
8
+ s.email = 'me@joshholtz.com'
9
+ s.homepage = 'https://github.com/fastlane-community/security'
10
10
  s.version = Security::VERSION
11
11
  s.platform = Gem::Platform::RUBY
12
- s.license = "MIT"
13
- s.summary = "Interact with the macOS Keychain"
12
+ s.license = 'MIT'
13
+ s.summary = 'Interact with the macOS Keychain'
14
14
 
15
- s.add_development_dependency 'rake', '~> 12.3', '>= 12.3.3'
15
+ s.files = Dir['./**/*'].grep_v(%r{\./(bin|log|pkg|script|spec|test|vendor)})
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
17
+ s.require_paths = ['lib']
18
+ s.required_ruby_version = '>= 3.0.0'
16
19
 
17
- s.files = Dir["./**/*"].reject { |file| file =~ /\.\/(bin|log|pkg|script|spec|test|vendor)/ }
18
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
- s.require_paths = ["lib"]
20
+ s.metadata['rubygems_mfa_required'] = 'true'
21
21
  end
metadata CHANGED
@@ -1,37 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: security
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
+ - Josh Holtz
7
8
  - Mattt
8
- autorequire:
9
+ - iBotPeaches
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2021-03-02 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rake
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '12.3'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 12.3.3
23
- type: :development
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '12.3'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 12.3.3
33
- description:
34
- email: mattt@me.com
12
+ date: 1980-01-02 00:00:00.000000000 Z
13
+ dependencies: []
14
+ email: me@joshholtz.com
35
15
  executables: []
36
16
  extensions: []
37
17
  extra_rdoc_files: []
@@ -46,13 +26,12 @@ files:
46
26
  - "./lib/security/keychain.rb"
47
27
  - "./lib/security/password.rb"
48
28
  - "./lib/security/version.rb"
49
- - "./security-0.1.3.gem"
50
29
  - "./security.gemspec"
51
- homepage: https://mat.tt/
30
+ homepage: https://github.com/fastlane-community/security
52
31
  licenses:
53
32
  - MIT
54
- metadata: {}
55
- post_install_message:
33
+ metadata:
34
+ rubygems_mfa_required: 'true'
56
35
  rdoc_options: []
57
36
  require_paths:
58
37
  - lib
@@ -60,15 +39,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
39
  requirements:
61
40
  - - ">="
62
41
  - !ruby/object:Gem::Version
63
- version: '0'
42
+ version: 3.0.0
64
43
  required_rubygems_version: !ruby/object:Gem::Requirement
65
44
  requirements:
66
45
  - - ">="
67
46
  - !ruby/object:Gem::Version
68
47
  version: '0'
69
48
  requirements: []
70
- rubygems_version: 3.1.2
71
- signing_key:
49
+ rubygems_version: 3.6.9
72
50
  specification_version: 4
73
51
  summary: Interact with the macOS Keychain
74
52
  test_files: []
data/security-0.1.3.gem DELETED
Binary file