-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial commit for plugin internals refactor #763
base: main
Are you sure you want to change the base?
Conversation
bfa1029
to
f4c1af4
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #763 +/- ##
==========================================
- Coverage 77.72% 76.83% -0.90%
==========================================
Files 326 327 +1
Lines 28575 28645 +70
==========================================
- Hits 22210 22009 -201
- Misses 6365 6636 +271
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
68299b4
to
84e83ea
Compare
2192994
to
85f4ebc
Compare
43b0585
to
e830c4e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed plugins/general/example.py
and plugins/os/unix/packagemanager.py
still have a __findable__
property, which is now no longer needed.
Another thing I noticed is that the -l
no longer lists the plugins from _os.py
.
And a third thing I noticed that if I run a namespace plugin, e.g. webserver.access, which is listed when doing target-query MyTarget -l
, before it printed an error like:
Error while parsing sysvol/windows/system32/inetsrv/config/applicationHost.config: ...
but now it errors with:
target-query: error: argument -f/--function contains invalid plugin(s): webserver.access
e830c4e
to
19bf4e9
Compare
Fixed package manager but we still don't want the example plugin to findable.
Should be fixed again.
I had to largely rewrite the |
19bf4e9
to
77f2144
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice increment.
Left some comments, most are suggestions / ideas, not demands.
QA: did not find regressions but will test again after changes.
0df9678
to
c9f03ef
Compare
Would it be possible to add registered arguments to diff --git a/dissect/target/plugins/general/plugins.py b/dissect/target/plugins/general/plugins.py
index 334830b..6dd5ed9 100644
--- a/dissect/target/plugins/general/plugins.py
+++ b/dissect/target/plugins/general/plugins.py
@@ -59,14 +59,25 @@ def generate_functions_json(functions: list[plugin.FunctionDescriptor] | None =
for desc in functions or _get_default_functions():
plugincls = plugin.load(desc)
- docstring = getattr(plugincls, desc.method_name).__doc__
+ func = getattr(plugincls, desc.method_name)
loaded.append(
{
"name": desc.name,
"output": desc.output,
- "description": docstring.split("\n\n", 1)[0].strip() if docstring else None,
+ "description": func.__doc__.split("\n\n", 1)[0].strip() if func.__doc__ else None,
"path": desc.path,
+ "arguments": [
+ {
+ "name": name[0],
+ "type": arg.get("type").__name__ if arg.get("type") is not None else None,
+ "help": arg.get("help"),
+ "default": arg.get("default"),
+ }
+ for name, arg in func.__args__
+ ]
+ if hasattr(func, "__args__")
+ else None,
}
) |
Additionally could |
This is not possible since we can't serialise the record descriptor, so it would just be a string. This functionality will be part of an incremental improvement of this PR as discussed in the main PR body:
The goal of this PR is to agree and establish a better base plugin system, and then incrementally improve that. |
520dda8
to
552933d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good.
Some tests are failing though.
After these have been fixed, I will do another QA pass.
9579422
to
de93169
Compare
de93169
to
6163a05
Compare
6163a05
to
8f55c68
Compare
Initial commit for the plugin internals refactor. This removes a lot of slow and hard to understand code with (hopefully) faster and easier to understand code. Also fixes some consistency issues I came across while working on this.
There are some things I want to add, but I may do those in a separate PR:
_os.py
, but then_plugin.py
or something similar (Add support for plugin directories #788)path
field, for example. (Add retrieval of runtime information to plugin descriptors #1007)This should also cover #759.
Closes #889.