-
Notifications
You must be signed in to change notification settings - Fork 43
fix: avoid deleting root filesystem when KANIKO_DIR not set #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e334b62
to
ee43ba7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
> **Note:** Envbuilder performs destructive filesystem operations! To guard against accidental data | ||
> loss, it will refuse to run if it detects that KANIKO_DIR is not set to a specific value. | ||
> If you need to bypass this behaviour for any reason, you can bypass this safety check by setting | ||
> `FORCE_SAFE=true`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love for us to start using the ENVBUILDER_
prefix for our envs, can we start now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do this in a separate PR. This isn't a new option, it's been there all the time but not doing anything.
|
||
// maybeDeleteFilesystem wraps util.DeleteFilesystem with a guard to hopefully stop | ||
// folks from unwittingly deleting their entire root directory. | ||
func maybeDeleteFilesystem(force bool) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this name ❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's technically correct!
Co-authored-by: Mathias Fredriksson <[email protected]>
Fixes #144
Running
envbuilder
outside of a container as root can result in it nuking your entire FS if you're not careful.Adds a check if
KANIKO_DIR
is not set toMagicDir
(a.k.a./.envbuilder
) and bails early.This behaviour can be overridden with
FORCE_SAFE=true
.