News for hackers. Stuff that matters.
Re:Ask HN: Why does validating a user require 14000 files? by 0x073 on Monday August 30, 2021 @07:00AM (#28354427)
No one reads the readme anymore? https://github.com/googleapis/google-api-php-client#cleaning... "Cleaning up unused services There are over 200 Google API services. The chances are good that you will not want them all. In order to avoid shipping these dependencies with your code, you can run the Google\Task\Composer::cleanup task and specify the services you want to keep in composer.json:"
Re:Ask HN: Why does validating a user require 14000 files? by KronisLV on Monday August 30, 2021 @07:37AM (#28354616)
It feels like some sort of a tree shaking solution in most of our modern development stacks is long overdue.

If only we could get rid of dynamically called code and instead could evaluate which code paths the code actually can call, then we'd be able to throw out about 90% of the contents of libraries, since most of the time noone actually uses all of that functionality.

Doing that with separate scripts is another approach, but it feels like the problem should be solved at its root.

Re:Ask HN: Why does validating a user require 14000 files? by MortenToudahl on Monday August 30, 2021 @09:12AM (#28355307)
It sounds like what's already available in C#.

https://docs.microsoft.com/en-us/dotnet/core/deploying/trimm...

Re:Ask HN: Why does validating a user require 14000 files? by yummypaint on Monday August 30, 2021 @08:07AM (#28354812)
This sounds like it could be equivalent to the halting problem
Re:Ask HN: Why does validating a user require 14000 files? by herbstein on Monday August 30, 2021 @08:12AM (#28354846)
With a conservative analysis it's possible to make an underestimation on the names one can remove. This shouldn't be done on object files but at a level where program flow information is still preserved. A flow-independent analysis using a superset lattice over the callable names should do the trick for a first-order implementation that will look good enough compared to shipping 37mb for google authentication. Further you could make it flow-sensitive for a more accurate analysis with the caveat that the runtime will be significantly longer.
Re:Ask HN: Why does validating a user require 14000 files? by jitl on Monday August 30, 2021 @09:07AM (#28355254)
Control flow graphs are well-studied, critical parts of most compilers. The halting problem involves complexity of semantics in loops and jumps, but it’s possible to understand what loops may run just fine, without being able to decide exactly when a loop may exit.

In many cases Clang and GCC compiler can easily understand loops, and even reduce them to constant time.

Re:Ask HN: Why does validating a user require 14000 files? by denton-scratch on Monday August 30, 2021 @08:39AM (#28355025)
But Composer is the cause of all those file dependencies. Things like Composer and NPM encourage devs to re-use scores of 3rd-party libraries rather than writing new code; those libraries also rely on NPM/Composer; so they also have scores of dependencies. And it's impractical to audit them all.

I don't understand why people are so willing to depend on these crazy dependency trees, where most of the code was written by people you don't even know the names of.

Re:Ask HN: Why does validating a user require 14000 files? by 0x073 on Monday August 30, 2021 @09:15AM (#28355328)
Before dependency managers, you downloaded a zip with php files from people you dont even know the names of. (And never update any of the external libraries)

These managers dont replace the chain of trust, if you dont trust a dependecy and the developer behind dont install it.

"And it's impractical to audit them all." I dont use NPM but for composer.json: https://github.com/fabpot/local-php-security-checker

I agree, composer is not perfect, but before it was worse.

Re:Ask HN: Why does validating a user require 14000 files? by yashg on Monday August 30, 2021 @08:34AM (#28354975)
"I tried removing unnecessary services from composer.json. Still 14000+ files."
Re:Ask HN: Why does validating a user require 14000 files? by 0x073 on Monday August 30, 2021 @08:57AM (#28355159)
Validate a User Only: composer.json

    {
        "require": {
            "google/apiclient": "^2.10"
        },
        "scripts": {
            "pre-autoload-dump": "Google\\Task\\Composer::cleanup"
        },
        "extra": {
            "google/apiclient-services": [
            ]
        }
    }
=> vendor folder size: 6MB, 1012 Files
Re:Ask HN: Why does validating a user require 14000 files? by yashg on Monday August 30, 2021 @09:40AM (#28355542)
Cool. I did not remove enough services it seems.