Giter Site home page Giter Site logo

Dangerous `rm -rf` in CLI about vapor HOT 7 CLOSED

vapor avatar vapor commented on April 27, 2024
Dangerous `rm -rf` in CLI

from vapor.

Comments (7)

tanner0101 avatar tanner0101 commented on April 27, 2024 1

Thanks @shnhrrsn. I'll merge this.

from vapor.

tanner0101 avatar tanner0101 commented on April 27, 2024

that seems like it would function normally unless I'm mistaken

from vapor.

zef avatar zef commented on April 27, 2024

Doing something like that would remove the user's root directory right? It's just that you can't expect people to know that an unchecked rm is going to be performed inside your command. It's not like people should be typing something like that on purpose, but if it was an accident or it somehow happened, it would be really terrible.

So basically I think it's the responsibility of a tool like this to make sure that kind of thing is not even possible. In this specific case maybe you could check that the directory exists and that it's a .git directory before running the command. Make sure there are no spaces in the name that's passed in, something like that.

Hope that helps!

from vapor.

tanner0101 avatar tanner0101 commented on April 27, 2024

If you do vapor new / it will create a new vapor project in the root directory of your application then remove the .git folder normally.

It can only delete something with .git after it. Also unless you ran it with sudo attempting to delete the root folder would be denied.

from vapor.

zef avatar zef commented on April 27, 2024

Thanks for the response... Last thing: the way it would delete something undesirable is if there was whitespace: vapor new / something would call rm -rf / something, and rm would execute for both / and something.git/. / is really just a placeholder for whatever undesirable thing you don't actually want deleted. Looking at the rest it might not get that far if the git clone failed due to weird arguments or something. Regardless just seems scary to me to pass that straight through without doing any checking.

from vapor.

tanner0101 avatar tanner0101 commented on April 27, 2024

Ah okay, I see what you mean. Yeah that would fail the git clone for sure.

from vapor.

tanner0101 avatar tanner0101 commented on April 27, 2024

People once thought it was scary to drive with tanks of explosive liquid attached to the bottom of their cars.

from vapor.

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.