]> source.dussan.org Git - gitblit.git/commitdiff
Create infrastructure for XSS sanitization
authorJames Moger <james.moger@gitblit.com>
Sat, 6 Sep 2014 15:25:42 +0000 (11:25 -0400)
committerJames Moger <james.moger@gitblit.com>
Sun, 7 Sep 2014 15:42:40 +0000 (11:42 -0400)
23 files changed:
.classpath
build.moxie
gitblit.iml
src/main/java/com/gitblit/DaggerModule.java
src/main/java/com/gitblit/FederationClient.java
src/main/java/com/gitblit/MigrateTickets.java
src/main/java/com/gitblit/ReindexTickets.java
src/main/java/com/gitblit/manager/GitblitManager.java
src/main/java/com/gitblit/manager/IRuntimeManager.java
src/main/java/com/gitblit/manager/RuntimeManager.java
src/main/java/com/gitblit/utils/JSoupXssFilter.java [new file with mode: 0644]
src/main/java/com/gitblit/utils/XssFilter.java [new file with mode: 0644]
src/main/java/com/gitblit/wicket/GitBlitWebApp.java
src/main/java/com/gitblit/wicket/GitblitWicketApp.java
src/test/java/com/gitblit/tests/AuthenticationManagerTest.java
src/test/java/com/gitblit/tests/BranchTicketServiceTest.java
src/test/java/com/gitblit/tests/FileTicketServiceTest.java
src/test/java/com/gitblit/tests/HtpasswdAuthenticationTest.java
src/test/java/com/gitblit/tests/LdapAuthenticationTest.java
src/test/java/com/gitblit/tests/LuceneExecutorTest.java
src/test/java/com/gitblit/tests/RedisTicketServiceTest.java
src/test/java/com/gitblit/tests/RedmineAuthenticationTest.java
src/test/java/com/gitblit/tests/mock/MockRuntimeManager.java

index f6e655e1be81d8c35bec2273e91da63c69c724ff..a6b40100e51779dca5798a0640275779aeb96a00 100644 (file)
@@ -77,6 +77,7 @@
        <classpathentry kind="lib" path="ext/commons-pool2-2.0.jar" sourcepath="ext/src/commons-pool2-2.0.jar" />
        <classpathentry kind="lib" path="ext/pf4j-0.8.0.jar" sourcepath="ext/src/pf4j-0.8.0.jar" />
        <classpathentry kind="lib" path="ext/tika-core-1.5.jar" sourcepath="ext/src/tika-core-1.5.jar" />
+       <classpathentry kind="lib" path="ext/jsoup-1.7.3.jar" sourcepath="ext/src/jsoup-1.7.3.jar" />
        <classpathentry kind="lib" path="ext/junit-4.11.jar" sourcepath="ext/src/junit-4.11.jar" />
        <classpathentry kind="lib" path="ext/hamcrest-core-1.3.jar" sourcepath="ext/src/hamcrest-core-1.3.jar" />
        <classpathentry kind="lib" path="ext/selenium-java-2.28.0.jar" sourcepath="ext/src/selenium-java-2.28.0.jar" />
index 0801644d79f462a08d84ebf85d4e4327c7853fed..c558c5204ea452041fa39ca96ec43e118c20e173 100644 (file)
@@ -176,6 +176,7 @@ dependencies:
 - compile 'redis.clients:jedis:2.3.1' :war
 - compile 'ro.fortsoft.pf4j:pf4j:0.8.0' :war
 - compile 'org.apache.tika:tika-core:1.5' :war
+- compile 'org.jsoup:jsoup:1.7.3' :war
 - test 'junit'
 # Dependencies for Selenium web page testing
 - test 'org.seleniumhq.selenium:selenium-java:${selenium.version}' @jar
index 03e2896a001886f0a99ffc28f6515255a02ee0f0..3e6608f0219cf651182788465a59f1b071e2160b 100644 (file)
         </SOURCES>
       </library>
     </orderEntry>
+    <orderEntry type="module-library">
+      <library name="jsoup-1.7.3.jar">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/ext/jsoup-1.7.3.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/ext/src/jsoup-1.7.3.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
     <orderEntry type="module-library" scope="TEST">
       <library name="junit-4.11.jar">
         <CLASSES>
