From 814bb4def03ee9aadb4aa8aa19e45213198f6ee4 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Mon, 26 Jun 2023 00:17:00 +0300 Subject: [PATCH] #1713 check for login and host --- .../com/rultor/agents/shells/RegistersShell.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/rultor/agents/shells/RegistersShell.java b/src/main/java/com/rultor/agents/shells/RegistersShell.java index 4af497159e..8153edac2e 100644 --- a/src/main/java/com/rultor/agents/shells/RegistersShell.java +++ b/src/main/java/com/rultor/agents/shells/RegistersShell.java @@ -97,6 +97,18 @@ public Iterable process(final XML xml) throws IOException { hash, this.shell.host(), this.shell.port(), xml.xpath("/talk/@name").get(0) ); + final String host = this.shell.host(); + if (host.isEmpty()) { + throw new Profile.ConfigException( + "SSH host is empty, it's a mistake" + ); + } + final String login = this.shell.login(); + if (login.isEmpty()) { + throw new Profile.ConfigException( + "SSH login is empty, it's a mistake" + ); + } final String key = this.shell.key(); if (key.isEmpty()) { throw new Profile.ConfigException( @@ -105,9 +117,9 @@ public Iterable process(final XML xml) throws IOException { } dirs.xpath("/talk").add("shell") .attr("id", hash) - .add("host").set(this.shell.host()).up() + .add("host").set(host).up() .add("port").set(Integer.toString(this.shell.port())).up() - .add("login").set(this.shell.login()).up() + .add("login").set(login).up() .add("key").set(key); } catch (final Profile.ConfigException ex) { dirs.xpath("/talk/daemon/script").set(