Skip to content
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

Add NamespacePlugin #334

Merged
merged 20 commits into from
Aug 16, 2023
Merged

Add NamespacePlugin #334

merged 20 commits into from
Aug 16, 2023

Conversation

cecinestpasunepipe
Copy link
Contributor

(DIS-1681)

@cecinestpasunepipe cecinestpasunepipe force-pushed the DIS-1681_Plugin_Helpers branch 3 times, most recently from ca285cf to 7d52b5e Compare July 28, 2023 11:20
@codecov
Copy link

codecov bot commented Jul 28, 2023

Codecov Report

Merging #334 (b0b3301) into main (dabc656) will increase coverage by 0.13%.
The diff coverage is 95.00%.

@@            Coverage Diff             @@
##             main     #334      +/-   ##
==========================================
+ Coverage   70.57%   70.70%   +0.13%     
==========================================
  Files         235      235              
  Lines       18071    18098      +27     
==========================================
+ Hits        12753    12796      +43     
+ Misses       5318     5302      -16     
Flag Coverage Δ
unittests 70.70% <95.00%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
dissect/target/tools/query.py 35.32% <40.00%> (-0.18%) ⬇️
dissect/target/plugin.py 90.30% <96.42%> (+1.28%) ⬆️
dissect/target/helpers/docs.py 87.80% <100.00%> (-0.81%) ⬇️
...issect/target/plugins/apps/remoteaccess/anydesk.py 94.28% <100.00%> (ø)
...t/target/plugins/apps/remoteaccess/remoteaccess.py 100.00% <100.00%> (+54.83%) ⬆️
...ect/target/plugins/apps/remoteaccess/teamviewer.py 94.44% <100.00%> (ø)
dissect/target/plugins/browsers/browser.py 100.00% <100.00%> (+6.52%) ⬆️
dissect/target/plugins/browsers/chrome.py 100.00% <100.00%> (ø)
dissect/target/plugins/browsers/chromium.py 90.57% <100.00%> (ø)
dissect/target/plugins/browsers/edge.py 100.00% <100.00%> (ø)
... and 5 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@cecinestpasunepipe cecinestpasunepipe force-pushed the DIS-1681_Plugin_Helpers branch 7 times, most recently from 0746cc9 to fe4f2e6 Compare July 28, 2023 11:55
Copy link
Member

@Schamper Schamper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add automatic generation of shared functions that have the same (name, record) signature? So that you don't have to manually define functions such as these:

@export(record=BrowserDownloadRecord)
def downloads(self):
    yield from self._func("downloads")

@cecinestpasunepipe
Copy link
Contributor Author

cecinestpasunepipe commented Jul 28, 2023

Can you add automatic generation of shared functions that have the same (name, record) signature? So that you don't have to manually define functions such as these:

@export(record=BrowserDownloadRecord)
def downloads(self):
    yield from self._func("downloads")

Seems that we have to do this statically, maybe using __init_subclass__ otherwise the autogenerated funcs will be listed as invalid. Also, we used to put record descriptions as docs in those functions, so we lose those then I guess? Looking into this now.

@Schamper
Copy link
Member

Schamper commented Jul 28, 2023

Also, we used to put record descriptions as docs in those functions, so we lose those then I guess? Looking into this now.

You can set __doc__.

@Schamper
Copy link
Member

Yes, I know, but the developer still needs a place to write the documentation? (Of course the developer could add the docs to all the separate plugins but then we have duplicate docs?) Or do you mean to generate the record docs automatically? But what about any manual documentation / comments then?

I believe the long-term goal is to automatically generate the record descriptor documentation. The body of the docstring could be automatically generated to say something like "Convenience function to call {function} on {subplugins}".

@cecinestpasunepipe
Copy link
Contributor Author

Yes, I know, but the developer still needs a place to write the documentation? (Of course the developer could add the docs to all the separate plugins but then we have duplicate docs?) Or do you mean to generate the record docs automatically? But what about any manual documentation / comments then?

I believe the long-term goal is to automatically generate the record descriptor documentation. The body of the docstring could be automatically generated to say something like "Convenience function to call {function} on {subplugins}".

Yes, I deleted my previous comment because I see there is already some duplication in the docs.

@cecinestpasunepipe cecinestpasunepipe force-pushed the DIS-1681_Plugin_Helpers branch 2 times, most recently from 69afe89 to 6ac8585 Compare August 1, 2023 18:07
@cecinestpasunepipe cecinestpasunepipe force-pushed the DIS-1681_Plugin_Helpers branch 4 times, most recently from f93f564 to f4e8a00 Compare August 2, 2023 10:36
@cecinestpasunepipe
Copy link
Contributor Author

cecinestpasunepipe commented Aug 2, 2023

Note that the auto-generated functions will have generated docs that reflect the actual aggregation:

So

target-query -l browser

yields:

Available plugins:
    browsers:
      browser:
        browser.downloads - Return aggregated records for: chromium,chrome,iexplore,edge,firefox (output: records)
        browser.extensions - Return aggregated records for: chromium,chrome,edge (output: records)
        browser.history - Return aggregated records for: chromium,chrome,iexplore,edge,firefox (output: records)

Also the function that generates these docs is very flexible and accepts a format_spec str to be filled in, so we might reuse this code for other purposes as well.

@cecinestpasunepipe cecinestpasunepipe marked this pull request as ready for review August 2, 2023 10:48
@cecinestpasunepipe cecinestpasunepipe force-pushed the DIS-1681_Plugin_Helpers branch 2 times, most recently from 20c1e50 to d558a11 Compare August 2, 2023 11:39
cecinestpasunepipe and others added 20 commits August 16, 2023 12:46
Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
@cecinestpasunepipe cecinestpasunepipe merged commit 356df08 into main Aug 16, 2023
@cecinestpasunepipe cecinestpasunepipe deleted the DIS-1681_Plugin_Helpers branch August 16, 2023 11:23
Poeloe pushed a commit that referenced this pull request Feb 29, 2024
Zawadidone pushed a commit to Zawadidone/dissect.target that referenced this pull request Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants