I am trying to debug an agent plugin written by someone else and have some questions.
The framework documentation says that plugins are not regular python programs, and that "All of the plug-in’s code needs to be contained within functions"
I have written some code for the scanner that I'd like to reuse in the plugin. They are in the form of a class that sits in a different .py file. I tried importing the files in the agent and got some mysterious errors (either import failed or some file descriptor error).
I'd like to know if:
1) from __init__.py, I can import code from different .py files. I can't get this to work with either the .py file in the same folder as __init__.py, or in a sub folder. If not, then I guess I have to write everything in one file which is not ideal but not a deal breaker.
I did find an example of an existing plugin that imported a countrycode.py file, but I can't seem to find the difference between it and my .py file and why my import fails and the other one would work.
2) is python classes supported (assume I write it in __init__.py)?
I'd like to write a class that handles communication with a 3rd party entity. The reason for the class is I can keep track of some state information. Say I can initialize it with some credentials, etc, and subsequent method call would use those credentials to construct a query..
I could do this with pure functions too, but it seems to be less elegant.
Just wondering what I can and cannot do inside a plugin as the documentation doesn't contain much detail beyond stating functions...
Thanks!