There’s a recent standard for that and it’s starting to be supported by tools like Hatch and pipx.
That is an utter misconception. There is no review of packages published on PyPI. “It is open source” guarantees that you can read the source code. You still have to do it!
What PyPI does have is a posteriori mitigation: when malware is found and reported, it is deleted from the index. That’s what it is: a mitigation.
There’s also a mitigation against packages with too similar names. I suspect pyserial
and serial
were both created before that was put in place.
That’s the best you get. Curation like manually verifying each newly created project is provided by other distributors (e.g., Anaconda and conda-forge), but as a counterpart, you get fewer packages. There is no silver bullet for this problem.
Of course it is possible: get the package contents from serial · PyPI and inspect them. (The .whl
file is a ZIP archive in disguise.)
Well, dependency confusion is a bit different, it’s rather about getting a package with a given name from an index you didn’t expect, when you use several indices at the same time (e.g., PyPI plus an internal corporate index). Typosquatting is the appropriate term here.
On that specific topic, not that I know. These issues are handled by the general PyPI staff (which is extremely scarce, unfortunately). You might want to read the PyPI blog.
There is no automated way at present, see Pip must notify people that they have been compromised by a malicious package EDIT: Wrong, have a look at GitHub - pypa/pip-audit: Audits Python environments, requirements files and dependency trees for known security vulnerabilities, and can automatically fix them
Yes, you can block PyPI and require all installs to be done through an internal index, run using, e.g., pypiserver or simpleindex.