GithubHelp home page GithubHelp logo

jsonc support about drogon HOT 4 CLOSED

Alexufo avatar Alexufo commented on June 2, 2024
jsonc support

from drogon.

Comments (4)

an-tao avatar an-tao commented on June 2, 2024

You should place the config.json file outside the document root folder.

from drogon.

marty1885 avatar marty1885 commented on June 2, 2024

This is definitely a weird request. As an alternative, if you are on OpenBSD or Linux. Just use unveil or landlock to whitelist directories the application is able to. See my repo abd blog post for details, You likely want to do something like the followning. Though I still think it is not ideal

unveil(app().getDocumentRoot().c_str(), "r");
unveil((app().getDocumentRoot() + "/config.json").c_str(), "");
unveil(app().getUploadPath().c_str(), "rwc");
// TODO: add more paths like /dev /etc as you likely need them
unveil(NULL, NULL);

Unveil API on Liinux
https://github.com/marty1885/landlock-unveil

OpenBSD unveil
https://man.openbsd.org/unveil.2

My post
https://clehaxze.tw/gemlog/2023/11-04-pledgeing-and-unveiling-the-drogon-web-application-framework.gmi

from drogon.

Alexufo avatar Alexufo commented on June 2, 2024

@marty1885

Thanks for the solution, it's interesting, but I need something platform independent.

The Drogon json config contains comments. This is not the correct json format. The json with comments has the file extension “jsonc”. Also the json config could potentially forget to add to the blacklist.

In my case, I add extension to the sources

 std::vector<std::string> JsonConfigAdapter::getExtensions() const
{
    return {“json”, “jsonc”}
}

from drogon.

Alexufo avatar Alexufo commented on June 2, 2024

You should place the config.json file outside the document root folder.

this is correct, in my case it is rest api, where with the executable file there is only docs folder with html. I didn't want the extra nesting for only one folder for the local distribution.

from drogon.

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.