index 6ad3fe632ffc318689f745e3507da5b2869d0255..dd7e1b2bed6fb1140d1d7db666cccb9a5e7147f8 100644 (file)
@@ -38,7 +38,9 @@ import com.gitblit.transport.ssh.FileKeyManager;
 import com.gitblit.transport.ssh.IPublicKeyManager;
 import com.gitblit.transport.ssh.MemoryKeyManager;
 import com.gitblit.transport.ssh.NullKeyManager;
+import com.gitblit.utils.JSoupXssFilter;
 import com.gitblit.utils.StringUtils;
+import com.gitblit.utils.XssFilter;
 import com.gitblit.wicket.GitBlitWebApp;
 
 import dagger.Module;
@@ -54,6 +56,7 @@ import dagger.Provides;
        library = true,
        injects = {
                        IStoredSettings.class,
+                       XssFilter.class,
 
                        // core managers
                        IRuntimeManager.class,
@@ -79,8 +82,12 @@ public class DaggerModule {
                return new FileSettings();
        }
 
-       @Provides @Singleton IRuntimeManager provideRuntimeManager(IStoredSettings settings) {
-               return new RuntimeManager(settings);
+       @Provides @Singleton XssFilter provideXssFilter() {
+               return new JSoupXssFilter();
+       }
+
+       @Provides @Singleton IRuntimeManager provideRuntimeManager(IStoredSettings settings, XssFilter xssFilter) {
+               return new RuntimeManager(settings, xssFilter);
        }
 
        @Provides @Singleton IPluginManager providePluginManager(IRuntimeManager runtimeManager) {
index 29cdefe691480c24c1e0634446e0d27454906531..079355efa9f89a6f27bfe0409e9c78e0280a34d9 100644 (file)
@@ -36,6 +36,8 @@ import com.gitblit.models.Mailing;
 import com.gitblit.service.FederationPullService;\r
 import com.gitblit.utils.FederationUtils;\r
 import com.gitblit.utils.StringUtils;\r
+import com.gitblit.utils.XssFilter;\r
+import com.gitblit.utils.XssFilter.AllowXssFilter;\r
 \r
 /**\r
  * Command-line client to pull federated Gitblit repositories.\r
@@ -92,7 +94,8 @@ public class FederationClient {
                }\r
 \r
                // configure the Gitblit singleton for minimal, non-server operation\r
-               RuntimeManager runtime = new RuntimeManager(settings, baseFolder).start();\r
+               XssFilter xssFilter = new AllowXssFilter();\r
+               RuntimeManager runtime = new RuntimeManager(settings, xssFilter, baseFolder).start();\r
                NoopNotificationManager notifications = new NoopNotificationManager().start();\r
                UserManager users = new UserManager(runtime, null).start();\r
                RepositoryManager repositories = new RepositoryManager(runtime, null, users).start();\r
index ad1c63ea5346b01eb9367c1d8ee8c3274ac5e7ae..94284ee2d27f566d4dfb42f3fbe12696ae3aa8fb 100644 (file)
@@ -39,6 +39,8 @@ import com.gitblit.tickets.FileTicketService;
 import com.gitblit.tickets.ITicketService;
 import com.gitblit.tickets.RedisTicketService;
 import com.gitblit.utils.StringUtils;
+import com.gitblit.utils.XssFilter;
+import com.gitblit.utils.XssFilter.AllowXssFilter;
 
 /**
  * A command-line tool to move all tickets from one ticket service to another.
@@ -134,7 +136,8 @@ public class MigrateTickets {
                settings.overrideSetting(Keys.web.activityCacheDays, 0);
                settings.overrideSetting(ITicketService.SETTING_UPDATE_DIFFSTATS, false);
 
-               IRuntimeManager runtimeManager = new RuntimeManager(settings, baseFolder).start();
+               XssFilter xssFilter = new AllowXssFilter();
+               IRuntimeManager runtimeManager = new RuntimeManager(settings, xssFilter, baseFolder).start();
                IRepositoryManager repositoryManager = new RepositoryManager(runtimeManager, null, null).start();
 
                String inputServiceName = settings.getString(Keys.tickets.service, BranchTicketService.class.getSimpleName());
index 5a614481133b3ea04cb35978b4acefbc688cff02..858436afb850ffff586c871c3dc5ba6c70516718 100644 (file)
@@ -33,6 +33,8 @@ import com.gitblit.tickets.FileTicketService;
 import com.gitblit.tickets.ITicketService;
 import com.gitblit.tickets.RedisTicketService;
 import com.gitblit.utils.StringUtils;
+import com.gitblit.utils.XssFilter;
+import com.gitblit.utils.XssFilter.AllowXssFilter;
 
 /**
  * A command-line tool to reindex all tickets in all repositories when the
@@ -126,7 +128,8 @@ public class ReindexTickets {
                settings.overrideSetting(Keys.git.enableMirroring, false);
                settings.overrideSetting(Keys.web.activityCacheDays, 0);
 
-               IRuntimeManager runtimeManager = new RuntimeManager(settings, baseFolder).start();
+               XssFilter xssFilter = new AllowXssFilter();
+               IRuntimeManager runtimeManager = new RuntimeManager(settings, xssFilter, baseFolder).start();
                IRepositoryManager repositoryManager = new RepositoryManager(runtimeManager, null, null).start();
 
                String serviceName = settings.getString(Keys.tickets.service, BranchTicketService.class.getSimpleName());
index b9ae122f1f1f427e5599f1649c052ccf0e4eda97..2ed52d67d2e92135f204864ac7623181bc2de5dd 100644 (file)
@@ -79,6 +79,7 @@ import com.gitblit.tickets.ITicketService;
 import com.gitblit.transport.ssh.IPublicKeyManager;
 import com.gitblit.transport.ssh.SshKey;
 import com.gitblit.utils.ArrayUtils;
+import com.gitblit.utils.XssFilter;
 import com.gitblit.utils.HttpUtils;
 import com.gitblit.utils.JsonUtils;
 import com.gitblit.utils.ObjectCache;
@@ -663,6 +664,11 @@ public class GitblitManager implements IGitblit {
                return runtimeManager.getStatus();
        }
 
+       @Override
+       public XssFilter getXssFilter() {
+               return runtimeManager.getXssFilter();
+       }
+
        /*
         * NOTIFICATION MANAGER
         */
index b2d7a2b3137f34c91f2698b314766ea9874663d5..132534c389a7f410f26cb7783f933e15d3377aa7 100644 (file)
@@ -24,6 +24,7 @@ import java.util.TimeZone;
 import com.gitblit.IStoredSettings;
 import com.gitblit.models.ServerSettings;
 import com.gitblit.models.ServerStatus;
+import com.gitblit.utils.XssFilter;
 
 public interface IRuntimeManager extends IManager {
 
@@ -151,4 +152,11 @@ public interface IRuntimeManager extends IManager {
         * @since 1.4.0
         */
        boolean updateSettings(Map<String, String> updatedSettings);
+
+       /**
+        * Returns the HTML sanitizer used to clean user content.
+        *
+        * @return the HTML sanitizer
+        */
+       XssFilter getXssFilter();
 }
\ No newline at end of file
index 9cdc64ebac830a77708199dae0303a9670bb42b8..219bf8019cc773cba50449d939c0e6a3d5c5c31c 100644 (file)
@@ -32,6 +32,7 @@ import com.gitblit.models.ServerSettings;
 import com.gitblit.models.ServerStatus;
 import com.gitblit.models.SettingModel;
 import com.gitblit.utils.StringUtils;
+import com.gitblit.utils.XssFilter;
 
 public class RuntimeManager implements IRuntimeManager {
 
@@ -39,6 +40,8 @@ public class RuntimeManager implements IRuntimeManager {
 
        private final IStoredSettings settings;
 
+       private final XssFilter xssFilter;
+
        private final ServerStatus serverStatus;
 
        private final ServerSettings settingsModel;
@@ -47,14 +50,15 @@ public class RuntimeManager implements IRuntimeManager {
 
        private TimeZone timezone;
 
-       public RuntimeManager(IStoredSettings settings) {
-               this(settings, null);
+       public RuntimeManager(IStoredSettings settings, XssFilter xssFilter) {
+               this(settings, xssFilter, null);
        }
 
-       public RuntimeManager(IStoredSettings settings, File baseFolder) {
+       public RuntimeManager(IStoredSettings settings, XssFilter xssFilter, File baseFolder) {
                this.settings = settings;
                this.settingsModel = new ServerSettings();
                this.serverStatus = new ServerStatus();
+               this.xssFilter = xssFilter;
                this.baseFolder = baseFolder == null ? new File("") : baseFolder;
        }
 
@@ -262,4 +266,15 @@ public class RuntimeManager implements IRuntimeManager {
                serverStatus.heapFree = Runtime.getRuntime().freeMemory();
                return serverStatus;
        }
+
+       /**
+        * Returns the XSS filter.
+        *
+        * @return the XSS filter
+        */
+       @Override
+       public XssFilter getXssFilter() {
+               return xssFilter;
+       }
+
 }
diff --git a/src/main/java/com/gitblit/utils/JSoupXssFilter.java b/src/main/java/com/gitblit/utils/JSoupXssFilter.java
new file mode 100644 (file)
index 0000000..b07bcb9
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2014 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gitblit.utils;
+
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.safety.Cleaner;
+import org.jsoup.safety.Whitelist;
+
+/**
+ * Implementation of an XSS filter based on JSoup.
+ *
+ * @author James Moger
+ *
+ */
+public class JSoupXssFilter implements XssFilter {
+
+        private final Cleaner none;
+
+        private final Cleaner relaxed;
+
+        public JSoupXssFilter() {
+                none = new Cleaner(Whitelist.none());
+                relaxed = new Cleaner(getRelaxedWhiteList());
+       }
+
+       @Override
+       public String none(String input) {
+               return clean(input, none);
+       }
+
+       @Override
+       public String relaxed(String input) {
+               return clean(input, relaxed);
+       }
+
+       protected String clean(String input, Cleaner cleaner) {
+               Document unsafe = Jsoup.parse(input);
+               Document safe = cleaner.clean(unsafe);
+               return safe.body().html();
+       }
+
+       /**
+        * Builds & returns a loose HTML whitelist similar to Github.
+        *
+        * https://github.com/github/markup/tree/master#html-sanitization
+        * @return a loose HTML whitelist
+        */
+       protected Whitelist getRelaxedWhiteList() {
+               return new Whitelist()
+        .addTags(
+                "a", "b", "blockquote", "br", "caption", "cite", "code", "col",
+                "colgroup", "dd", "del", "div", "dl", "dt", "em", "h1", "h2", "h3", "h4", "h5", "h6", "hr",
+                "i", "img", "ins", "kbd", "li", "ol", "p", "pre", "q", "samp", "small", "strike", "strong",
+                "sub", "sup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "tt", "u",
+                "ul", "var")
+
+        .addAttributes("a", "href", "title")
+        .addAttributes("blockquote", "cite")
+        .addAttributes("col", "span", "width")
+        .addAttributes("colgroup", "span", "width")
+        .addAttributes("img", "align", "alt", "height", "src", "title", "width")
+        .addAttributes("ol", "start", "type")
+        .addAttributes("q", "cite")
+        .addAttributes("table", "summary", "width")
+        .addAttributes("td", "abbr", "axis", "colspan", "rowspan", "width")
+        .addAttributes("th", "abbr", "axis", "colspan", "rowspan", "scope", "width")
+        .addAttributes("ul", "type")
+
+        .addEnforcedAttribute("a", "rel", "nofollow")
+        ;
+       }
+
+}
diff --git a/src/main/java/com/gitblit/utils/XssFilter.java b/src/main/java/com/gitblit/utils/XssFilter.java
new file mode 100644 (file)
index 0000000..20b5105
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2014 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gitblit.utils;
+
+/**
+ * Defines the contract for an XSS filter implementation.
+ *
+ * @author James Moger
+ *
+ */
+public interface XssFilter {
+
+       /**
+        * Returns a filtered version of the input value that contains no html
+        * elements.
+        *
+        * @param input
+        * @return a plain text value
+        */
+       String none(String input);
+
+       /**
+        * Returns a filtered version of the input that contains structural html
+        * elements.
+        *
+        * @param input
+        * @return a filtered html value
+        */
+       String relaxed(String input);
+
+       /**
+        * A NOOP XSS filter.
+        *
+        * @author James Moger
+        *
+        */
+       public class AllowXssFilter implements XssFilter {
+
+               @Override
+               public String none(String input) {
+                       return input;
+               }
+
+               @Override
+               public String relaxed(String input) {
+                       return input;
+               }
+
+       }
+
+}
index f63ff3d9499d460aedeadda8eaaca9f4d8a7b32d..6cf5f582cdb8bc283fda76f5a437e1913f1836de 100644 (file)
@@ -46,6 +46,7 @@ import com.gitblit.manager.IRuntimeManager;
 import com.gitblit.manager.IUserManager;
 import com.gitblit.tickets.ITicketService;
 import com.gitblit.transport.ssh.IPublicKeyManager;
+import com.gitblit.utils.XssFilter;
 import com.gitblit.wicket.pages.ActivityPage;
 import com.gitblit.wicket.pages.BlamePage;
 import com.gitblit.wicket.pages.BlobDiffPage;
@@ -100,6 +101,8 @@ public class GitBlitWebApp extends WebApplication implements GitblitWicketApp {
 
        private final IStoredSettings settings;
 
+       private final XssFilter xssFilter;
+
        private final IRuntimeManager runtimeManager;
 
        private final IPluginManager pluginManager;
@@ -134,6 +137,7 @@ public class GitBlitWebApp extends WebApplication implements GitblitWicketApp {
 
                super();
                this.settings = runtimeManager.getSettings();
+               this.xssFilter = runtimeManager.getXssFilter();
                this.runtimeManager = runtimeManager;
                this.pluginManager = pluginManager;
                this.notificationManager = notificationManager;
@@ -307,6 +311,14 @@ public class GitBlitWebApp extends WebApplication implements GitblitWicketApp {
                return settings;
        }
 
+       /* (non-Javadoc)
+        * @see com.gitblit.wicket.Webapp#xssFilter()
+        */
+       @Override
+       public XssFilter xssFilter() {
+               return xssFilter;
+       }
+
        /* (non-Javadoc)
         * @see com.gitblit.wicket.Webapp#isDebugMode()
         */
index a56e6996fcbc62d060fe44f34ee61e95001ea68c..8d3d598d8e1c3783f056e433bb141ea4f4575539 100644 (file)
@@ -17,6 +17,7 @@ import com.gitblit.manager.IRuntimeManager;
 import com.gitblit.manager.IUserManager;
 import com.gitblit.tickets.ITicketService;
 import com.gitblit.transport.ssh.IPublicKeyManager;
+import com.gitblit.utils.XssFilter;
 
 public interface GitblitWicketApp {
 
@@ -30,6 +31,8 @@ public interface GitblitWicketApp {
 
        public abstract IStoredSettings settings();
 
+       public abstract XssFilter xssFilter();
+
        /**
         * Is Gitblit running in debug mode?
         *
index f1d2711e0d27b9d869321956ab6eaaa1921767e5..0cdee6cbf31f49b62307fc337c44b9cf4a273144 100644 (file)
@@ -26,6 +26,8 @@ import com.gitblit.manager.RuntimeManager;
 import com.gitblit.manager.UserManager;
 import com.gitblit.models.UserModel;
 import com.gitblit.tests.mock.MemorySettings;
+import com.gitblit.utils.XssFilter;
+import com.gitblit.utils.XssFilter.AllowXssFilter;
 
 /**
  * Class for testing local authentication.
@@ -42,7 +44,8 @@ public class AuthenticationManagerTest extends GitblitUnitTest {
     }
 
     IAuthenticationManager newAuthenticationManager() {
-       RuntimeManager runtime = new RuntimeManager(getSettings(), GitBlitSuite.BASEFOLDER).start();
+       XssFilter xssFilter = new AllowXssFilter();
+       RuntimeManager runtime = new RuntimeManager(getSettings(), xssFilter, GitBlitSuite.BASEFOLDER).start();
        users = new UserManager(runtime, null).start();
        AuthenticationManager auth = new AuthenticationManager(runtime, users).start();
        return auth;
index cc404abf84458fc19716120791e6535f7c5b96c5..0a5de1961d79fa3cd71c726f66899b2699d6264d 100644 (file)
@@ -29,6 +29,8 @@ import com.gitblit.manager.UserManager;
 import com.gitblit.models.RepositoryModel;
 import com.gitblit.tickets.BranchTicketService;
 import com.gitblit.tickets.ITicketService;
+import com.gitblit.utils.XssFilter;
+import com.gitblit.utils.XssFilter.AllowXssFilter;
 
 /**
  * Tests the branch ticket service.
@@ -50,8 +52,8 @@ public class BranchTicketServiceTest extends TicketServiceTest {
        protected ITicketService getService(boolean deleteAll) throws Exception {
 
                IStoredSettings settings = getSettings(deleteAll);
-
-               IRuntimeManager runtimeManager = new RuntimeManager(settings).start();
+               XssFilter xssFilter = new AllowXssFilter();
+               IRuntimeManager runtimeManager = new RuntimeManager(settings, xssFilter).start();
                IPluginManager pluginManager = new PluginManager(runtimeManager).start();
                INotificationManager notificationManager = new NotificationManager(settings).start();
                IUserManager userManager = new UserManager(runtimeManager, pluginManager).start();
index 6ede042a0475e9563332d2cb28165e0318db184d..1fb2eed96f705580cbe418701a7ed6ce0d88ec30 100644 (file)
@@ -29,6 +29,8 @@ import com.gitblit.manager.UserManager;
 import com.gitblit.models.RepositoryModel;
 import com.gitblit.tickets.FileTicketService;
 import com.gitblit.tickets.ITicketService;
+import com.gitblit.utils.XssFilter;
+import com.gitblit.utils.XssFilter.AllowXssFilter;
 
 /**
  * Tests the file ticket service.
@@ -49,8 +51,8 @@ public class FileTicketServiceTest extends TicketServiceTest {
        protected ITicketService getService(boolean deleteAll) throws Exception {
 
                IStoredSettings settings = getSettings(deleteAll);
-
-               IRuntimeManager runtimeManager = new RuntimeManager(settings).start();
+               XssFilter xssFilter = new AllowXssFilter();
+               IRuntimeManager runtimeManager = new RuntimeManager(settings, xssFilter).start();
                IPluginManager pluginManager = new PluginManager(runtimeManager).start();
                INotificationManager notificationManager = new NotificationManager(settings).start();
                IUserManager userManager = new UserManager(runtimeManager, pluginManager).start();
index f4e24d4e08af5b4f08cbc2cd4ac0149bda384d40..e2bb764eab17873fdaa638f94aaf80f9dbd1496b 100644 (file)
@@ -32,6 +32,8 @@ import com.gitblit.manager.RuntimeManager;
 import com.gitblit.manager.UserManager;
 import com.gitblit.models.UserModel;
 import com.gitblit.tests.mock.MemorySettings;
+import com.gitblit.utils.XssFilter;
+import com.gitblit.utils.XssFilter.AllowXssFilter;
 
 /**
  * Test the Htpasswd user service.
@@ -74,7 +76,8 @@ public class HtpasswdAuthenticationTest extends GitblitUnitTest {
     }
 
     private HtpasswdAuthProvider newHtpasswdAuthentication(IStoredSettings settings) {
-       RuntimeManager runtime = new RuntimeManager(settings, GitBlitSuite.BASEFOLDER).start();
+       XssFilter xssFilter = new AllowXssFilter();
+       RuntimeManager runtime = new RuntimeManager(settings, xssFilter, GitBlitSuite.BASEFOLDER).start();
        UserManager users = new UserManager(runtime, null).start();
        HtpasswdAuthProvider htpasswd = new HtpasswdAuthProvider();
        htpasswd.setup(runtime, users);
@@ -82,7 +85,8 @@ public class HtpasswdAuthenticationTest extends GitblitUnitTest {
     }
 
     private AuthenticationManager newAuthenticationManager(IStoredSettings settings) {
-       RuntimeManager runtime = new RuntimeManager(settings, GitBlitSuite.BASEFOLDER).start();
+       XssFilter xssFilter = new AllowXssFilter();
+       RuntimeManager runtime = new RuntimeManager(settings, xssFilter, GitBlitSuite.BASEFOLDER).start();
        UserManager users = new UserManager(runtime, null).start();
        HtpasswdAuthProvider htpasswd = new HtpasswdAuthProvider();
        htpasswd.setup(runtime, users);
index 646f7e9ffa1f1148f63c6b61a7c9f9e4276ad5e3..7c84ecc2e905e8466ade8d86a70307c9a525d5be 100644 (file)
@@ -39,6 +39,8 @@ import com.gitblit.manager.UserManager;
 import com.gitblit.models.TeamModel;
 import com.gitblit.models.UserModel;
 import com.gitblit.tests.mock.MemorySettings;
+import com.gitblit.utils.XssFilter;
+import com.gitblit.utils.XssFilter.AllowXssFilter;
 import com.unboundid.ldap.listener.InMemoryDirectoryServer;
 import com.unboundid.ldap.listener.InMemoryDirectoryServerConfig;
 import com.unboundid.ldap.listener.InMemoryListenerConfig;
@@ -96,7 +98,8 @@ public class LdapAuthenticationTest extends GitblitUnitTest {
        }
 
        private LdapAuthProvider newLdapAuthentication(IStoredSettings settings) {
-               RuntimeManager runtime = new RuntimeManager(settings, GitBlitSuite.BASEFOLDER).start();
+               XssFilter xssFilter = new AllowXssFilter();
+               RuntimeManager runtime = new RuntimeManager(settings, xssFilter, GitBlitSuite.BASEFOLDER).start();
                userManager = new UserManager(runtime, null).start();
                LdapAuthProvider ldap = new LdapAuthProvider();
                ldap.setup(runtime, userManager);
@@ -104,7 +107,8 @@ public class LdapAuthenticationTest extends GitblitUnitTest {
        }
 
        private AuthenticationManager newAuthenticationManager(IStoredSettings settings) {
-               RuntimeManager runtime = new RuntimeManager(settings, GitBlitSuite.BASEFOLDER).start();
+               XssFilter xssFilter = new AllowXssFilter();
+               RuntimeManager runtime = new RuntimeManager(settings, xssFilter, GitBlitSuite.BASEFOLDER).start();
                AuthenticationManager auth = new AuthenticationManager(runtime, userManager);
                auth.addAuthenticationProvider(newLdapAuthentication(settings));
                return auth;
index 5c319e6591d0a33b50a15f68e0f0425ad02e20ec..a8358b99f50a72afd5ff62f1c0f7638a3435d8e8 100644 (file)
@@ -34,6 +34,8 @@ import com.gitblit.service.LuceneService;
 import com.gitblit.tests.mock.MemorySettings;\r
 import com.gitblit.utils.FileUtils;\r
 import com.gitblit.utils.JGitUtils;\r
+import com.gitblit.utils.XssFilter;\r
+import com.gitblit.utils.XssFilter.AllowXssFilter;\r
 \r
 /**\r
  * Tests Lucene indexing and querying.\r
@@ -48,7 +50,8 @@ public class LuceneExecutorTest extends GitblitUnitTest {
        private LuceneService newLuceneExecutor() {\r
                MemorySettings settings = new MemorySettings();\r
                settings.put(Keys.git.repositoriesFolder, GitBlitSuite.REPOSITORIES);\r
-               RuntimeManager runtime = new RuntimeManager(settings, GitBlitSuite.BASEFOLDER).start();\r
+               XssFilter xssFilter = new AllowXssFilter();\r
+               RuntimeManager runtime = new RuntimeManager(settings, xssFilter, GitBlitSuite.BASEFOLDER).start();\r
                UserManager users = new UserManager(runtime, null).start();\r
                RepositoryManager repos = new RepositoryManager(runtime, null, users);\r
                return new LuceneService(settings, repos);\r
index b782b4495ef7a9e9edd97673ac2823fca243ed92..48011ade259ad86c35c4b25ee865ebe8aa5f3a56 100644 (file)
@@ -30,6 +30,8 @@ import com.gitblit.manager.UserManager;
 import com.gitblit.models.RepositoryModel;
 import com.gitblit.tickets.ITicketService;
 import com.gitblit.tickets.RedisTicketService;
+import com.gitblit.utils.XssFilter;
+import com.gitblit.utils.XssFilter.AllowXssFilter;
 
 /**
  * Tests the Redis ticket service.
@@ -57,8 +59,8 @@ public class RedisTicketServiceTest extends TicketServiceTest {
        protected ITicketService getService(boolean deleteAll) throws Exception {
 
                IStoredSettings settings = getSettings(deleteAll);
-
-               IRuntimeManager runtimeManager = new RuntimeManager(settings).start();
+               XssFilter xssFilter = new AllowXssFilter();
+               IRuntimeManager runtimeManager = new RuntimeManager(settings, xssFilter).start();
                IPluginManager pluginManager = new PluginManager(runtimeManager).start();
                INotificationManager notificationManager = new NotificationManager(settings).start();
                IUserManager userManager = new UserManager(runtimeManager, pluginManager).start();
index 3b6b7bbaccd00e8f4135b061efc1c2e37f58839d..ad773b7a58dec6d51db927530f3752effd62098a 100644 (file)
@@ -13,6 +13,8 @@ import com.gitblit.manager.RuntimeManager;
 import com.gitblit.manager.UserManager;
 import com.gitblit.models.UserModel;
 import com.gitblit.tests.mock.MemorySettings;
+import com.gitblit.utils.XssFilter;
+import com.gitblit.utils.XssFilter.AllowXssFilter;
 
 public class RedmineAuthenticationTest extends GitblitUnitTest {
 
@@ -25,7 +27,8 @@ public class RedmineAuthenticationTest extends GitblitUnitTest {
     }
 
     RedmineAuthProvider newRedmineAuthentication(IStoredSettings settings) {
-       RuntimeManager runtime = new RuntimeManager(settings, GitBlitSuite.BASEFOLDER).start();
+       XssFilter xssFilter = new AllowXssFilter();
+       RuntimeManager runtime = new RuntimeManager(settings, xssFilter, GitBlitSuite.BASEFOLDER).start();
        UserManager users = new UserManager(runtime, null).start();
        RedmineAuthProvider redmine = new RedmineAuthProvider();
        redmine.setup(runtime, users);
@@ -37,7 +40,8 @@ public class RedmineAuthenticationTest extends GitblitUnitTest {
     }
 
     AuthenticationManager newAuthenticationManager() {
-       RuntimeManager runtime = new RuntimeManager(getSettings(), GitBlitSuite.BASEFOLDER).start();
+       XssFilter xssFilter = new AllowXssFilter();
+       RuntimeManager runtime = new RuntimeManager(getSettings(), xssFilter, GitBlitSuite.BASEFOLDER).start();
        UserManager users = new UserManager(runtime, null).start();
        RedmineAuthProvider redmine = new RedmineAuthProvider();
        redmine.setup(runtime, users);
index 54be539fa61cfde7bc7d3b020fc02535fde0a412..7b563622420203a3c625327962af5eb67a290c75 100644 (file)
@@ -28,6 +28,8 @@ import com.gitblit.manager.IRuntimeManager;
 import com.gitblit.models.ServerSettings;
 import com.gitblit.models.ServerStatus;
 import com.gitblit.models.SettingModel;
+import com.gitblit.utils.XssFilter;
+import com.gitblit.utils.XssFilter.AllowXssFilter;
 
 public class MockRuntimeManager implements IRuntimeManager {
 
@@ -147,6 +149,11 @@ public class MockRuntimeManager implements IRuntimeManager {
                return settings;
        }
 
+       @Override
+       public XssFilter getXssFilter() {
+               return new AllowXssFilter();
+       }
+
        @Override
        public boolean updateSettings(Map<String, String> updatedSettings) {
                return settings.saveSettings(updatedSettings);