GithubHelp home page GithubHelp logo

Comments (10)

davewichers avatar davewichers commented on July 24, 2024 1

OK. I made it optional, and also added a few comments in the README on the new logging setup. I'd like @kwwall to review/test these changes w/ESAPI before I publish 1.6.1.

from antisamy.

kwwall avatar kwwall commented on July 24, 2024 1

@talios - The reason for this decision is that ESAPI, dating back to the earliest 2.x versions, delivered an AntiSamy policy file with an extraneous, never used '' node. And we assume that many ESAPI users have customized this and we do not wish to cause their policy files to fail, but still would like them to benefit from the XML schema checking.
However, not to long ago, when we phased out log4j 1.x as the default logger (because it had reached end-of-life), we made JUL the default ESAPI logger. (SLF4J was just new at the time and still having some of the bugs worked out.) So the problem is that if an application using ESAPI is using JUL rather than SLF4J, then when ESAPI invokes AntiSamy, AntiSamy ends up logging this:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

so they get no indication of what is going on at all if their old, possibly customized AntiSamy policy file schema validation fails, because if they are using JUL for ESAPI, they probably are not using SLF4J in their application either.

I was actually in favor of marking it optional, for the very reasons that you say, but Dave and I discussed it and decided together it would be best to make it required and allow the developers using AntiSamy to exclude it. Almost all the projects I deal with in my day job already exclude libraries in the Maven pom, so I don't think there's a big knowledge gap there.

from antisamy.

davewichers avatar davewichers commented on July 24, 2024

Thanks for reporting this issue so quickly. I have reimplemented the logging in the new 1.6.1 branch to only use slf4j. There are no imports or uses of log4j at all. I do import slf4j-simple so that AntiSamy logging will work if an app hasn't configured logging at all. But the importing app should be able to switch out the logger to whatever they want. Can you review/test this new 1.6.1 branch and let me know if you agree that these changes address your concerns?

from antisamy.

talios avatar talios commented on July 24, 2024

@davewichers I've just pulled the branch and building locally and everything seems to build fine on my project.

I think it may be better listing the slf4j-simple dependency with <optional>true</optional> :

https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html

Cheers

from antisamy.

davewichers avatar davewichers commented on July 24, 2024

@talios @kwwall - After testing AntiSamy with apps that don't have SLF4J enabled at all, we decided that we needed to include slf4j-simple (i.e., not make it optional). AntiSamy uses can still configure their slf4j setup to use a different logging library, but we need to include something that works, in case they don't have anything at all.

from antisamy.

talios avatar talios commented on July 24, 2024

Given that SLF4j uses class path scanning as its means of configuring bindings; generally you only include the binding you want your application to use. It's usually recommended for libraries to not depend on concrete bindings, merely the API package for this reason.

This will probably lead to forcing users who want logging to require adding <exclusion> elements against the dependency. An optional dependency should still work as expected, but should not cause Maven to fail to build if missing.

I'm not 100% on that, or the behaviour when you have multiple bindings on the classpath - I suspect that might end up using which ever it encounters first - which could be problematic; for me this isn't such as an issue as we configure global exclusions everywhere already.

I note the subsequent commits on the branch still leave src/main/resources/log4j2.xml included - which should probably be removed.

from antisamy.

talios avatar talios commented on July 24, 2024

Apologies if I came off as cold above - had a bad day at work :(

from antisamy.

kwwall avatar kwwall commented on July 24, 2024

@talios - Agree, both src/main/resources/log4j2.xml and src/test/resources/log4j2.xml should probably be removed. @davewichers - if you haven't pushed 1.6.1 to Maven Central yet, you may want to do this.

from antisamy.

talios avatar talios commented on July 24, 2024

@kwwall Cheers for the back-info - sounds all good then.

from antisamy.

davewichers avatar davewichers commented on July 24, 2024

This has been addressed in the 1.6.1 release that just went out. I removed the two log4j2.xml files as well.

from antisamy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.