fastlane-plugin-secrets 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 060d33a034c47e7318d5bad3cea1930afa705c920eddbbfb0ea9dd583e872e50
4
+ data.tar.gz: 7d65b0c138410241701d532f39fa9ea761cf72b1f25fefb1cdd5ab4f258b5e56
5
+ SHA512:
6
+ metadata.gz: 2dc780c0f767a55d764f189157f381a54b1a22d371d045aebaf38f7b086ec9e19164ebaed37b360419800a7fe27997dc5f8042e6e2aaec09a8f7c5bd3943e2e0
7
+ data.tar.gz: 0a0adc5e09eb7b419d443911f65031d18e8d0b041371b1c5525f076d72f839e143813de2d63d01b60ca67563c68294f9d1ec08d10984ae615c9115746e8346c5
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Cyril Cermak, Jörg Nestele
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,52 @@
1
+ # secrets plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-secrets)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-secrets`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin secrets
11
+ ```
12
+
13
+ ## About secrets
14
+
15
+ Securely store secrets in source code.
16
+
17
+ **Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
18
+
19
+ ## Example
20
+
21
+ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
22
+
23
+ **Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
24
+
25
+ ## Run tests for this plugin
26
+
27
+ To run both the tests, and code style validation, run
28
+
29
+ ```
30
+ rake
31
+ ```
32
+
33
+ To automatically fix many of the styling issues, use
34
+ ```
35
+ rubocop -a
36
+ ```
37
+
38
+ ## Issues and Feedback
39
+
40
+ For any other issues and feedback about this plugin, please submit it to this repository.
41
+
42
+ ## Troubleshooting
43
+
44
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
45
+
46
+ ## Using _fastlane_ Plugins
47
+
48
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
49
+
50
+ ## About _fastlane_
51
+
52
+ _fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/secrets/version'
2
+
3
+ module Fastlane
4
+ module Secrets
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::Secrets.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,85 @@
1
+ require 'fastlane/action'
2
+ require 'mobile-secrets'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class DecryptSecretsAction < Action
7
+ def self.run(params)
8
+ secrets_path = params[:file_path]
9
+ password = params[:password]
10
+ empty = params[:empty]
11
+ private_key_path = params[:private_key_path]
12
+ target_path = "#{Dir.pwd}/#{params[:target_path]}/secrets.swift"
13
+ tmp_decrypted_secrets_file = "/tmp/secrets"
14
+ secrets_handler = MobileSecrets::SecretsHandler.new
15
+
16
+ return secrets_handler.inject_secrets [[]], target_path if empty
17
+
18
+
19
+ clean tmp_decrypted_secrets_file
20
+ if private_key_path && password
21
+ sh("gpg", "-v", "--pinentry-mode", "loopback", "--passphrase", password, "--import", private_key_path)
22
+ sh("gpg", "-a", "--pinentry-mode", "loopback", "--passphrase", password, "--output", tmp_decrypted_secrets_file, "--decrypt", secrets_path)
23
+ elsif password then
24
+ sh("gpg", "-a", "--pinentry-mode", "loopback", "--passphrase", password, "--output", tmp_decrypted_secrets_file, "--decrypt", secrets_path)
25
+ else
26
+ sh("gpg", "--output", tmp_decrypted_secrets_file, "--decrypt", secrets_path)
27
+ end
28
+
29
+ yml_config = File.read tmp_decrypted_secrets_file
30
+ bytes = secrets_handler.process_yaml_config yml_config
31
+ secrets_handler.inject_secrets bytes, target_path
32
+ clean tmp_decrypted_secrets_file
33
+ end
34
+
35
+ def self.description
36
+ "Securely store secrets in source code"
37
+ end
38
+
39
+ def self.authors
40
+ ["Cyril Cermak, Jörg Nestele"]
41
+ end
42
+
43
+ def self.details
44
+ # Optional:
45
+ ""
46
+ end
47
+
48
+ def self.clean file_path
49
+ File.delete(file_path) if File.exist?(file_path)
50
+ end
51
+
52
+ def self.available_options
53
+ [
54
+ FastlaneCore::ConfigItem.new(key: :file_path,
55
+ description: "Path to the encrypted secrets file",
56
+ is_string: true),
57
+ FastlaneCore::ConfigItem.new(key: :target_path,
58
+ description: "Output path for the auto generated source file",
59
+ is_string: true),
60
+ FastlaneCore::ConfigItem.new(key: :password,
61
+ description: "Password to open the GPG secrets file",
62
+ is_string: true,
63
+ optional: true),
64
+ FastlaneCore::ConfigItem.new(key: :private_key_path,
65
+ description: "Path to a private key for GPG",
66
+ is_string: true,
67
+ optional: true),
68
+ FastlaneCore::ConfigItem.new(key: :empty,
69
+ description: "Path to a private key for GPG",
70
+ type: Boolean,
71
+ optional: true,
72
+ default_value: false)
73
+ ]
74
+ end
75
+
76
+ def self.is_supported?(platform)
77
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
78
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
79
+ #
80
+ # [:ios, :mac, :android].include?(platform)
81
+ [:ios, :mac].include?(platform)
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,62 @@
1
+ require 'fastlane/action'
2
+ require 'mobile-secrets'
3
+ require 'yaml'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ class EncryptSecretsAction < Action
8
+ def self.run(params)
9
+ hash_key = params[:hash_key]
10
+ language = params[:language]
11
+ secrets_dir_path = params[:secrets_dir_path]
12
+ secrets_dict = params[:secrets]
13
+ config_yml = {"MobileSecrets" => {"hashKey"=>hash_key,"language"=>language, "secrets"=>secrets_dict}}.to_yaml
14
+
15
+ MobileSecrets::SecretsHandler.new.encrypt "#{secrets_dir_path}/secrets.gpg", config_yml, secrets_dir_path
16
+ end
17
+
18
+ def self.description
19
+ "Securely store secrets in source code"
20
+ end
21
+
22
+ def self.authors
23
+ ["Cyril Cermak, Jörg Nestele"]
24
+ end
25
+
26
+ def self.details
27
+ # Optional:
28
+ ""
29
+ end
30
+
31
+ def self.clean file_path
32
+ File.delete(file_path) if File.exist?(file_path)
33
+ end
34
+
35
+ def self.available_options
36
+ [
37
+ FastlaneCore::ConfigItem.new(key: :hash_key,
38
+ description: "Key that will be used to hash the secrets using XOR technique",
39
+ is_string: true),
40
+ FastlaneCore::ConfigItem.new(key: :language,
41
+ description: "Source code language, currently supported - [swift]",
42
+ is_string: true),
43
+ FastlaneCore::ConfigItem.new(key: :secrets_dir_path,
44
+ description: "Path to a directory where .gpg was initialized",
45
+ is_string: true),
46
+ FastlaneCore::ConfigItem.new(key: :secrets,
47
+ description: "Key-value dictionary of secrets",
48
+ type: Hash,
49
+ optional: true)
50
+ ]
51
+ end
52
+
53
+ def self.is_supported?(platform)
54
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
55
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
56
+ #
57
+ # [:ios, :mac, :android].include?(platform)
58
+ [:ios, :mac].include?(platform)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,28 @@
1
+ //
2
+ // Autogenerated file by Fastlane-Plugin-Secret
3
+ //
4
+
5
+ import Foundation
6
+
7
+ class Secrets {
8
+ static let standard = Secrets()
9
+ /* SECRET BYTES */
10
+
11
+ private init() {}
12
+
13
+ func string(forKey key: String) -> String? {
14
+ guard let index = bytes.index(where: { String(data: Data(bytes:$0), encoding: .utf8) == key }),
15
+ let value = decrypt(bytes[index + 1]) else { return nil }
16
+ return String(data: Data(bytes: value), encoding: .utf8)
17
+ }
18
+
19
+ private func decrypt(_ input: [UInt8]) -> [UInt8]? {
20
+ let key = bytes[0]
21
+ guard !key.isEmpty else { return nil }
22
+ var output = [UInt8]()
23
+ for byte in input.enumerated() {
24
+ output.append(byte.element ^ key[byte.offset % key.count])
25
+ }
26
+ return output
27
+ }
28
+ }
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Secrets
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,190 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-secrets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Cyril Cermak
8
+ - Jörg Nestele
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2019-10-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mobile-secrets
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '='
19
+ - !ruby/object:Gem::Version
20
+ version: 0.0.5
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '='
26
+ - !ruby/object:Gem::Version
27
+ version: 0.0.5
28
+ - !ruby/object:Gem::Dependency
29
+ name: pry
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec_junit_formatter
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rake
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: rubocop
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '='
103
+ - !ruby/object:Gem::Version
104
+ version: 0.49.1
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '='
110
+ - !ruby/object:Gem::Version
111
+ version: 0.49.1
112
+ - !ruby/object:Gem::Dependency
113
+ name: rubocop-require_tools
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: simplecov
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ - !ruby/object:Gem::Dependency
141
+ name: fastlane
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: 2.131.0
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: 2.131.0
154
+ description:
155
+ email:
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - LICENSE
161
+ - README.md
162
+ - lib/fastlane/plugin/secrets.rb
163
+ - lib/fastlane/plugin/secrets/actions/decrypt_secrets_action.rb
164
+ - lib/fastlane/plugin/secrets/actions/encrypt_secrets_action.rb
165
+ - lib/fastlane/plugin/secrets/helper/SecretsTemplate.swift
166
+ - lib/fastlane/plugin/secrets/version.rb
167
+ homepage: https://github.com/nestele/fastlane-plugin-secrets
168
+ licenses:
169
+ - MIT
170
+ metadata: {}
171
+ post_install_message:
172
+ rdoc_options: []
173
+ require_paths:
174
+ - lib
175
+ required_ruby_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ required_rubygems_version: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ version: '0'
185
+ requirements: []
186
+ rubygems_version: 3.0.6
187
+ signing_key:
188
+ specification_version: 4
189
+ summary: Securely store secrets in source code.
190
+ test_files: []