Code Monkey home page Code Monkey logo

Comments (2)

GaborFarkas avatar GaborFarkas commented on June 17, 2024

Yes, there is. createRegistry is privileged, so it - and only it - can access the protected idCounter variable. idCounter is protected, because the whole layer tree management relies on the uniqueness of layer IDs. This uniqueness is only guaranteed until idCounter is protected. After then, the idCounter will be accessible (rewritable) from outside of the layer tree object, thus it can be compromised (it will be vulnerable).

This can be a real problem, when you aren't the only developer of your code, and one of your colleagues accidentally uses idCounter in a non intended way, breaking the rest of the logic of the layer tree. In another scenario, you finish your code, return to it after a year or two, forget about the unprotected variable, and you use it in a non intended way. This can lead to a debug hell (especially if you don't have unit tests) taking several valuable days out of your hands.

from mastering_openlayers3.

WillieMaddox avatar WillieMaddox commented on June 17, 2024

Ok, I see that now. Other than wrapping a prototype.createRegistry in a closure (which would probably be overkill), I haven't found a clean way to move it out of the constructor. It would be nice to have another implementation option here, but the way you did it seems to be the only truly secure way.

Thanks for the feedback.

from mastering_openlayers3.

Related Issues (14)

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.