Background
Simplifying, assume I want to write some tool for code-analysis, which tell me which files - class/module - are/have some kind of network interface(s). No matter if it's REST Controller, DB connection, RPC or simple socket.
Restrictions
I want to achive this automatically. What do I mean by that? I don't want to use any regex stuff to search network-specific keywords in method names or strings like GET, POST, other http operations, URLs, IP addresses and other things which are related to certain protocol. I want to obtain if class use some socket operations under the hood. Even if it's app build on e.g http framework, and all network operations are hidden in deeper dependencies.
Example
We have some REST controller, which listen on particular URL. If we use some HTTP framework, then probably such controller is injected as dependency to other class and this class is injected to other class and so on, where finally we have some network socket which listen on low level network interface. I assume that every programming environment has some atomic socket abstraction, or couple of such, which are used by every network interface.
Question
How can I properly fulfill such requirements? The goal is to indicate places where are located network inputs and outputs of the system. Can I achieve that using tool written in only one programming language or do I have to write individual tool every technology?
PS. Post is language-agnostic in general, but some example in java or python would be helpful.