sshkit 1.18.2 → 1.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +63 -0
- data/.rubocop_todo.yml +637 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +8 -1
- data/lib/sshkit/backends/abstract.rb +8 -6
- data/lib/sshkit/command.rb +12 -12
- data/lib/sshkit/host.rb +6 -4
- data/lib/sshkit/version.rb +1 -1
- data/test/functional/backends/test_netssh.rb +8 -11
- data/test/support/vagrant_wrapper.rb +10 -1
- data/test/unit/test_command.rb +27 -7
- data/test/unit/test_host.rb +5 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b4191d45c0d732071e82c9a8eeead452366f901fd483eb016dbd97761da10d1
|
4
|
+
data.tar.gz: 49209aa289eb35cc906bb88fa187aa43079d3c3a0e9ed42582cbc74bb967d54f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa67fe84e2eda52dae94814f6c81d66a0f965e8fbffadc4238c9cc63b800ab3c24a424b0382d8d1a1431f5ecb095dda017fe076277fe165f8771d1e21d6f4d82
|
7
|
+
data.tar.gz: f404f7933c620ab7737c5062c45a7b536dd62f26034894588dffb132b9e027a32516c0bf5a43215d7bdf468c4ae3102d99957d7a1ef728bf2e3e7db9c1ee3dd0
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
DisplayCopNames: true
|
5
|
+
DisplayStyleGuide: true
|
6
|
+
TargetRubyVersion: 2.0
|
7
|
+
|
8
|
+
Lint/AmbiguousBlockAssociation:
|
9
|
+
Enabled:
|
10
|
+
false
|
11
|
+
Metrics/BlockLength:
|
12
|
+
Exclude:
|
13
|
+
- "spec/**/*"
|
14
|
+
- "lib/**/*.rake"
|
15
|
+
Style/BarePercentLiterals:
|
16
|
+
EnforcedStyle: percent_q
|
17
|
+
Style/ClassAndModuleChildren:
|
18
|
+
Enabled: false
|
19
|
+
Style/DoubleNegation:
|
20
|
+
Enabled: false
|
21
|
+
Style/FileName:
|
22
|
+
Exclude:
|
23
|
+
- "Dangerfile"
|
24
|
+
Style/IndentHeredoc:
|
25
|
+
Enabled: false
|
26
|
+
Style/SpaceAroundEqualsInParameterDefault:
|
27
|
+
EnforcedStyle: no_space
|
28
|
+
Style/StringLiterals:
|
29
|
+
EnforcedStyle: double_quotes
|
30
|
+
Style/TrivialAccessors:
|
31
|
+
AllowPredicates: true
|
32
|
+
Style/PercentLiteralDelimiters:
|
33
|
+
Enabled: false
|
34
|
+
Style/SingleLineBlockParams:
|
35
|
+
Enabled: false
|
36
|
+
Style/ModuleFunction:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
# Enable someday
|
40
|
+
Style/Documentation:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
# Needs refactors
|
44
|
+
Metrics/PerceivedComplexity:
|
45
|
+
Enabled: false
|
46
|
+
Metrics/CyclomaticComplexity:
|
47
|
+
Enabled: false
|
48
|
+
Metrics/MethodLength:
|
49
|
+
Enabled: false
|
50
|
+
Style/PredicateName:
|
51
|
+
Enabled: false
|
52
|
+
Metrics/LineLength:
|
53
|
+
Enabled: false
|
54
|
+
Metrics/AbcSize:
|
55
|
+
Enabled: false
|
56
|
+
Style/PerlBackrefs:
|
57
|
+
Enabled: false
|
58
|
+
Metrics/ClassLength:
|
59
|
+
Enabled: false
|
60
|
+
Metrics/ModuleLength:
|
61
|
+
Enabled: false
|
62
|
+
Style/AccessorMethodName:
|
63
|
+
Enabled: false
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,637 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2019-05-15 19:11:29 -0500 using RuboCop version 0.49.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: Include, TreatCommentsAsGroupSeparators.
|
12
|
+
# Include: **/Gemfile, **/gems.rb
|
13
|
+
Bundler/OrderedGems:
|
14
|
+
Exclude:
|
15
|
+
- 'Gemfile'
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
# Cop supports --auto-correct.
|
19
|
+
Layout/EmptyLineAfterMagicComment:
|
20
|
+
Exclude:
|
21
|
+
- 'sshkit.gemspec'
|
22
|
+
|
23
|
+
# Offense count: 11
|
24
|
+
# Cop supports --auto-correct.
|
25
|
+
# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines.
|
26
|
+
Layout/EmptyLineBetweenDefs:
|
27
|
+
Exclude:
|
28
|
+
- 'lib/core_ext/hash.rb'
|
29
|
+
- 'lib/sshkit/backends/abstract.rb'
|
30
|
+
- 'lib/sshkit/host.rb'
|
31
|
+
- 'lib/sshkit/log_message.rb'
|
32
|
+
- 'test/unit/formatters/test_pretty.rb'
|
33
|
+
- 'test/unit/test_mapping_interaction_handler.rb'
|
34
|
+
|
35
|
+
# Offense count: 2
|
36
|
+
# Cop supports --auto-correct.
|
37
|
+
Layout/EmptyLines:
|
38
|
+
Exclude:
|
39
|
+
- 'test/unit/formatters/test_pretty.rb'
|
40
|
+
- 'test/unit/test_mapping_interaction_handler.rb'
|
41
|
+
|
42
|
+
# Offense count: 1
|
43
|
+
# Cop supports --auto-correct.
|
44
|
+
Layout/EmptyLinesAroundAccessModifier:
|
45
|
+
Exclude:
|
46
|
+
- 'lib/sshkit/runners/sequential.rb'
|
47
|
+
|
48
|
+
# Offense count: 4
|
49
|
+
# Cop supports --auto-correct.
|
50
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
51
|
+
# SupportedStyles: empty_lines, no_empty_lines
|
52
|
+
Layout/EmptyLinesAroundBlockBody:
|
53
|
+
Exclude:
|
54
|
+
- 'Rakefile'
|
55
|
+
- 'sshkit.gemspec'
|
56
|
+
- 'test/helper.rb'
|
57
|
+
|
58
|
+
# Offense count: 73
|
59
|
+
# Cop supports --auto-correct.
|
60
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
61
|
+
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
|
62
|
+
Layout/EmptyLinesAroundClassBody:
|
63
|
+
Enabled: false
|
64
|
+
|
65
|
+
# Offense count: 2
|
66
|
+
# Cop supports --auto-correct.
|
67
|
+
Layout/EmptyLinesAroundMethodBody:
|
68
|
+
Exclude:
|
69
|
+
- 'lib/sshkit/host.rb'
|
70
|
+
|
71
|
+
# Offense count: 100
|
72
|
+
# Cop supports --auto-correct.
|
73
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
74
|
+
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
|
75
|
+
Layout/EmptyLinesAroundModuleBody:
|
76
|
+
Enabled: false
|
77
|
+
|
78
|
+
# Offense count: 3
|
79
|
+
# Cop supports --auto-correct.
|
80
|
+
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
|
81
|
+
Layout/ExtraSpacing:
|
82
|
+
Exclude:
|
83
|
+
- 'test/unit/backends/test_abstract.rb'
|
84
|
+
- 'test/unit/backends/test_netssh.rb'
|
85
|
+
- 'test/unit/test_host.rb'
|
86
|
+
|
87
|
+
# Offense count: 6
|
88
|
+
# Cop supports --auto-correct.
|
89
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
90
|
+
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
|
91
|
+
Layout/IndentArray:
|
92
|
+
Exclude:
|
93
|
+
- 'test/functional/backends/test_netssh.rb'
|
94
|
+
- 'test/unit/backends/test_netssh.rb'
|
95
|
+
- 'test/unit/formatters/test_pretty.rb'
|
96
|
+
|
97
|
+
# Offense count: 11
|
98
|
+
# Cop supports --auto-correct.
|
99
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
100
|
+
# SupportedStyles: special_inside_parentheses, consistent, align_braces
|
101
|
+
Layout/IndentHash:
|
102
|
+
Exclude:
|
103
|
+
- 'test/functional/backends/test_local.rb'
|
104
|
+
- 'test/functional/backends/test_netssh.rb'
|
105
|
+
- 'test/support/vagrant_wrapper.rb'
|
106
|
+
- 'test/unit/formatters/test_custom.rb'
|
107
|
+
- 'test/unit/formatters/test_pretty.rb'
|
108
|
+
- 'test/unit/test_mapping_interaction_handler.rb'
|
109
|
+
|
110
|
+
# Offense count: 5
|
111
|
+
# Cop supports --auto-correct.
|
112
|
+
# Configuration parameters: Width, IgnoredPatterns.
|
113
|
+
Layout/IndentationWidth:
|
114
|
+
Exclude:
|
115
|
+
- 'lib/sshkit/exception.rb'
|
116
|
+
- 'test/functional/backends/test_netssh.rb'
|
117
|
+
|
118
|
+
# Offense count: 5
|
119
|
+
# Cop supports --auto-correct.
|
120
|
+
Layout/LeadingCommentSpace:
|
121
|
+
Exclude:
|
122
|
+
- 'lib/sshkit/backends/netssh.rb'
|
123
|
+
- 'lib/sshkit/command.rb'
|
124
|
+
- 'test/helper.rb'
|
125
|
+
|
126
|
+
# Offense count: 4
|
127
|
+
# Cop supports --auto-correct.
|
128
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
129
|
+
# SupportedStyles: symmetrical, new_line, same_line
|
130
|
+
Layout/MultilineMethodCallBraceLayout:
|
131
|
+
Exclude:
|
132
|
+
- 'test/unit/test_command.rb'
|
133
|
+
|
134
|
+
# Offense count: 1
|
135
|
+
# Cop supports --auto-correct.
|
136
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
137
|
+
# SupportedStyles: aligned, indented, indented_relative_to_receiver
|
138
|
+
Layout/MultilineMethodCallIndentation:
|
139
|
+
Exclude:
|
140
|
+
- 'lib/sshkit/host.rb'
|
141
|
+
|
142
|
+
# Offense count: 1
|
143
|
+
# Cop supports --auto-correct.
|
144
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
145
|
+
# SupportedStyles: aligned, indented
|
146
|
+
Layout/MultilineOperationIndentation:
|
147
|
+
Exclude:
|
148
|
+
- 'lib/sshkit/backends/netssh.rb'
|
149
|
+
|
150
|
+
# Offense count: 10
|
151
|
+
# Cop supports --auto-correct.
|
152
|
+
Layout/SpaceAfterComma:
|
153
|
+
Exclude:
|
154
|
+
- 'lib/sshkit/command.rb'
|
155
|
+
- 'test/functional/backends/test_netssh.rb'
|
156
|
+
- 'test/unit/backends/test_netssh.rb'
|
157
|
+
- 'test/unit/test_configuration.rb'
|
158
|
+
|
159
|
+
# Offense count: 16
|
160
|
+
# Cop supports --auto-correct.
|
161
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
162
|
+
# SupportedStyles: space, no_space
|
163
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
164
|
+
Exclude:
|
165
|
+
- 'lib/sshkit/backends/abstract.rb'
|
166
|
+
- 'lib/sshkit/backends/local.rb'
|
167
|
+
- 'lib/sshkit/backends/netssh.rb'
|
168
|
+
- 'lib/sshkit/backends/netssh/known_hosts.rb'
|
169
|
+
- 'lib/sshkit/command_map.rb'
|
170
|
+
- 'lib/sshkit/runners/abstract.rb'
|
171
|
+
- 'lib/sshkit/runners/group.rb'
|
172
|
+
- 'lib/sshkit/runners/sequential.rb'
|
173
|
+
- 'test/helper.rb'
|
174
|
+
- 'test/unit/backends/test_netssh.rb'
|
175
|
+
|
176
|
+
# Offense count: 12
|
177
|
+
# Cop supports --auto-correct.
|
178
|
+
# Configuration parameters: AllowForAlignment.
|
179
|
+
Layout/SpaceAroundOperators:
|
180
|
+
Exclude:
|
181
|
+
- 'test/functional/backends/test_netssh.rb'
|
182
|
+
- 'test/unit/backends/test_abstract.rb'
|
183
|
+
- 'test/unit/test_command.rb'
|
184
|
+
- 'test/unit/test_deprecation_logger.rb'
|
185
|
+
|
186
|
+
# Offense count: 4
|
187
|
+
# Cop supports --auto-correct.
|
188
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
189
|
+
# SupportedStyles: space, no_space
|
190
|
+
Layout/SpaceBeforeBlockBraces:
|
191
|
+
Exclude:
|
192
|
+
- 'lib/sshkit/command.rb'
|
193
|
+
- 'lib/sshkit/host.rb'
|
194
|
+
- 'sshkit.gemspec'
|
195
|
+
- 'test/unit/test_command_map.rb'
|
196
|
+
|
197
|
+
# Offense count: 1
|
198
|
+
# Cop supports --auto-correct.
|
199
|
+
# Configuration parameters: AllowForAlignment.
|
200
|
+
Layout/SpaceBeforeFirstArg:
|
201
|
+
Exclude:
|
202
|
+
- 'test/unit/backends/test_netssh.rb'
|
203
|
+
|
204
|
+
# Offense count: 4
|
205
|
+
# Cop supports --auto-correct.
|
206
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces, SpaceBeforeBlockParameters.
|
207
|
+
# SupportedStyles: space, no_space
|
208
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
209
|
+
Layout/SpaceInsideBlockBraces:
|
210
|
+
Exclude:
|
211
|
+
- 'lib/sshkit/command.rb'
|
212
|
+
- 'lib/sshkit/host.rb'
|
213
|
+
- 'test/functional/backends/test_netssh.rb'
|
214
|
+
- 'test/unit/test_configuration.rb'
|
215
|
+
|
216
|
+
# Offense count: 39
|
217
|
+
# Cop supports --auto-correct.
|
218
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces.
|
219
|
+
# SupportedStyles: space, no_space, compact
|
220
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
221
|
+
Layout/SpaceInsideHashLiteralBraces:
|
222
|
+
Exclude:
|
223
|
+
- 'lib/sshkit/backends/abstract.rb'
|
224
|
+
- 'lib/sshkit/backends/netssh.rb'
|
225
|
+
- 'test/functional/backends/test_netssh.rb'
|
226
|
+
- 'test/unit/backends/test_abstract.rb'
|
227
|
+
- 'test/unit/formatters/test_dot.rb'
|
228
|
+
- 'test/unit/test_color.rb'
|
229
|
+
- 'test/unit/test_command.rb'
|
230
|
+
- 'test/unit/test_host.rb'
|
231
|
+
- 'test/unit/test_mapping_interaction_handler.rb'
|
232
|
+
|
233
|
+
# Offense count: 2
|
234
|
+
# Cop supports --auto-correct.
|
235
|
+
Layout/SpaceInsidePercentLiteralDelimiters:
|
236
|
+
Exclude:
|
237
|
+
- 'lib/sshkit/formatters/pretty.rb'
|
238
|
+
|
239
|
+
# Offense count: 1
|
240
|
+
# Cop supports --auto-correct.
|
241
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
242
|
+
# SupportedStyles: final_newline, final_blank_line
|
243
|
+
Layout/TrailingBlankLines:
|
244
|
+
Exclude:
|
245
|
+
- 'lib/sshkit/backends/netssh/known_hosts.rb'
|
246
|
+
|
247
|
+
# Offense count: 16
|
248
|
+
# Cop supports --auto-correct.
|
249
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
250
|
+
# SupportedStyles: prefer_alias, prefer_alias_method
|
251
|
+
Style/Alias:
|
252
|
+
Exclude:
|
253
|
+
- 'lib/sshkit/backends/printer.rb'
|
254
|
+
- 'lib/sshkit/backends/skipper.rb'
|
255
|
+
- 'lib/sshkit/command.rb'
|
256
|
+
- 'lib/sshkit/formatters/abstract.rb'
|
257
|
+
- 'lib/sshkit/host.rb'
|
258
|
+
- 'test/unit/formatters/test_custom.rb'
|
259
|
+
|
260
|
+
# Offense count: 2
|
261
|
+
Style/AsciiComments:
|
262
|
+
Exclude:
|
263
|
+
- 'lib/sshkit/command.rb'
|
264
|
+
- 'test/helper.rb'
|
265
|
+
|
266
|
+
# Offense count: 11
|
267
|
+
# Cop supports --auto-correct.
|
268
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
269
|
+
# SupportedStyles: percent_q, bare_percent
|
270
|
+
Style/BarePercentLiterals:
|
271
|
+
Exclude:
|
272
|
+
- 'lib/sshkit/command.rb'
|
273
|
+
- 'test/unit/test_command.rb'
|
274
|
+
|
275
|
+
# Offense count: 10
|
276
|
+
# Cop supports --auto-correct.
|
277
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
278
|
+
# SupportedStyles: braces, no_braces, context_dependent
|
279
|
+
Style/BracesAroundHashParameters:
|
280
|
+
Exclude:
|
281
|
+
- 'lib/sshkit/backends/abstract.rb'
|
282
|
+
- 'test/functional/backends/test_netssh.rb'
|
283
|
+
- 'test/unit/backends/test_abstract.rb'
|
284
|
+
- 'test/unit/formatters/test_dot.rb'
|
285
|
+
- 'test/unit/test_color.rb'
|
286
|
+
- 'test/unit/test_host.rb'
|
287
|
+
- 'test/unit/test_mapping_interaction_handler.rb'
|
288
|
+
|
289
|
+
# Offense count: 1
|
290
|
+
Style/CaseEquality:
|
291
|
+
Exclude:
|
292
|
+
- 'lib/sshkit/mapping_interaction_handler.rb'
|
293
|
+
|
294
|
+
# Offense count: 2
|
295
|
+
# Cop supports --auto-correct.
|
296
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
297
|
+
# SupportedStyles: is_a?, kind_of?
|
298
|
+
Style/ClassCheck:
|
299
|
+
Exclude:
|
300
|
+
- 'lib/sshkit/command.rb'
|
301
|
+
- 'lib/sshkit/formatters/pretty.rb'
|
302
|
+
|
303
|
+
# Offense count: 1
|
304
|
+
# Cop supports --auto-correct.
|
305
|
+
Style/ClassMethods:
|
306
|
+
Exclude:
|
307
|
+
- 'test/unit/backends/test_abstract.rb'
|
308
|
+
|
309
|
+
# Offense count: 3
|
310
|
+
Style/ClassVars:
|
311
|
+
Exclude:
|
312
|
+
- 'lib/sshkit.rb'
|
313
|
+
|
314
|
+
# Offense count: 1
|
315
|
+
# Cop supports --auto-correct.
|
316
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly, IncludeTernaryExpressions.
|
317
|
+
# SupportedStyles: assign_to_condition, assign_inside_condition
|
318
|
+
Style/ConditionalAssignment:
|
319
|
+
Exclude:
|
320
|
+
- 'lib/sshkit/command_map.rb'
|
321
|
+
|
322
|
+
# Offense count: 1
|
323
|
+
# Cop supports --auto-correct.
|
324
|
+
Style/EachWithObject:
|
325
|
+
Exclude:
|
326
|
+
- 'lib/core_ext/hash.rb'
|
327
|
+
|
328
|
+
# Offense count: 12
|
329
|
+
# Cop supports --auto-correct.
|
330
|
+
Style/EmptyLiteral:
|
331
|
+
Exclude:
|
332
|
+
- 'lib/sshkit/command.rb'
|
333
|
+
- 'test/functional/backends/test_netssh.rb'
|
334
|
+
- 'test/unit/backends/test_printer.rb'
|
335
|
+
- 'test/unit/formatters/test_custom.rb'
|
336
|
+
- 'test/unit/formatters/test_dot.rb'
|
337
|
+
- 'test/unit/formatters/test_pretty.rb'
|
338
|
+
- 'test/unit/formatters/test_simple_text.rb'
|
339
|
+
- 'test/unit/test_coordinator.rb'
|
340
|
+
- 'test/unit/test_deprecation_logger.rb'
|
341
|
+
|
342
|
+
# Offense count: 3
|
343
|
+
# Cop supports --auto-correct.
|
344
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
345
|
+
# SupportedStyles: compact, expanded
|
346
|
+
Style/EmptyMethod:
|
347
|
+
Exclude:
|
348
|
+
- 'lib/sshkit/formatters/dot.rb'
|
349
|
+
- 'lib/sshkit/host.rb'
|
350
|
+
|
351
|
+
# Offense count: 1
|
352
|
+
# Cop supports --auto-correct.
|
353
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
354
|
+
# SupportedStyles: format, sprintf, percent
|
355
|
+
Style/FormatString:
|
356
|
+
Exclude:
|
357
|
+
- 'lib/sshkit/formatters/pretty.rb'
|
358
|
+
|
359
|
+
# Offense count: 6
|
360
|
+
# Configuration parameters: AllowedVariables.
|
361
|
+
Style/GlobalVars:
|
362
|
+
Exclude:
|
363
|
+
- 'test/unit/test_coordinator.rb'
|
364
|
+
|
365
|
+
# Offense count: 7
|
366
|
+
# Configuration parameters: MinBodyLength.
|
367
|
+
Style/GuardClause:
|
368
|
+
Exclude:
|
369
|
+
- 'lib/sshkit/backends/connection_pool.rb'
|
370
|
+
- 'lib/sshkit/backends/netssh.rb'
|
371
|
+
- 'lib/sshkit/command.rb'
|
372
|
+
- 'lib/sshkit/formatters/pretty.rb'
|
373
|
+
- 'lib/sshkit/host.rb'
|
374
|
+
- 'lib/sshkit/runners/sequential.rb'
|
375
|
+
- 'test/helper.rb'
|
376
|
+
|
377
|
+
# Offense count: 33
|
378
|
+
# Cop supports --auto-correct.
|
379
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
380
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
381
|
+
Style/HashSyntax:
|
382
|
+
Exclude:
|
383
|
+
- 'Rakefile'
|
384
|
+
- 'lib/sshkit/color.rb'
|
385
|
+
- 'test/functional/backends/test_netssh.rb'
|
386
|
+
- 'test/unit/backends/test_abstract.rb'
|
387
|
+
- 'test/unit/backends/test_connection_pool.rb'
|
388
|
+
- 'test/unit/formatters/test_custom.rb'
|
389
|
+
- 'test/unit/test_configuration.rb'
|
390
|
+
|
391
|
+
# Offense count: 4
|
392
|
+
# Cop supports --auto-correct.
|
393
|
+
# Configuration parameters: MaxLineLength.
|
394
|
+
Style/IfUnlessModifier:
|
395
|
+
Exclude:
|
396
|
+
- 'lib/sshkit/backends/connection_pool.rb'
|
397
|
+
- 'lib/sshkit/backends/netssh/known_hosts.rb'
|
398
|
+
- 'lib/sshkit/configuration.rb'
|
399
|
+
- 'lib/sshkit/runners/sequential.rb'
|
400
|
+
|
401
|
+
# Offense count: 1
|
402
|
+
# Cop supports --auto-correct.
|
403
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
404
|
+
# SupportedStyles: line_count_dependent, lambda, literal
|
405
|
+
Style/Lambda:
|
406
|
+
Exclude:
|
407
|
+
- 'test/unit/backends/test_abstract.rb'
|
408
|
+
|
409
|
+
# Offense count: 1
|
410
|
+
# Cop supports --auto-correct.
|
411
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
412
|
+
# SupportedStyles: call, braces
|
413
|
+
Style/LambdaCall:
|
414
|
+
Exclude:
|
415
|
+
- 'lib/sshkit/command_map.rb'
|
416
|
+
|
417
|
+
# Offense count: 5
|
418
|
+
# Cop supports --auto-correct.
|
419
|
+
Style/LineEndConcatenation:
|
420
|
+
Exclude:
|
421
|
+
- 'lib/sshkit/backends/netssh.rb'
|
422
|
+
- 'test/unit/test_command.rb'
|
423
|
+
|
424
|
+
# Offense count: 3
|
425
|
+
# Cop supports --auto-correct.
|
426
|
+
Style/MethodCallWithoutArgsParentheses:
|
427
|
+
Exclude:
|
428
|
+
- 'test/unit/test_color.rb'
|
429
|
+
- 'test/unit/test_coordinator.rb'
|
430
|
+
- 'test/unit/test_mapping_interaction_handler.rb'
|
431
|
+
|
432
|
+
# Offense count: 1
|
433
|
+
# Cop supports --auto-correct.
|
434
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
435
|
+
# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline
|
436
|
+
Style/MethodDefParentheses:
|
437
|
+
Exclude:
|
438
|
+
- 'lib/sshkit/exception.rb'
|
439
|
+
|
440
|
+
# Offense count: 3
|
441
|
+
# Configuration parameters: SupportedStyles.
|
442
|
+
# SupportedStyles: snake_case, camelCase
|
443
|
+
Style/MethodName:
|
444
|
+
EnforcedStyle: snake_case
|
445
|
+
Exclude:
|
446
|
+
- 'test/unit/test_color.rb'
|
447
|
+
|
448
|
+
# Offense count: 1
|
449
|
+
# Cop supports --auto-correct.
|
450
|
+
Style/MutableConstant:
|
451
|
+
Exclude:
|
452
|
+
- 'Vagrantfile'
|
453
|
+
|
454
|
+
# Offense count: 1
|
455
|
+
# Cop supports --auto-correct.
|
456
|
+
# Configuration parameters: Strict.
|
457
|
+
Style/NumericLiterals:
|
458
|
+
MinDigits: 6
|
459
|
+
|
460
|
+
# Offense count: 1
|
461
|
+
# Cop supports --auto-correct.
|
462
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles.
|
463
|
+
# SupportedStyles: predicate, comparison
|
464
|
+
Style/NumericPredicate:
|
465
|
+
Exclude:
|
466
|
+
- 'spec/**/*'
|
467
|
+
- 'lib/sshkit/command.rb'
|
468
|
+
|
469
|
+
# Offense count: 1
|
470
|
+
Style/OpMethod:
|
471
|
+
Exclude:
|
472
|
+
- 'lib/sshkit/host.rb'
|
473
|
+
|
474
|
+
# Offense count: 6
|
475
|
+
# Cop supports --auto-correct.
|
476
|
+
Style/ParallelAssignment:
|
477
|
+
Exclude:
|
478
|
+
- 'lib/sshkit/backends/netssh/known_hosts.rb'
|
479
|
+
- 'lib/sshkit/color.rb'
|
480
|
+
- 'lib/sshkit/command.rb'
|
481
|
+
- 'lib/sshkit/log_message.rb'
|
482
|
+
- 'test/helper.rb'
|
483
|
+
|
484
|
+
# Offense count: 1
|
485
|
+
# Cop supports --auto-correct.
|
486
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
487
|
+
# SupportedStyles: lower_case_q, upper_case_q
|
488
|
+
Style/PercentQLiterals:
|
489
|
+
Exclude:
|
490
|
+
- 'test/unit/test_command.rb'
|
491
|
+
|
492
|
+
# Offense count: 4
|
493
|
+
# Cop supports --auto-correct.
|
494
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
495
|
+
# SupportedStyles: short, verbose
|
496
|
+
Style/PreferredHashMethods:
|
497
|
+
Exclude:
|
498
|
+
- 'test/unit/test_host.rb'
|
499
|
+
|
500
|
+
# Offense count: 2
|
501
|
+
# Cop supports --auto-correct.
|
502
|
+
Style/RedundantBegin:
|
503
|
+
Exclude:
|
504
|
+
- 'test/unit/test_coordinator.rb'
|
505
|
+
|
506
|
+
# Offense count: 1
|
507
|
+
# Cop supports --auto-correct.
|
508
|
+
Style/RedundantParentheses:
|
509
|
+
Exclude:
|
510
|
+
- 'test/functional/backends/test_netssh.rb'
|
511
|
+
|
512
|
+
# Offense count: 2
|
513
|
+
# Cop supports --auto-correct.
|
514
|
+
# Configuration parameters: AllowMultipleReturnValues.
|
515
|
+
Style/RedundantReturn:
|
516
|
+
Exclude:
|
517
|
+
- 'lib/sshkit/command.rb'
|
518
|
+
|
519
|
+
# Offense count: 4
|
520
|
+
# Cop supports --auto-correct.
|
521
|
+
Style/RedundantSelf:
|
522
|
+
Exclude:
|
523
|
+
- 'lib/core_ext/hash.rb'
|
524
|
+
- 'lib/sshkit/command.rb'
|
525
|
+
- 'lib/sshkit/host.rb'
|
526
|
+
|
527
|
+
# Offense count: 1
|
528
|
+
# Cop supports --auto-correct.
|
529
|
+
Style/RescueModifier:
|
530
|
+
Exclude:
|
531
|
+
- 'lib/core_ext/hash.rb'
|
532
|
+
|
533
|
+
# Offense count: 2
|
534
|
+
# Cop supports --auto-correct.
|
535
|
+
# Configuration parameters: AllowAsExpressionSeparator.
|
536
|
+
Style/Semicolon:
|
537
|
+
Exclude:
|
538
|
+
- 'test/unit/backends/test_connection_pool.rb'
|
539
|
+
- 'test/unit/test_command_map.rb'
|
540
|
+
|
541
|
+
# Offense count: 2
|
542
|
+
# Cop supports --auto-correct.
|
543
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
544
|
+
# SupportedStyles: only_raise, only_fail, semantic
|
545
|
+
Style/SignalException:
|
546
|
+
Exclude:
|
547
|
+
- 'lib/sshkit/configuration.rb'
|
548
|
+
- 'lib/sshkit/host.rb'
|
549
|
+
|
550
|
+
# Offense count: 3
|
551
|
+
# Cop supports --auto-correct.
|
552
|
+
# Configuration parameters: AllowIfMethodIsEmpty.
|
553
|
+
Style/SingleLineMethods:
|
554
|
+
Exclude:
|
555
|
+
- 'lib/sshkit/backends/abstract.rb'
|
556
|
+
|
557
|
+
# Offense count: 476
|
558
|
+
# Cop supports --auto-correct.
|
559
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
|
560
|
+
# SupportedStyles: single_quotes, double_quotes
|
561
|
+
Style/StringLiterals:
|
562
|
+
Enabled: false
|
563
|
+
|
564
|
+
# Offense count: 3
|
565
|
+
# Cop supports --auto-correct.
|
566
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
567
|
+
# SupportedStyles: single_quotes, double_quotes
|
568
|
+
Style/StringLiteralsInInterpolation:
|
569
|
+
Exclude:
|
570
|
+
- 'lib/sshkit/command.rb'
|
571
|
+
- 'lib/sshkit/runners/parallel.rb'
|
572
|
+
- 'lib/sshkit/runners/sequential.rb'
|
573
|
+
|
574
|
+
# Offense count: 5
|
575
|
+
# Cop supports --auto-correct.
|
576
|
+
# Configuration parameters: MinSize, SupportedStyles.
|
577
|
+
# SupportedStyles: percent, brackets
|
578
|
+
Style/SymbolArray:
|
579
|
+
EnforcedStyle: brackets
|
580
|
+
|
581
|
+
# Offense count: 3
|
582
|
+
# Cop supports --auto-correct.
|
583
|
+
# Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline.
|
584
|
+
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
|
585
|
+
Style/TrailingCommaInLiteral:
|
586
|
+
Exclude:
|
587
|
+
- 'lib/sshkit/host.rb'
|
588
|
+
- 'test/unit/backends/test_netssh.rb'
|
589
|
+
- 'test/unit/test_configuration.rb'
|
590
|
+
|
591
|
+
# Offense count: 1
|
592
|
+
# Cop supports --auto-correct.
|
593
|
+
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist.
|
594
|
+
# Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym
|
595
|
+
Style/TrivialAccessors:
|
596
|
+
Exclude:
|
597
|
+
- 'lib/sshkit/host.rb'
|
598
|
+
|
599
|
+
# Offense count: 1
|
600
|
+
# Cop supports --auto-correct.
|
601
|
+
Style/UnlessElse:
|
602
|
+
Exclude:
|
603
|
+
- 'lib/sshkit/backends/netssh.rb'
|
604
|
+
|
605
|
+
# Offense count: 1
|
606
|
+
# Cop supports --auto-correct.
|
607
|
+
Style/UnneededCapitalW:
|
608
|
+
Exclude:
|
609
|
+
- 'test/functional/backends/test_netssh.rb'
|
610
|
+
|
611
|
+
# Offense count: 3
|
612
|
+
# Cop supports --auto-correct.
|
613
|
+
Style/UnneededPercentQ:
|
614
|
+
Exclude:
|
615
|
+
- 'sshkit.gemspec'
|
616
|
+
- 'test/unit/test_command.rb'
|
617
|
+
|
618
|
+
# Offense count: 1
|
619
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
620
|
+
# SupportedStyles: snake_case, normalcase, non_integer
|
621
|
+
Style/VariableNumber:
|
622
|
+
Exclude:
|
623
|
+
- 'test/unit/backends/test_connection_pool.rb'
|
624
|
+
|
625
|
+
# Offense count: 2
|
626
|
+
# Cop supports --auto-correct.
|
627
|
+
Style/WhileUntilDo:
|
628
|
+
Exclude:
|
629
|
+
- 'lib/sshkit/backends/local.rb'
|
630
|
+
|
631
|
+
# Offense count: 1
|
632
|
+
# Cop supports --auto-correct.
|
633
|
+
# Configuration parameters: SupportedStyles, WordRegex.
|
634
|
+
# SupportedStyles: percent, brackets
|
635
|
+
Style/WordArray:
|
636
|
+
EnforcedStyle: percent
|
637
|
+
MinSize: 3
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,12 @@ appear at the top.
|
|
7
7
|
|
8
8
|
* Your contribution here!
|
9
9
|
|
10
|
+
## [1.19.0][] (2019-06-30)
|
11
|
+
|
12
|
+
* [#455](https://github.com/capistrano/sshkit/pull/455): Ensure UUID of commands are stable in logging - [@lazyatom](https://github.com/lazyatom)
|
13
|
+
* [#453](https://github.com/capistrano/sshkit/pull/453): `as` and `within` now properly escape their user/group/path arguments, and the command nested within an `as` block is now properly escaped before passing to `sh -c`. In the unlikely case that you were manually escaping commands passed to SSHKit as a workaround, you will no longer need to do this. See [#458](https://github.com/capistrano/sshkit/issues/458) for examples of what has been fixed. - [@grosser](https://github.com/grosser)
|
14
|
+
* [#460](https://github.com/capistrano/sshkit/pull/460): Handle IPv6 addresses without port - [@will-in-wi](https://github.com/will-in-wi)
|
15
|
+
|
10
16
|
## [1.18.2][] (2019-02-03)
|
11
17
|
|
12
18
|
* [#448](https://github.com/capistrano/sshkit/pull/448): Fix misbehaving connection eviction loop when disabling connection pooling - [Sebastian Cohnen](https://github.com/tisba)
|
@@ -758,7 +764,8 @@ version `0.0.5`.
|
|
758
764
|
|
759
765
|
First release.
|
760
766
|
|
761
|
-
[Unreleased]: https://github.com/capistrano/sshkit/compare/v1.
|
767
|
+
[Unreleased]: https://github.com/capistrano/sshkit/compare/v1.19.0...HEAD
|
768
|
+
[1.19.0]: https://github.com/capistrano/sshkit/compare/v1.18.2...v1.19.0
|
762
769
|
[1.18.2]: https://github.com/capistrano/sshkit/compare/v1.18.1...v1.18.2
|
763
770
|
[1.18.1]: https://github.com/capistrano/sshkit/compare/v1.18.0...v1.18.1
|
764
771
|
[1.18.0]: https://github.com/capistrano/sshkit/compare/v1.17.0...v1.18.0
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
|
1
3
|
module SSHKit
|
2
4
|
|
3
5
|
module Backend
|
@@ -81,12 +83,12 @@ module SSHKit
|
|
81
83
|
def within(directory, &_block)
|
82
84
|
(@pwd ||= []).push directory.to_s
|
83
85
|
execute <<-EOTEST, verbosity: Logger::DEBUG
|
84
|
-
if test ! -d #{File.join(@pwd)}
|
85
|
-
then echo "Directory does not exist '#{File.join(@pwd)}'" 1>&2
|
86
|
+
if test ! -d #{File.join(@pwd).shellescape}
|
87
|
+
then echo "Directory does not exist '#{File.join(@pwd).shellescape}'" 1>&2
|
86
88
|
false
|
87
89
|
fi
|
88
|
-
|
89
|
-
|
90
|
+
EOTEST
|
91
|
+
yield
|
90
92
|
ensure
|
91
93
|
@pwd.pop
|
92
94
|
end
|
@@ -108,8 +110,8 @@ module SSHKit
|
|
108
110
|
@group = nil
|
109
111
|
end
|
110
112
|
execute <<-EOTEST, verbosity: Logger::DEBUG
|
111
|
-
if ! sudo -u #{@user} whoami > /dev/null
|
112
|
-
then echo "You cannot switch to user '#{@user}' using sudo, please check the sudoers file" 1>&2
|
113
|
+
if ! sudo -u #{@user.to_s.shellescape} whoami > /dev/null
|
114
|
+
then echo "You cannot switch to user '#{@user.to_s.shellescape}' using sudo, please check the sudoers file" 1>&2
|
113
115
|
false
|
114
116
|
fi
|
115
117
|
EOTEST
|
data/lib/sshkit/command.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'digest/sha1'
|
2
2
|
require 'securerandom'
|
3
|
+
require 'shellwords'
|
3
4
|
|
4
5
|
# @author Lee Hambley
|
5
6
|
module SSHKit
|
@@ -9,7 +10,7 @@ module SSHKit
|
|
9
10
|
|
10
11
|
Failed = Class.new(SSHKit::StandardError)
|
11
12
|
|
12
|
-
attr_reader :command, :args, :options, :started_at, :started, :exit_status, :full_stdout, :full_stderr
|
13
|
+
attr_reader :command, :args, :options, :started_at, :started, :exit_status, :full_stdout, :full_stderr, :uuid
|
13
14
|
|
14
15
|
# Initialize a new Command object
|
15
16
|
#
|
@@ -25,6 +26,7 @@ module SSHKit
|
|
25
26
|
@args = args
|
26
27
|
@options.symbolize_keys!
|
27
28
|
@stdout, @stderr, @full_stdout, @full_stderr = String.new, String.new, String.new, String.new
|
29
|
+
@uuid = Digest::SHA1.hexdigest(SecureRandom.random_bytes(10))[0..7]
|
28
30
|
end
|
29
31
|
|
30
32
|
def complete?
|
@@ -41,10 +43,6 @@ module SSHKit
|
|
41
43
|
@started = new_started
|
42
44
|
end
|
43
45
|
|
44
|
-
def uuid
|
45
|
-
@uuid ||= Digest::SHA1.hexdigest(SecureRandom.random_bytes(10))[0..7]
|
46
|
-
end
|
47
|
-
|
48
46
|
def success?
|
49
47
|
exit_status.nil? ? false : exit_status.to_i == 0
|
50
48
|
end
|
@@ -145,7 +143,7 @@ module SSHKit
|
|
145
143
|
|
146
144
|
def within(&_block)
|
147
145
|
return yield unless options[:in]
|
148
|
-
|
146
|
+
"cd #{options[:in].shellescape} && #{yield}"
|
149
147
|
end
|
150
148
|
|
151
149
|
def environment_hash
|
@@ -161,28 +159,30 @@ module SSHKit
|
|
161
159
|
end
|
162
160
|
|
163
161
|
def with(&_block)
|
164
|
-
|
165
|
-
|
162
|
+
env_string = environment_string
|
163
|
+
return yield if env_string.empty?
|
164
|
+
"( export #{env_string} ; #{yield} )"
|
166
165
|
end
|
167
166
|
|
168
167
|
def user(&_block)
|
169
168
|
return yield unless options[:user]
|
170
|
-
|
169
|
+
env_string = environment_string
|
170
|
+
"sudo -u #{options[:user].to_s.shellescape} #{env_string + " " unless env_string.empty?}-- sh -c #{yield.shellescape}"
|
171
171
|
end
|
172
172
|
|
173
173
|
def in_background(&_block)
|
174
174
|
return yield unless options[:run_in_background]
|
175
|
-
|
175
|
+
"( nohup #{yield} > /dev/null & )"
|
176
176
|
end
|
177
177
|
|
178
178
|
def umask(&_block)
|
179
179
|
return yield unless SSHKit.config.umask
|
180
|
-
|
180
|
+
"umask #{SSHKit.config.umask} && #{yield}"
|
181
181
|
end
|
182
182
|
|
183
183
|
def group(&_block)
|
184
184
|
return yield unless options[:group]
|
185
|
-
|
185
|
+
"sg #{options[:group].to_s.shellescape} -c #{yield.shellescape}"
|
186
186
|
# We could also use the so-called heredoc format perhaps:
|
187
187
|
#"newgrp #{options[:group]} <<EOC \\\"%s\\\" EOC" % %Q{#{yield}}
|
188
188
|
end
|
data/lib/sshkit/host.rb
CHANGED
@@ -151,18 +151,20 @@ module SSHKit
|
|
151
151
|
# @private
|
152
152
|
# :nodoc:
|
153
153
|
class IPv6HostWithPortParser < SimpleHostParser
|
154
|
+
IPV6_REGEX = /\[([a-fA-F0-9:]+)\](?:\:(\d+))?/
|
154
155
|
|
155
156
|
def self.suitable?(host_string)
|
156
|
-
host_string.match(
|
157
|
+
host_string.match(IPV6_REGEX)
|
157
158
|
end
|
158
159
|
|
159
160
|
def port
|
160
|
-
@host_string.
|
161
|
+
prt = @host_string.match(IPV6_REGEX)[2]
|
162
|
+
prt = prt.to_i unless prt.nil?
|
163
|
+
prt
|
161
164
|
end
|
162
165
|
|
163
166
|
def hostname
|
164
|
-
@host_string.
|
165
|
-
@host_string.split(':')[0..-2].join(':')
|
167
|
+
@host_string.match(IPV6_REGEX)[1]
|
166
168
|
end
|
167
169
|
|
168
170
|
end
|
data/lib/sshkit/version.rb
CHANGED
@@ -38,7 +38,7 @@ module SSHKit
|
|
38
38
|
"Command: /usr/bin/env ls -l\n",
|
39
39
|
"Command: if test ! -d /tmp; then echo \"Directory does not exist '/tmp'\" 1>&2; false; fi\n",
|
40
40
|
"Command: if ! sudo -u root whoami > /dev/null; then echo \"You cannot switch to user 'root' using sudo, please check the sudoers file\" 1>&2; false; fi\n",
|
41
|
-
"Command: cd /tmp && ( export RAILS_ENV=\"production\" ; sudo -u root RAILS_ENV=\"production\" -- sh -c
|
41
|
+
"Command: cd /tmp && ( export RAILS_ENV=\"production\" ; sudo -u root RAILS_ENV=\"production\" -- sh -c /usr/bin/env\\ touch\\ restart.txt )\n"
|
42
42
|
], command_lines
|
43
43
|
end
|
44
44
|
|
@@ -82,7 +82,7 @@ module SSHKit
|
|
82
82
|
command_lines = @output.lines.select { |line| line.start_with?('Command:') }
|
83
83
|
assert_equal [
|
84
84
|
"Command: if ! sudo -u root whoami > /dev/null; then echo \"You cannot switch to user 'root' using sudo, please check the sudoers file\" 1>&2; false; fi\n",
|
85
|
-
"Command: sudo -u root -- sh -c
|
85
|
+
"Command: sudo -u root -- sh -c sg\\ admin\\ -c\\ /usr/bin/env\\\\\\ touch\\\\\\ restart.txt\n"
|
86
86
|
], command_lines
|
87
87
|
end
|
88
88
|
|
@@ -96,21 +96,18 @@ module SSHKit
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def test_ssh_option_merge
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
{ paranoid: true }
|
103
|
-
end
|
104
|
-
a_host.ssh_options = verify_host_opt
|
99
|
+
keepalive_opt = { keepalive: true }
|
100
|
+
test_host = a_host.dup
|
101
|
+
test_host.ssh_options = keepalive_opt
|
105
102
|
host_ssh_options = {}
|
106
103
|
SSHKit::Backend::Netssh.config.ssh_options = { forward_agent: false }
|
107
|
-
Netssh.new(
|
104
|
+
Netssh.new(test_host) do |host|
|
108
105
|
capture(:uname)
|
109
106
|
host_ssh_options = host.ssh_options
|
110
107
|
end.run
|
111
|
-
assert_equal [:forward_agent, *
|
108
|
+
assert_equal [:forward_agent, *keepalive_opt.keys, :known_hosts, :logger, :password_prompt].sort, host_ssh_options.keys.sort
|
112
109
|
assert_equal false, host_ssh_options[:forward_agent]
|
113
|
-
assert_equal
|
110
|
+
assert_equal keepalive_opt.values.first, host_ssh_options[keepalive_opt.keys.first]
|
114
111
|
assert_instance_of SSHKit::Backend::Netssh::KnownHosts, host_ssh_options[:known_hosts]
|
115
112
|
end
|
116
113
|
|
@@ -46,10 +46,19 @@ class VagrantWrapper
|
|
46
46
|
user: vm['user'] || 'vagrant',
|
47
47
|
hostname: vm['hostname'] || 'localhost',
|
48
48
|
port: vm['port'] || '22',
|
49
|
-
password: vm['password'] || 'vagrant'
|
49
|
+
password: vm['password'] || 'vagrant',
|
50
|
+
ssh_options: host_verify_options
|
50
51
|
}
|
51
52
|
|
52
53
|
SSHKit::Host.new(host_options)
|
53
54
|
end
|
55
|
+
|
56
|
+
def host_verify_options
|
57
|
+
if Net::SSH::Version::MAJOR >= 5
|
58
|
+
{ verify_host_key: :never }
|
59
|
+
else
|
60
|
+
{ paranoid: false }
|
61
|
+
end
|
62
|
+
end
|
54
63
|
end
|
55
64
|
end
|
data/test/unit/test_command.rb
CHANGED
@@ -51,13 +51,13 @@ module SSHKit
|
|
51
51
|
def test_double_quotes_are_escaped_in_env
|
52
52
|
SSHKit.config = nil
|
53
53
|
c = Command.new(:rails, 'server', env: {foo: 'asdf"hjkl'})
|
54
|
-
assert_equal %{( export FOO="asdf
|
54
|
+
assert_equal %{( export FOO="asdf\\"hjkl" ; /usr/bin/env rails server )}, c.to_command
|
55
55
|
end
|
56
56
|
|
57
57
|
def test_percentage_symbol_handled_in_env
|
58
58
|
SSHKit.config = nil
|
59
59
|
c = Command.new(:rails, 'server', env: {foo: 'asdf%hjkl'}, user: "anotheruser")
|
60
|
-
assert_equal %{( export FOO="asdf%hjkl" ; sudo -u anotheruser FOO=\"asdf%hjkl\" -- sh -c
|
60
|
+
assert_equal %{( export FOO="asdf%hjkl" ; sudo -u anotheruser FOO=\"asdf%hjkl\" -- sh -c /usr/bin/env\\ rails\\ server )}, c.to_command
|
61
61
|
end
|
62
62
|
|
63
63
|
def test_including_the_env_doesnt_addressively_escape
|
@@ -84,6 +84,11 @@ module SSHKit
|
|
84
84
|
assert_equal "cd /opt/sites && /usr/bin/env ls -l", c.to_command
|
85
85
|
end
|
86
86
|
|
87
|
+
def test_working_in_a_given_weird_directory
|
88
|
+
c = Command.new(:ls, '-l', in: "/opt/sites and stuff")
|
89
|
+
assert_equal "cd /opt/sites\\ and\\ stuff && /usr/bin/env ls -l", c.to_command
|
90
|
+
end
|
91
|
+
|
87
92
|
def test_working_in_a_given_directory_with_env
|
88
93
|
c = Command.new(:ls, '-l', in: "/opt/sites", env: {a: :b})
|
89
94
|
assert_equal %{cd /opt/sites && ( export A="b" ; /usr/bin/env ls -l )}, c.to_command
|
@@ -97,17 +102,27 @@ module SSHKit
|
|
97
102
|
|
98
103
|
def test_working_as_a_given_user
|
99
104
|
c = Command.new(:whoami, user: :anotheruser)
|
100
|
-
assert_equal "sudo -u anotheruser -- sh -c
|
105
|
+
assert_equal "sudo -u anotheruser -- sh -c /usr/bin/env\\ whoami", c.to_command
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_working_as_a_given_weird_user
|
109
|
+
c = Command.new(:whoami, user: "mr space |")
|
110
|
+
assert_equal "sudo -u mr\\ space\\ \\| -- sh -c /usr/bin/env\\ whoami", c.to_command
|
101
111
|
end
|
102
112
|
|
103
113
|
def test_working_as_a_given_group
|
104
114
|
c = Command.new(:whoami, group: :devvers)
|
105
|
-
assert_equal 'sg devvers -c
|
115
|
+
assert_equal 'sg devvers -c /usr/bin/env\\ whoami', c.to_command
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_working_as_a_given_weird_group
|
119
|
+
c = Command.new(:whoami, group: "space | group")
|
120
|
+
assert_equal "sg space\\ \\|\\ group -c /usr/bin/env\\ whoami", c.to_command
|
106
121
|
end
|
107
122
|
|
108
123
|
def test_working_as_a_given_user_and_group
|
109
124
|
c = Command.new(:whoami, user: :anotheruser, group: :devvers)
|
110
|
-
assert_equal %Q(sudo -u anotheruser -- sh -c
|
125
|
+
assert_equal %Q(sudo -u anotheruser -- sh -c sg\\ devvers\\ -c\\ /usr/bin/env\\\\\\ whoami), c.to_command
|
111
126
|
end
|
112
127
|
|
113
128
|
def test_umask
|
@@ -125,13 +140,13 @@ module SSHKit
|
|
125
140
|
def test_umask_with_working_directory_and_user
|
126
141
|
SSHKit.config.umask = '007'
|
127
142
|
c = Command.new(:touch, 'somefile', in: '/var', user: 'alice')
|
128
|
-
assert_equal "cd /var && umask 007 && sudo -u alice -- sh -c
|
143
|
+
assert_equal "cd /var && umask 007 && sudo -u alice -- sh -c /usr/bin/env\\ touch\\ somefile", c.to_command
|
129
144
|
end
|
130
145
|
|
131
146
|
def test_umask_with_env_and_working_directory_and_user
|
132
147
|
SSHKit.config.umask = '007'
|
133
148
|
c = Command.new(:touch, 'somefile', user: 'bob', env: {a: 'b'}, in: '/var')
|
134
|
-
assert_equal %{cd /var && umask 007 && ( export A="b" ; sudo -u bob A="b" -- sh -c
|
149
|
+
assert_equal %{cd /var && umask 007 && ( export A="b" ; sudo -u bob A="b" -- sh -c /usr/bin/env\\ touch\\ somefile )}, c.to_command
|
135
150
|
end
|
136
151
|
|
137
152
|
def test_verbosity_defaults_to_logger_info
|
@@ -245,5 +260,10 @@ module SSHKit
|
|
245
260
|
assert_equal "whoami exit status: 1\nwhoami stdout: Nothing written\nwhoami stderr: Nothing written\n", error.message
|
246
261
|
end
|
247
262
|
|
263
|
+
def test_shares_same_uuid_before_and_after_redaction
|
264
|
+
command = Command.new(:whoami)
|
265
|
+
command_with_redaction = command.with_redaction
|
266
|
+
assert_equal command.uuid, command_with_redaction.uuid, "UUID should be stable before and after redaction"
|
267
|
+
end
|
248
268
|
end
|
249
269
|
end
|
data/test/unit/test_host.rb
CHANGED
@@ -56,6 +56,11 @@ module SSHKit
|
|
56
56
|
assert_equal '1fff:0:a88:85a3::ac1f', h.hostname
|
57
57
|
end
|
58
58
|
|
59
|
+
def test_does_not_confuse_ipv6_hosts_without_port_specification
|
60
|
+
h = Host.new '[2001:db8:85a3:8d3:1319:8a2e:370:7348]'
|
61
|
+
assert_equal '2001:db8:85a3:8d3:1319:8a2e:370:7348', h.hostname
|
62
|
+
end
|
63
|
+
|
59
64
|
def testing_host_casting_to_a_string
|
60
65
|
assert_equal "example.com", Host.new('user@example.com:1234').to_s
|
61
66
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sshkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Hambley
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-07-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ssh
|
@@ -181,6 +181,8 @@ extensions: []
|
|
181
181
|
extra_rdoc_files: []
|
182
182
|
files:
|
183
183
|
- ".gitignore"
|
184
|
+
- ".rubocop.yml"
|
185
|
+
- ".rubocop_todo.yml"
|
184
186
|
- ".travis.yml"
|
185
187
|
- ".yardopts"
|
186
188
|
- BREAKING_API_WISHLIST.md
|
@@ -284,7 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
284
286
|
- !ruby/object:Gem::Version
|
285
287
|
version: '0'
|
286
288
|
requirements: []
|
287
|
-
rubygems_version: 3.0.
|
289
|
+
rubygems_version: 3.0.4
|
288
290
|
signing_key:
|
289
291
|
specification_version: 4
|
290
292
|
summary: SSHKit makes it easy to write structured, testable SSH commands in Ruby
|