oscope-dev / scope

Scoping user machines
https://oscope-dev.github.io/scope/
BSD 3-Clause "New" or "Revised" License
6 stars 3 forks source link

Refactor report generation for group report extras #120

Closed ethankhall closed 5 months ago

ethankhall commented 5 months ago

With this change, a group is now able to provide a new field reportExtraDetails, that contains a map of string:string, this map will run after the group has executed regardless if it succeeded or failed.

The output will be placed into a table in the markdown report.

This allows groups to add metadata about their targets to reports, making the reports more useful.

This change includes some refactoring work (mainly around naming) that will come in a later PR. There is also some refactoring to be done around de-duplicating data, but wanted to exclude that for now as this PR is already large.

ethankhall commented 5 months ago

Example Output

Scope bug report: scope doctor run

Additional Capture Data

Name Value
node
/Users/ethan/.local/share/mise/installs/node/20/bin/node
nodeVersion
v20.11.0
ruby
/usr/bin/ruby
username
ethan

Group fail

Action fail/file-exists


Command: echo "found file /Users/ethan/workspace/ethankhall/pity/examples/file-mod.txt"

Output:

found file /Users/ethan/workspace/ethankhall/pity/examples/file-mod.txt
Name Value
Exit code 0
Started at 2024-05-04 19:01:50.618366 UTC
Finished at 2024-05-04 19:01:50.621153 UTC

Command: test -f /Users/ethan/workspace/ethankhall/pity/examples/file-mod.txt

Output:

Name Value
Exit code 1
Started at 2024-05-04 19:01:50.621472 UTC
Finished at 2024-05-04 19:01:50.623390 UTC

Additional Capture Data

Name Value
who am i
uid=501(ethan) gid=20(staff) groups=20(staff),101(access_bpf),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),33(_appstore),100(_lpoperator),204(_developer),250(_analyticsusers),395(com.apple.access_ftp),398(com.apple.access_screensharing),399(com.apple.access_ssh),400(com.apple.access_remote_ae)
noizwaves commented 5 months ago

This PR does leave some of the existing report code (i.e. ReportBuilder, OutputCapture.create_report_text, and CaptureError.create_report_text) still around.

ethankhall commented 5 months ago

Oo good callout. Updated to remove/move them.

One thing I'd like to do is make a trait that can be used when running commands, so that "FoundConfig" object doesn't need to be passed around / a struct that can be abstracted out to be re-used everywhere.