embulk-input-sftp 0.2.9 → 0.2.10

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: b9e0c79f27fccf85103bbbfca4fe4230e16e564d
4
- data.tar.gz: 53b679a39dfddb526e44397781d6ef240652823f
3
+ metadata.gz: 9c33467b7d6bc31212b8814d3705f257ffd093ce
4
+ data.tar.gz: 1e7004637de8d3c897743eaebf6084356ef8b1eb
5
5
  SHA512:
6
- metadata.gz: fe0c37dad8a9b545d194b01b11b34a8cb745bcc48c3b85031b30caf839d40d2f5a32ccf4cfea976a85388333c0c7417b876a34aa49fb18cd8457fe6793eee9e8
7
- data.tar.gz: 1122f60a71055f2e390b96c5cc2fdd0b00c36607ccaf53d94301cfa21d3cf8dc09f6a0831de123c1b77942ffddc73b07c1db2f303a24ab954b6d9e38a83ce252
6
+ metadata.gz: 3bc6eeec14c63504e2f74096e9f4e25fab4e709ad982cab68bf817f6c1b03da9c76fcdd2753c4324b026f9d22bfb5ce0ac538acfc91a3916aeca54a4233741ec
7
+ data.tar.gz: 2675cda9d5683cb89a742e39ee9c418778670d4bf81845db215ac2c5e4898c46888c2fdd411d19a8313664870e68ba970059fa184654a23ad00ad2728f76ef08
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.2.10 - 2018-04-26
2
+ * [maintenance] Add validation for "host" and "proxy.host" [#31](https://github.com/embulk/embulk-input-sftp/pull/31)
3
+
1
4
  ## 0.2.9 - 2018-04-20
2
5
  * [maintenance] Throw ConfigException when process fails with "com.jcraft.jsch.JSchException: Auth fail" [#29](https://github.com/embulk/embulk-input-sftp/pull/29)
3
6
 
data/build.gradle CHANGED
@@ -16,7 +16,7 @@ configurations {
16
16
  }
17
17
 
18
18
  group = "org.embulk.input.sftp"
19
- version = "0.2.9"
19
+ version = "0.2.10"
20
20
 
21
21
  sourceCompatibility = 1.7
22
22
  targetCompatibility = 1.7
@@ -3,7 +3,6 @@ package org.embulk.input.sftp;
3
3
  import com.google.common.base.Function;
4
4
  import com.google.common.base.Optional;
5
5
  import com.google.common.base.Throwables;
6
- import com.jcraft.jsch.JSchException;
7
6
  import org.apache.commons.io.FilenameUtils;
8
7
  import org.apache.commons.lang3.StringUtils;
9
8
  import org.apache.commons.vfs2.FileObject;
@@ -138,6 +137,20 @@ public class SftpFileInput
138
137
  return fsOptions;
139
138
  }
140
139
 
140
+ public static void validateHost(PluginTask task)
141
+ {
142
+ if (task.getHost().contains("%s")) {
143
+ throw new ConfigException("'host' can't contain spaces");
144
+ }
145
+ getSftpFileUri(task, "/");
146
+
147
+ if (task.getProxy().isPresent() && task.getProxy().get().getHost().isPresent()) {
148
+ if (task.getProxy().get().getHost().get().contains("%s")) {
149
+ throw new ConfigException("'proxy.host' can't contains spaces");
150
+ }
151
+ }
152
+ }
153
+
141
154
  public static String getSftpFileUri(PluginTask task, String path)
142
155
  {
143
156
  try {
@@ -146,7 +159,9 @@ public class SftpFileInput
146
159
  return uri;
147
160
  }
148
161
  catch (URISyntaxException ex) {
149
- throw new ConfigException(ex);
162
+ String message = String.format("URISyntaxException was thrown: Illegal character in sftp://%s:******@%s:%s%s",
163
+ task.getUser(), task.getHost(), task.getPort(), path);
164
+ throw new ConfigException(message);
150
165
  }
151
166
  }
152
167
 
@@ -247,6 +262,9 @@ public class SftpFileInput
247
262
  @Override
248
263
  public boolean isRetryableException(Exception exception)
249
264
  {
265
+ if (exception instanceof ConfigException) {
266
+ return false;
267
+ }
250
268
  return true;
251
269
  }
252
270
 
@@ -270,7 +288,7 @@ public class SftpFileInput
270
288
  {
271
289
  // Generally, Auth fail should be caught and throw ConfigException when first retry. But this library is a bit unstable.
272
290
  // So we throw ConfigException after all retries are completed
273
- if (lastException.getCause().getCause() != null) {
291
+ if (lastException.getCause() != null && lastException.getCause().getCause() != null) {
274
292
  Throwable cause = lastException.getCause().getCause();
275
293
  if (cause.getMessage().contains("Auth fail")) {
276
294
  throw new ConfigException(lastException);
@@ -17,6 +17,7 @@ public class SftpFileInputPlugin
17
17
  public ConfigDiff transaction(ConfigSource config, FileInputPlugin.Control control)
18
18
  {
19
19
  PluginTask task = config.loadConfig(PluginTask.class);
20
+ SftpFileInput.validateHost(task);
20
21
 
21
22
  // list files recursively
22
23
  task.setFiles(SftpFileInput.listFilesByPrefix(task));
@@ -162,6 +162,20 @@ public class TestSftpFileInputPlugin
162
162
  runner.transaction(config, new Control());
163
163
  }
164
164
 
165
+ @Test(expected = ConfigException.class)
166
+ public void checkDefaultValuesHostIsInvalid()
167
+ {
168
+ ConfigSource config = Exec.newConfigSource()
169
+ .set("host", HOST + " ")
170
+ .set("user", null)
171
+ .set("password", PASSWORD)
172
+ .set("path_prefix", "")
173
+ .set("last_path", "")
174
+ .set("parser", parserConfig(schemaConfig()));
175
+
176
+ runner.transaction(config, new Control());
177
+ }
178
+
165
179
  @Test
166
180
  public void testResume()
167
181
  {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-sftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Satoshi Akama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-20 00:00:00.000000000 Z
11
+ date: 2018-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -72,7 +72,7 @@ files:
72
72
  - classpath/commons-io-2.6.jar
73
73
  - classpath/commons-logging-1.2.jar
74
74
  - classpath/commons-vfs2-2.2.jar
75
- - classpath/embulk-input-sftp-0.2.9.jar
75
+ - classpath/embulk-input-sftp-0.2.10.jar
76
76
  - classpath/jsch-0.1.54.jar
77
77
  homepage: https://github.com/embulk/embulk-input-sftp
78
78
  licenses: