News for hackers. Stuff that matters.
Re:Minify your container by sockmeistr on Wednesday August 03, 2022 @02:17PM (#32335127)
Isn't this incredibly dangerous? I know everyone likes to pretend they have perfect code coverage, but just ripping stuff out that wasn't called during 'probing' feels like the perfect way to make rare code paths even more dangerous.
Re:Minify your container by OMGWTF on Wednesday August 03, 2022 @04:34PM (#32336384)
kkrieger (https://www.pouet.net/prod.php?which=12036) is an impressive 3D shooter in only 96 KiloBytes. As one of their optimization techniques they recorded all code paths and discarded unused parts. At least in the first version this was why you could only use CursorDown in the menus and CursorUp did not work.
Re:Minify your container by saurik on Wednesday August 03, 2022 @07:45PM (#32337737)
I can't tell if this is praise or condemnation by demonstration ;P.
Re:Minify your container by xdennis on Wednesday August 03, 2022 @08:15PM (#32337922)
My guess is: praise for kkrieger for its tiny size, and condemnation by demonstration because kkrieger was known to have bugs because of the usage of that technique.
Re:Minify your container by jamesfinlayson on Wednesday August 03, 2022 @08:26PM (#32337987)
kkrieger was my first thought too - I think there was some other important piece of functionality that got stripped as well (I want to say something to do with hitboxes or collision detection).
Re:Minify your container by CubsFan1060 on Wednesday August 03, 2022 @03:00PM (#32335541)
I guess it only seems dangerous to me if you blindly follow it's recommendations. Feels like it could generate a list of "things you may want to consider", that you'd then be able to use to take a look at your container.
Re:Minify your container by bigpod on Wednesday August 03, 2022 @03:07PM (#32335599)
it sometimes doesnt work sure but thats why we have tests and test i minify all my containers nowdays and in most cases it works in those that it doesnt i figured out the pattern when and why for my apps and use include flags to ensure things remain inside
Re:Minify your container by jzelinskie on Wednesday August 03, 2022 @04:32PM (#32336363)
Even prior to docker-slim there were tools like Quay.io that "did the right thing" by squashing images to just the contents of the final image layer.

The best thing you can do is use minimal images and multi-stage builds. This should help you immensely to reduce your attack vector and do standard software bill of materials, too.

Re:Minify your container by fwip on Wednesday August 03, 2022 @05:38PM (#32336925)
The quay.io squashing optimization is a lot safer though, right, as it doesn't remove anything that should be visible to the container?

I agree that the multi-stage builds are the best option, but it can be hard to know if you've included everything that is required or if you've accidentally excluded something that is important in rare cases.

Re:Minify your container by mplewis on Wednesday August 03, 2022 @03:52PM (#32336023)
docker-slim is incredibly dangerous and should never be used for a production app.
Re:Minify your container by nicce on Wednesday August 03, 2022 @04:39PM (#32336424)
I guess the question is in which way dangerous? It might lead for crash for sure, but is that crash controlled? If it is, then it is just a crash. Stability vs. minimal attack surface

But I agree, this is just bandaid for lazy bois. Better use Bazel etc. for distroless builds

Re:Minify your container by mplewis on Wednesday August 03, 2022 @06:24PM (#32337259)
This is dangerous in that it strips assets, resources, and files from your app without understanding how they are used.

If you forget a critical code path when you build using Docker-Slim, and a resource file is not used, that resource will be stripped. The feature which depends on it will be broken in production.

Re:Minify your container by bigpod on Wednesday August 03, 2022 @05:15PM (#32336734)
i would disagree i use em in production apps, i configured it and it works if you do it blindly it happens that sometimes things break but if you configure it, it will work
Re:Minify your container by mplewis on Wednesday August 03, 2022 @06:25PM (#32337269)
There is no guarantee that a blind code shaker will leave in everything important while stripping out everything that isn't. How could it possibly know?

If Docker-Slim is working for you in production apps, you are either getting lucky or your app is trivial enough to lack unseen code paths.

Re:Minify your container by tyingq on Wednesday August 03, 2022 @08:56PM (#32338176)
Maybe even unforseen files outside of your app, right?

Like, maybe some log forwarder utility that only gets called for "CRIT" messages that didn't happen to get triggered by testing.

Re:Minify your container by mnutt on Wednesday August 03, 2022 @08:40PM (#32338081)
Sandstorm does something similar in its packaging process. In practice it works pretty well; besides integration tests exercising functionality, the packaging generates a manifest list people typically check into source control, making it easy to see a diff between versions. I’m sure I’ve had a bad build at some point, but on the whole it works fine. Most dependencies tend to get referenced up-front anyway and any issues that arise are usually from shelling out to binaries in rare code paths.
Re:Minify your container by killingtime74 on Wednesday August 03, 2022 @04:46PM (#32336482)
If you have good integration tests is it still a problem?
Re:Minify your container by fwip on Wednesday August 03, 2022 @05:43PM (#32336955)
It depends on how comprehensive they are, and how important it is that your container operates correctly.

For example, even the best integration tests (for small/mid-size companies) don't always include tests that exercise weird paths around dates/times - leap years, leap seconds, daylight savings time, etc. We often trust that our datetime library or code will handle these for us, but what if the configuration is stored in a file that isn't accessed during your integration tests?

Best case scenario is you hit the error-path soon in production and your code either crashes or does something correct-enough with a fallback path, but a worse scenario is you start losing critical information and don't realize it/fix it until it's gone on for a while.

Re:Minify your container by mplewis on Wednesday August 03, 2022 @06:25PM (#32337274)
In a non-trivial app, you can never guarantee that your "good integration tests" cover every edge case. If you could, we wouldn't have outages in production.
Re:Minify your container by tmpz22 on Wednesday August 03, 2022 @08:14PM (#32337917)
Not really. There's a few common problems doing this with Go and for example, Alpine as a base image. You'll have to manually grab something like sqlite.c or some openssl stuff (its been awhile) but after that it works just fine.

Its actually a good way to find dependencies you didn't know were there. As long as you're diligent this isn't something you should be shaking in your boots over.

Re:Minify your container by encryptluks2 on Wednesday August 03, 2022 @10:13PM (#32338584)
The dependencies are part of the build process. It seems like something apko would be better suited for.
Re:Minify your container by lapser on Wednesday August 03, 2022 @02:25PM (#32335201)
If you have a good pipeline to prod, should be okay. You should hopefully have plenty of automated tests to ensure it doesn't get to prod if there are errors.
Re:Minify your container by Volundr on Wednesday August 03, 2022 @04:14PM (#32336212)
I think a "good pipeline to prod" with sufficient automated tests to ensure nothing is broken is the exception not the rule. Even in places that think/say they have a "good pipeline to prod". It's something that takes a shocking amount of engineering effort to do well, and tons of discipline to maintain.
Re:Minify your container by EddySchauHai on Wednesday August 03, 2022 @05:56PM (#32337048)
Hire a test engineer to manage all of that - it’s a full time job but an important one!
Re:Minify your container by lapser on Thursday August 04, 2022 @09:50AM (#32342879)
Totally agree. I've joined companies where there was literally zero test coverage. All tests were done manually. But then if you have bad test coverage, then you shouldn't be using something like this.
Re:Minify your container by axelthegerman on Wednesday August 03, 2022 @02:45PM (#32335374)
should be okay is definitely not enough for me to ship things to production.

And while I do have automated tests, they might sometimes stub system calls as I'm mostly testing my code to keep things stable and fast.

I'd rather explicitly declare my dependencies and use the same container for development, test and production to feel much more confident that it includes actually everything that's needed.

Re:Minify your container by bigpod on Wednesday August 03, 2022 @04:25PM (#32336302)
with good pipeline and knowledge about your app you should be able to ensure it works without much of a problem
Re:Minify your container by bigpod on Wednesday August 03, 2022 @02:59PM (#32335516)
thats why you should test and if there are stuff htat needs to be included but arent and you know wont work fail the test and add --include-path to your docker-slim command to ensure something is added