embulk-output-sftp 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b60e9f9177d328ee62002c1ebdcb195defa7eb1
4
- data.tar.gz: ca9c05c13f8095ca39e4b951c62e6179054cc970
3
+ metadata.gz: 51708045da5829301daa1d1d816688c262b6e932
4
+ data.tar.gz: 3fedac6d7f98845a1278beaba39de3cfd0722ff4
5
5
  SHA512:
6
- metadata.gz: 08a86e8657aee83ccb8b16c465ae9cfdb12f17351ee2f546199c3f087b4c589214847f66c293d846f1e582e85ccef2683c82254c96f403b8c82ba82a4a7a8426
7
- data.tar.gz: 04b6d71aea96667779340171de9e78c0a25b84bcdd8758def6f7c99e628cdd7f83121d402d3294ea6e30621fab057f60a4926f2bb4e3487dd30f5b98f7650e9c
6
+ metadata.gz: de3417dd58045d5c8bccc8b78896f1134bb320c0637207599ac974dec2032cb1a609244d95066008199f37194129c3fbe5d2d1b1dcd07a7996717669b08aa3c2
7
+ data.tar.gz: 8e4ca5ae5bc7fddc25ba4a1bdd26e29a2dd07488477ee5f166592bb8fc957276b669c5fd0b158a98c1f084de9cd87c45a50c806c644c306a9a018b121ff90c33
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ 0.1.9 (2018-04-26)
2
+ - Enhance: Add validation for "host" and "proxy.host"
3
+ - https://github.com/embulk/embulk-output-sftp/pull/48
1
4
  0.1.8 (2018-03-20)
2
5
  - Change input stream buffer size to 32MB to reduce number of storage reads
3
6
  - https://github.com/embulk/embulk-output-sftp/pull/47
data/build.gradle CHANGED
@@ -17,7 +17,7 @@ configurations {
17
17
  }
18
18
 
19
19
  group = "org.embulk.output.sftp"
20
- version = "0.1.8"
20
+ version = "0.1.9"
21
21
  sourceCompatibility = 1.7
22
22
  targetCompatibility = 1.7
23
23
 
@@ -81,6 +81,16 @@ public class SftpFileOutputPlugin
81
81
  FileOutputPlugin.Control control)
82
82
  {
83
83
  PluginTask task = config.loadConfig(PluginTask.class);
84
+ SftpUtils sftpUtils = null;
85
+ try {
86
+ sftpUtils = new SftpUtils(task);
87
+ sftpUtils.validateHost(task);
88
+ }
89
+ finally {
90
+ if (sftpUtils != null) {
91
+ sftpUtils.close();
92
+ }
93
+ }
84
94
 
85
95
  // retryable (idempotent) output:
86
96
  // return resume(task.dump(), taskCount, control);
@@ -35,6 +35,7 @@ public class SftpUtils
35
35
  private final DefaultFileSystemManager manager;
36
36
  private final FileSystemOptions fsOptions;
37
37
  private final String userInfo;
38
+ private final String user;
38
39
  private final String host;
39
40
  private final int port;
40
41
  private final int maxConnectionRetry;
@@ -127,6 +128,7 @@ public class SftpUtils
127
128
  {
128
129
  this.manager = initializeStandardFileSystemManager();
129
130
  this.userInfo = initializeUserInfo(task);
131
+ this.user = task.getUser();
130
132
  this.fsOptions = initializeFsOptions(task);
131
133
  this.host = task.getHost();
132
134
  this.port = task.getPort();
@@ -182,6 +184,9 @@ public class SftpUtils
182
184
  @Override
183
185
  public boolean isRetryableException(Exception exception)
184
186
  {
187
+ if (exception instanceof ConfigException) {
188
+ return false;
189
+ }
185
190
  return true;
186
191
  }
187
192
 
@@ -264,14 +269,28 @@ public class SftpUtils
264
269
  }
265
270
  }
266
271
 
272
+ public void validateHost(PluginTask task)
273
+ {
274
+ if (task.getHost().contains("%s")) {
275
+ throw new ConfigException("'host' can't contain spaces");
276
+ }
277
+ getSftpFileUri("/");
278
+
279
+ if (task.getProxy().isPresent() && task.getProxy().get().getHost().isPresent()) {
280
+ if (task.getProxy().get().getHost().get().contains("%s")) {
281
+ throw new ConfigException("'proxy.host' can't contains spaces");
282
+ }
283
+ }
284
+ }
285
+
267
286
  private URI getSftpFileUri(String remoteFilePath)
268
287
  {
269
288
  try {
270
289
  return new URI("sftp", userInfo, host, port, remoteFilePath, null, null);
271
290
  }
272
291
  catch (URISyntaxException e) {
273
- logger.error(e.getMessage());
274
- throw new ConfigException(e);
292
+ String message = String.format("URISyntaxException was thrown: Illegal character in sftp://%s:******@%s:%s%s", user, host, port, remoteFilePath);
293
+ throw new ConfigException(message);
275
294
  }
276
295
  }
277
296
 
@@ -247,6 +247,37 @@ public class TestSftpFileOutputPlugin
247
247
  }
248
248
  }
249
249
 
250
+ @Test(expected = ConfigException.class)
251
+ public void testInvalidHost()
252
+ {
253
+ // setting embulk config
254
+ final String pathPrefix = "/test/testUserPassword";
255
+ String configYaml = "" +
256
+ "type: sftp\n" +
257
+ "host: " + HOST + "\n" +
258
+ "user: " + USERNAME + "\n" +
259
+ "path_prefix: " + pathPrefix + "\n" +
260
+ "file_ext: txt\n" +
261
+ "formatter:\n" +
262
+ " type: csv\n" +
263
+ " newline: CRLF\n" +
264
+ " newline_in_field: LF\n" +
265
+ " header_line: true\n" +
266
+ " charset: UTF-8\n" +
267
+ " quote_policy: NONE\n" +
268
+ " quote: \"\\\"\"\n" +
269
+ " escape: \"\\\\\"\n" +
270
+ " null_string: \"\"\n" +
271
+ " default_timezone: 'UTC'";
272
+
273
+ ConfigSource config = getConfigFromYaml(configYaml);
274
+ config.set("host", HOST + " ");
275
+ PluginTask task = config.loadConfig(PluginTask.class);
276
+
277
+ SftpUtils utils = new SftpUtils(task);
278
+ utils.validateHost(task);
279
+ }
280
+
250
281
  @Test
251
282
  public void testConfigValuesIncludingDefault()
252
283
  {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-sftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Civitaspo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-03-20 00:00:00.000000000 Z
12
+ date: 2018-04-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement
@@ -78,7 +78,7 @@ files:
78
78
  - classpath/commons-io-2.6.jar
79
79
  - classpath/commons-logging-1.2.jar
80
80
  - classpath/commons-vfs2-2.2.jar
81
- - classpath/embulk-output-sftp-0.1.8.jar
81
+ - classpath/embulk-output-sftp-0.1.9.jar
82
82
  - classpath/jsch-0.1.54.jar
83
83
  homepage: https://github.com/embulk/embulk-output-sftp
84
84
  licenses:
Binary file