TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Panoptisch – A recursive dependency scanner for Python projects

45 pointsby r9295over 2 years ago
Hello all,<p>Very excited to share this project with you all!<p>Panoptisch scans your Python file or module to find it&#x27;s imports (aka dependencies) and recursively does so for all dependencies and sub-dependencies. It then generates a dependency tree in JSON for you to parse and enforce import policies.<p>Supply chain attacks are no joke, and this is one way to transparently analyze your dependencies to see if any malicious imports are taking place. For example, your yaml parser, nor it&#x27;s sub-dependencies should import socket, or sys.<p>Panoptisch is in early stages, with known limitations (for now). I welcome feedback, testing and contributions.<p>Also, happy to answer any questions!

4 comments

woodruffwover 2 years ago
First of all: I&#x27;m glad that more people are trying to tackle this problem!<p>That being said, I&#x27;m not sure if I would encourage this approach: this conflates <i>modules</i> (a property of the Python language) with <i>dependencies</i> (a thing that maps roughly to packages&#x2F;distributions, which are a property of Python packaging). The two actually aren&#x27;t that connected: there&#x27;s no guaranteed 1-1 (or even 1-N) mapping between a dependency&#x27;s package name and its importable modules, meaning that knowledge of a malicious package doesn&#x27;t imply that you can derive how that package&#x27;s module(s) get imported at runtime.<p>More perniciously: module names aren&#x27;t static. It&#x27;s pretty easy to construct a dynamic module object, or to rename (or alias) an existing module object to avoid this kind of detection.<p>Finally: walking a project&#x27;s import tree isn&#x27;t safe in the general case! Lots of packages have side effects when imported, and malicious dependencies <i>definitely</i> take advantage of that ability. Running this tool might find a malicious import by virtue of actually running malicious code, which isn&#x27;t ideal.<p>If your goal is to detect malicious API patterns at runtime (which is effectively what you&#x27;re doing when you walk the package import tree), I think runtime audit hooks[1] are probably a better fit. Those also aren&#x27;t foolproof either, but they&#x27;ll probably be more reliable (and don&#x27;t require as much context awareness to determine maliciousness).<p>[1]: <a href="https:&#x2F;&#x2F;peps.python.org&#x2F;pep-0578&#x2F;" rel="nofollow">https:&#x2F;&#x2F;peps.python.org&#x2F;pep-0578&#x2F;</a>
评论 #33927427 未加载
ashishbijlaniover 2 years ago
Good to see this project here! Have you added support for permissions already? Would love to integrate this in <a href="https:&#x2F;&#x2F;github.com&#x2F;ossillate-inc&#x2F;packj" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ossillate-inc&#x2F;packj</a>
评论 #33935384 未加载
gegtikover 2 years ago
I&#x27;ve been using pip-compile from <a href="https:&#x2F;&#x2F;github.com&#x2F;jazzband&#x2F;pip-tools" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jazzband&#x2F;pip-tools</a> for this use case; a standard project Makefile defines &quot;make update&quot; which pip-compiles the current requirements, and &quot;make install&quot; installs the frozen requirements list.<p>This way I can install the same bill of materials every time
评论 #33935290 未加载
NitinDhakreyover 2 years ago
I need