How to configure antisamy in cq 5.5?

后端 未结 1 1626
自闭症患者
自闭症患者 2021-01-03 08:47

I have cq 5.5 project.

I want to Prevent XSS attacks.

According this link cq provides integration with AntiSamy project.

Please provide concrete step

相关标签:
1条回答
  • 2021-01-03 08:52

    The XSS protection mechanism offered by CQ is already based on the AntiSamy Project. You only need to provide your custom antisamy configuration, in case the default configuration doesn't suit your needs.

    The default antisamy configuration is present at /libs/cq/xssprotection/config.xml, which can be overlaid with your custom config within /apps.

    You can make use of the XSS Protection API available in CQ, to protect your website from security attacks. The XSSAPI and the XSSFilter classes provide various methods to validate the given values.

    The xssAPI is available as an implicit object on inclusion of /libs/foundation/global.jsp, whereas the XSSFilter can be obtained and used as shown below.

    XSSFilter xssFilter = sling.getService(XSSFilter.class);
    String filteredString = xssFilter.filter(ProtectionContext.HTML_HTML_CONTENT,
                                dirtyInput, POLICY_FILE_LOCATION); 
    

    You can find some predefined policy files and steps to create a new configuration here.

    UPDATE:

    In case you do not want to use the XSS API, then you need to have the owasp esapi bundle installed in your instance, and then you can use the code mentioned in the question.

    0 讨论(0)
提交回复
热议问题