# HG changeset patch # User victory.bedrosova # Date 1615474932 -3600 # Node ID 471eaf5420c88c2541477202546bffe6886458cc # Parent 4b6661db8a8aa604c983e0211c250ebff04124e3 moved tests to the proper class, added logging diff -r 4b6661db8a8a -r 471eaf5420c8 mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialUrlSupport.java --- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialUrlSupport.java Thu Mar 11 15:32:03 2021 +0100 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialUrlSupport.java Thu Mar 11 16:02:12 2021 +0100 @@ -81,6 +81,7 @@ TestConnectionSupport testConnectionSupport = myVcsSupport.getTestConnectionSupport(); testConnectionSupport.testConnection(new VcsRootImpl(-1, res)); } catch (VcsException e) { + Loggers.VCS.infoAndDebugDetails("Failed to recognize " + fetchUrl + " as a Mercurial VCS root", e); return null; } } diff -r 4b6661db8a8a -r 471eaf5420c8 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootTest.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootTest.java Thu Mar 11 15:32:03 2021 +0100 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootTest.java Thu Mar 11 16:02:12 2021 +0100 @@ -175,6 +175,28 @@ assertEquals(customConfig, new HgVcsRoot(root).getCustomHgConfigServer()); } + @TestFor(issues = "TW-70054") + public void exception_on_command_injection() throws Exception { + try { + new HgVcsRoot(vcsRoot().withUrl("--config=hooks.pre-identify=whoami>/tmp/JRNJRN").build()); + } catch (IllegalArgumentException e) { + // expected + return; + } + fail("Expection not thrown "); + } + + @TestFor(issues = "TW-70541") + public void exception_on_command_injection_cwd() throws Exception { + try { + new HgVcsRoot(vcsRoot().withUrl("--cwd=/home/user/.BuildServer/system/artifacts/Test/bad_artifact/411/").build()); + } catch (IllegalArgumentException e) { + // expected + return; + } + fail("Expection not thrown "); + } + private VcsRootImpl createVcsRoot(String url) { return createVcsRoot(url, "user", "pwd"); } diff -r 4b6661db8a8a -r 471eaf5420c8 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialUrlSupportTest.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialUrlSupportTest.java Thu Mar 11 15:32:03 2021 +0100 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialUrlSupportTest.java Thu Mar 11 16:02:12 2021 +0100 @@ -16,7 +16,6 @@ package jetbrains.buildServer.buildTriggers.vcs.mercurial; -import jetbrains.buildServer.util.TestFor; import jetbrains.buildServer.vcs.Credentials; import jetbrains.buildServer.vcs.VcsException; import jetbrains.buildServer.vcs.VcsUrl; @@ -77,26 +76,4 @@ Map props = myUrlSupport.convertToVcsRootProperties(url); assertNull(props); } - - @TestFor(issues = "TW-70054") - public void exception_on_command_injection() throws VcsException { - try { - myUrlSupport.convertToVcsRootProperties(new VcsUrl("--config=hooks.pre-identify=whoami>/tmp/JRNJRN")); - } catch (IllegalArgumentException e) { - // expected - return; - } - fail("Expection not thrown "); - } - - @TestFor(issues = "TW-70541") - public void exception_on_command_injection_cwd() throws VcsException { - try { - myUrlSupport.convertToVcsRootProperties(new VcsUrl("--cwd=/home/user/.BuildServer/system/artifacts/Test/bad_artifact/411/")); - } catch (IllegalArgumentException e) { - // expected - return; - } - fail("Expection not thrown "); - } }