Search in sources :

Example 11 with OnmsFilterFavorite

use of org.opennms.netmgt.model.OnmsFilterFavorite in project opennms by OpenNMS.

the class FilterFavoriteServiceIT method verifyXSSPreventionOnCreate.

@Test
public void verifyXSSPreventionOnCreate() throws FilterFavoriteService.FilterFavoriteException {
    final String maliciousName = "test<script>alert(123);</script>";
    final String maliciousFilter = "filter=severity=6<script>alert(123);</script>";
    for (Page page : Page.values()) {
        // try to create malicious favorites
        OnmsFilterFavorite favorite = service.createFavorite("ulf", maliciousName, maliciousFilter, page);
        // verify that filter name and criteria are not vulnerable to xss
        Assert.assertEquals(WebSecurityUtils.sanitizeString(maliciousName), favorite.getName());
        Assert.assertEquals(WebSecurityUtils.sanitizeString(maliciousFilter), favorite.getFilter());
    }
}
Also used : Page(org.opennms.netmgt.model.OnmsFilterFavorite.Page) OnmsFilterFavorite(org.opennms.netmgt.model.OnmsFilterFavorite) Test(org.junit.Test)

Example 12 with OnmsFilterFavorite

use of org.opennms.netmgt.model.OnmsFilterFavorite in project opennms by OpenNMS.

the class AlarmFilterController method index.

// index view
public ModelAndView index(HttpServletRequest request, HttpServletResponse response) throws Exception {
    List<OnmsFilterFavorite> userFilterList = favoriteService.getFavorites(request.getRemoteUser(), OnmsFilterFavorite.Page.ALARM);
    ModelAndView modelAndView = new ModelAndView("alarm/index");
    modelAndView.addObject("favorites", userFilterList.toArray());
    modelAndView.addObject("callback", getFilterCallback());
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) OnmsFilterFavorite(org.opennms.netmgt.model.OnmsFilterFavorite)

Aggregations

OnmsFilterFavorite (org.opennms.netmgt.model.OnmsFilterFavorite)12 ModelAndView (org.springframework.web.servlet.ModelAndView)4 Test (org.junit.Test)3 Page (org.opennms.netmgt.model.OnmsFilterFavorite.Page)3 FilterFavoriteService (org.opennms.web.services.FilterFavoriteService)2 Before (org.junit.Before)1 DatabasePopulator (org.opennms.netmgt.dao.DatabasePopulator)1 DaoSupport (org.opennms.netmgt.dao.DatabasePopulator.DaoSupport)1 FilterFavoriteDao (org.opennms.netmgt.dao.api.FilterFavoriteDao)1