fastlane-plugin-bitwarden 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: 280fa5fbc7ea8740435a3562cfd2958ce0407c026df86ce299195db0a17018fb
4
+ data.tar.gz: a30953014a5468f52dc0f59a66a9ff952cb09c5b039727ff5e82210ee5532817
5
+ SHA512:
6
+ metadata.gz: 4bb95ddedacdbfe81b58b75ed307dfca925c5df4b550b260e70e1a91d52e5742ac81bd778f79ea7b397a9e30b5f23d02d7a1bb8ad3953261d952ca6109155eab
7
+ data.tar.gz: 54a8541ff7de99b197f9da192defd330a5b5ac393b2d59649e89ca3774e9ef2f12b5034c3f01a6de1184055e77d0bf608949042a20dd93562099570b6908a1e5
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Ilija Boshkov <ilija@codechem.com>
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,63 @@
1
+ # bitwarden plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-bitwarden)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-bitwarden`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin bitwarden
11
+ ```
12
+
13
+ ## About
14
+
15
+ Bitwarden CLI warpper plugin
16
+
17
+ This plugin is a wrapper around the Bitwarden CLI, it provides very basic functionality to enable quick and easy access to your Bitwarden vault.
18
+
19
+ One nice use-case for a plugin like this is to automate and safely keep app deployment/build secrets like for example Android keystores and such.
20
+
21
+ It needs the [Bitwarden CLI](https://help.bitwarden.com/article/cli/) installed and available somewhere in `$PATH`. This can be overridden by using the `:cli_path` variable in all actions, or the analogous `BW_CLI_PATH` environment variable.
22
+
23
+ By default it uses https://bitwarden.com as the Server URL, can be overriden with `BW_SERVER_URL` for a self-hosted instance.
24
+
25
+ Documentation is **TODO**, see the actions' source and the example `Fastfile` for now.
26
+
27
+ **This plugin is in an early stage of development, any contributions are welcome.**
28
+
29
+ ## Example
30
+ 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`.
31
+
32
+ Make sure to setup the necessary variables or edit the `Fastfile` in order to be able to test everything out.
33
+
34
+ ## Run tests for this plugin
35
+
36
+ Note: The tests are still not done so - **TODO**.
37
+
38
+ To run both the tests, and code style validation, run
39
+
40
+ ```
41
+ rake
42
+ ```
43
+
44
+ To automatically fix many of the styling issues, use
45
+ ```
46
+ rubocop -a
47
+ ```
48
+
49
+ ## Issues and Feedback
50
+
51
+ For any other issues and feedback about this plugin, please submit it to this repository.
52
+
53
+ ## Troubleshooting
54
+
55
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
56
+
57
+ ## Using _fastlane_ Plugins
58
+
59
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
60
+
61
+ ## About _fastlane_
62
+
63
+ _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/bitwarden/version'
2
+
3
+ module Fastlane
4
+ module Bitwarden
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::Bitwarden.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,74 @@
1
+ require_relative '../helper/bitwarden_helper'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ class BitwardenDownloadAttachmentAction < Action
6
+ def self.run(params)
7
+ @helper = Helper::BitwardenHelper.new(params[:cli_path])
8
+ item_id = params[:item_id]
9
+ attachment_id = params[:attachment_id]
10
+ output_path = params[:output_path]
11
+ args = ['get', 'attachment', '--itemid', item_id, attachment_id, '--raw']
12
+ if output_path
13
+ args += ['--output', output_path]
14
+ end
15
+
16
+ @helper.exec(*args)
17
+ end
18
+
19
+ #####################################################
20
+ # @!group Documentation
21
+ #####################################################
22
+
23
+ def self.description
24
+ "You can use this action to download an item's attachment from BitWarden."
25
+ end
26
+
27
+ def self.details
28
+ "You can use this action to download an item's attachment from BitWarden."
29
+ end
30
+
31
+ def self.available_options
32
+ [
33
+ FastlaneCore::ConfigItem.new(key: :cli_path,
34
+ env_name: "BW_CLI_PATH",
35
+ optional: true,
36
+ description: "Override path to the Bitwarden CLI"),
37
+ FastlaneCore::ConfigItem.new(key: :item_id,
38
+ env_name: "BW_ITEM_ID",
39
+ description: "ID of the item the Attachment belongs to",
40
+ verify_block: proc do |value|
41
+ UI.user_error!("No Item ID provided to the Bitwarden Download Attachment Action, pass it like so: `item_id: '<...item_id...>'`") unless value and not value.empty?
42
+ end),
43
+ FastlaneCore::ConfigItem.new(key: :attachment_id,
44
+ env_name: "BW_ATTACHMENT_ID",
45
+ description: "ID of the Attachment to be downloaded",
46
+ verify_block: proc do |value|
47
+ UI.user_error!("No Attachment ID provided to the Bitwarden Download Attachment Action `email: '<...attachment_id...>'`") unless value and not value.empty?
48
+ end),
49
+ FastlaneCore::ConfigItem.new(key: :output_path,
50
+ env_name: "BW_ATTACHMENT_OUTPUT",
51
+ description: "Output path of the Attachment to be downloaded",
52
+ optional: true),
53
+ ]
54
+ end
55
+
56
+ def self.output
57
+ [
58
+ ]
59
+ end
60
+
61
+ def self.return_value
62
+ "The resulting file path"
63
+ end
64
+
65
+ def self.authors
66
+ ["ilija@codechem.com"]
67
+ end
68
+
69
+ def self.is_supported?(platform)
70
+ true
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,81 @@
1
+ require_relative '../helper/bitwarden_helper'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ module SharedValues
6
+ BW_SESSION = :BW_SESSION
7
+ end
8
+
9
+ class BitwardenGetObjectAction < Action
10
+ def self.run(params)
11
+ @helper = Helper::BitwardenHelper.new(params[:cli_path])
12
+ object_type = params[:object_type]
13
+ other_args = params[:args] || {}
14
+ str_args = params[:str_args] || ""
15
+
16
+ args = ['get', object_type]
17
+
18
+ args.push(str_args)
19
+
20
+ other_args.each do |key, value|
21
+ args.push(key.to_s)
22
+ args.push(value)
23
+ end
24
+
25
+ args.push('--raw')
26
+
27
+ @helper.exec(*args)
28
+ end
29
+
30
+ #####################################################
31
+ # @!group Documentation
32
+ #####################################################
33
+
34
+ def self.description
35
+ "You can use this action to download an item's attachment from BitWarden."
36
+ end
37
+
38
+ def self.details
39
+ "You can use this action to download an item's attachment from BitWarden."
40
+ end
41
+
42
+ def self.available_options
43
+ [
44
+ FastlaneCore::ConfigItem.new(key: :cli_path,
45
+ env_name: "BW_CLI_PATH",
46
+ optional: true,
47
+ description: "Override path to the Bitwarden CLI"),
48
+ FastlaneCore::ConfigItem.new(key: :object_type,
49
+ description: "Type of the object to get (collection, item, etc.)",
50
+ verify_block: proc do |value|
51
+ UI.user_error!("No object type provided to the Bitwarden Get Object Action`") unless value && !value.empty?
52
+ end),
53
+ FastlaneCore::ConfigItem.new(key: :args,
54
+ description: "Other arguments (hash)",
55
+ type: Hash,
56
+ optional: true),
57
+ FastlaneCore::ConfigItem.new(key: :str_args,
58
+ description: "Other arguments (string)",
59
+ optional: true)
60
+ ]
61
+ end
62
+
63
+ def self.output
64
+ [
65
+ ]
66
+ end
67
+
68
+ def self.return_value
69
+ "The resulting object"
70
+ end
71
+
72
+ def self.authors
73
+ ["ilija@codechem.com"]
74
+ end
75
+
76
+ def self.is_supported?(platform)
77
+ true
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,86 @@
1
+ module Fastlane
2
+ module Actions
3
+ class BitwardenLoginAction < Action
4
+ def self.ensure_login
5
+ UI.message("Logging in to " + @server_url)
6
+ @helper.exec('config', 'server', @server_url)
7
+ UI.message("Checking login")
8
+ @helper.exec('login', '--check', error_callback: method(:bw_login))
9
+ Actions::BitwardenUnlockVaultAction.run(cli_path: @cli_path, password: @password)
10
+ end
11
+
12
+ def self.bw_login(result)
13
+ session = @helper.exec('login', @email, @password, '--raw')
14
+ Actions.lane_context[SharedValues::BW_SESSION] = session
15
+ end
16
+
17
+ def self.run(params)
18
+ @cli_path = params[:cli_path]
19
+ @server_url = params[:server_url]
20
+ @email = params[:email]
21
+ @password = params[:password]
22
+ @helper = Helper::BitwardenHelper.new(@cli_path)
23
+ self.ensure_login
24
+ end
25
+
26
+ #####################################################
27
+ # @!group Documentation
28
+ #####################################################
29
+
30
+ def self.description
31
+ "You can use this action to login to BitWarden and unlock the vault."
32
+ end
33
+
34
+ def self.details
35
+ "You can use this action to login to BitWarden and unlock the vault."
36
+ end
37
+
38
+ def self.available_options
39
+ [
40
+ FastlaneCore::ConfigItem.new(key: :cli_path,
41
+ env_name: "BW_CLI_PATH",
42
+ optional: true,
43
+ description: "Override path to the Bitwarden CLI"),
44
+
45
+ FastlaneCore::ConfigItem.new(key: :server_url,
46
+ env_name: "BW_SERVER_URL",
47
+ description: "Server URL use when signing in to Bitwarden",
48
+ default_value: "https://bitwarden.com",
49
+ verify_block: proc do |value|
50
+ UI.user_error!("No Server URL provided to the Bitwarden Login Action, pass it like so: `server_url: '<...server_url...>'`") unless value && !value.empty?
51
+ end),
52
+ FastlaneCore::ConfigItem.new(key: :email,
53
+ env_name: "BW_EMAIL",
54
+ description: "Email to use when signing in to Bitwarden",
55
+ verify_block: proc do |value|
56
+ UI.user_error!("No Email provided to the Bitwarden Login Action, pass it like so: `email: '<...email...>'`") unless value && !value.empty?
57
+ end),
58
+ FastlaneCore::ConfigItem.new(key: :password,
59
+ env_name: "BW_PASSWORD",
60
+ description: "Master Password to use when signing in to Bitwarden",
61
+ verify_block: proc do |value|
62
+ UI.user_error!("No Password provided to the Bitwarden Login Action `email: '<...email...>'`") unless value && !value.empty?
63
+ end)
64
+ ]
65
+ end
66
+
67
+ def self.output
68
+ [
69
+ ['BW_SESSION', 'The session token that Bitwarden returns']
70
+ ]
71
+ end
72
+
73
+ def self.return_value
74
+ "The BW_SESSION token"
75
+ end
76
+
77
+ def self.authors
78
+ ["ilija@codechem.com"]
79
+ end
80
+
81
+ def self.is_supported?(platform)
82
+ true
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,60 @@
1
+ module Fastlane
2
+ module Actions
3
+ class BitwardenUnlockVaultAction < Action
4
+ def self.run(params)
5
+ @helper = Helper::BitwardenHelper.new(params[:cli_path])
6
+ password = params[:password]
7
+
8
+ UI.message("Unlocking vault...")
9
+
10
+ session = @helper.exec('unlock', password, '--raw')
11
+ Actions.lane_context[SharedValues::BW_SESSION] = session
12
+ end
13
+
14
+ #####################################################
15
+ # @!group Documentation
16
+ #####################################################
17
+
18
+ def self.description
19
+ "You can use this action to download an item's attachment from BitWarden."
20
+ end
21
+
22
+ def self.details
23
+ "You can use this action to download an item's attachment from BitWarden."
24
+ end
25
+
26
+ def self.available_options
27
+ [
28
+ FastlaneCore::ConfigItem.new(key: :cli_path,
29
+ env_name: "BW_CLI_PATH",
30
+ optional: true,
31
+ description: "Override path to the Bitwarden CLI"),
32
+ FastlaneCore::ConfigItem.new(key: :password,
33
+ env_name: "BW_PASSWORD",
34
+ description: "Master Password to use when signing in to Bitwarden",
35
+ verify_block: proc do |value|
36
+ UI.user_error!("No Password provided to the Bitwarden Login Action `email: '<...email...>'`") unless value && !value.empty?
37
+ end)
38
+ ]
39
+ end
40
+
41
+ def self.output
42
+ [
43
+ ['BW_SESSION', 'The session token that Bitwarden returns']
44
+ ]
45
+ end
46
+
47
+ def self.return_value
48
+ "The BW_SESSION token"
49
+ end
50
+
51
+ def self.authors
52
+ ["ilija@codechem.com"]
53
+ end
54
+
55
+ def self.is_supported?(platform)
56
+ true
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,21 @@
1
+ require 'fastlane_core/ui/ui'
2
+
3
+ module Fastlane
4
+ UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
5
+
6
+ module Helper
7
+ class BitwardenHelper
8
+ def initialize(cli_path)
9
+ @cli_path = cli_path || "bw"
10
+ end
11
+
12
+ def exec(*command, log: false, error_callback: nil)
13
+ ENV['BW_SESSION'] = Actions.lane_context[Actions::SharedValues::BW_SESSION]
14
+ command.insert(0, @cli_path)
15
+ res = Fastlane::Actions::sh(*command, log: log, error_callback: error_callback)
16
+ ENV.delete('BW_SESSION')
17
+ res
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Bitwarden
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,177 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-bitwarden
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ilija Boshkov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-12-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec_junit_formatter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.49.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.49.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-require_tools
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: fastlane
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 2.137.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: 2.137.0
139
+ description:
140
+ email: ilija@codechem.com
141
+ executables: []
142
+ extensions: []
143
+ extra_rdoc_files: []
144
+ files:
145
+ - LICENSE
146
+ - README.md
147
+ - lib/fastlane/plugin/bitwarden.rb
148
+ - lib/fastlane/plugin/bitwarden/actions/bitwarden_download_attachment.rb
149
+ - lib/fastlane/plugin/bitwarden/actions/bitwarden_get_object.rb
150
+ - lib/fastlane/plugin/bitwarden/actions/bitwarden_login.rb
151
+ - lib/fastlane/plugin/bitwarden/actions/bitwarden_unlock_vault.rb
152
+ - lib/fastlane/plugin/bitwarden/helper/bitwarden_helper.rb
153
+ - lib/fastlane/plugin/bitwarden/version.rb
154
+ homepage: https://github.com/codechem/fastlane-plugin-bitwarden
155
+ licenses:
156
+ - MIT
157
+ metadata: {}
158
+ post_install_message:
159
+ rdoc_options: []
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ requirements: []
173
+ rubygems_version: 3.0.6
174
+ signing_key:
175
+ specification_version: 4
176
+ summary: Bitwarden CLI warpper plugin
177
+ test_files: []