log2timeline / dftimewolf

A framework for orchestrating forensic collection, processing and data export
Apache License 2.0
286 stars 69 forks source link

Investigate coverage information options #694

Open ramo-j opened 1 year ago

ramo-j commented 1 year ago

It's probably a good idea to have a github action that calculates unit test coverage. Raising this issue to track ideas and any implementation.

ramo-j commented 1 year ago

From the github marketplace: https://github.com/marketplace/actions/python-coverage or https://github.com/marketplace/actions/python-coverage-comment

Requires a secret token.

ramo-j commented 1 year ago

As a standalone action:

poetry run coverage run -m unittest discover -s tests -p '*.py' && poetry run coverage report -m

That will print a report to stdout for the workflow action, but it would be nice to have the information a bit better presented somehow.

Sample output:

OK
Name                                                          Stmts   Miss  Cover   Missing
-------------------------------------------------------------------------------------------
dftimewolf/__init__.py                                            2      0   100%
dftimewolf/cli/__init__.py                                        0      0   100%
dftimewolf/cli/curses_display_manager.py                        201      3    99%   195, 289, 306
dftimewolf/cli/dftimewolf_recipes.py                            233    101    57%   24, 159-160, 164, 168-170, 183, 204-205, 235, 257-258, 263, 279-280, 291-293, 300-302, 306, 310-316, 320, 329-338, 374, 386-438, 446-475, 478-482
dftimewolf/config.py                                             31      3    90%   31, 64-65
dftimewolf/lib/__init__.py                                        1      0   100%
dftimewolf/lib/collectors/__init__.py                             0      0   100%
dftimewolf/lib/collectors/aws.py                                 90     15    83%   148-151, 154-156, 200-205, 223-225, 246-248, 262-266
dftimewolf/lib/collectors/aws_logging.py                         71      6    92%   65-69, 107
dftimewolf/lib/collectors/aws_snapshot_s3_copy.py                87     10    89%   33-34, 109, 134-135, 172, 185-186, 203, 206
dftimewolf/lib/collectors/aws_volume_snapshot.py                 39      5    87%   51, 57-58, 72-73
dftimewolf/lib/collectors/azure.py                               86     15    83%   141-144, 147-149, 152-155, 203-208, 226-228, 242, 256-257
dftimewolf/lib/collectors/azure_logging.py                       58      5    91%   87-88, 92, 96, 100
dftimewolf/lib/collectors/bigquery.py                            40      6    85%   53, 60-71
dftimewolf/lib/collectors/filesystem.py                          25      2    92%   52, 54
dftimewolf/lib/collectors/gce_disk_copy.py                      101      7    93%   159, 199-201, 208-209, 229, 240
dftimewolf/lib/collectors/gcp_logging.py                         79     54    32%   26-28, 54-55, 60-145
dftimewolf/lib/collectors/grr_base.py                            51      0   100%
dftimewolf/lib/collectors/grr_hosts.py                          523     89    83%   164, 168, 174, 236-237, 239, 279, 285-286, 294, 311-319, 377, 451-452, 460, 492-494, 699, 713-715, 817, 862-864, 933, 940, 961-981, 1001-1004, 1015-1024, 1053-1082, 1147-1148, 1255, 1267, 1291-1311
dftimewolf/lib/collectors/grr_hunt.py                           240     48    80%   64-67, 70-78, 81, 109-114, 117-121, 124-134, 142-143, 216, 313, 488, 499-500, 544, 550-552, 557-558, 575-576, 634-635, 646-647, 659, 711-712, 744
dftimewolf/lib/collectors/gsheets.py                            122     47    61%   68, 76-127, 148-151, 155-173, 191, 210-212, 221-222
dftimewolf/lib/collectors/osquery.py                             71      8    89%   61, 67, 69, 73, 96-98, 127, 150
dftimewolf/lib/collectors/virustotal.py                          95     57    40%   50-66, 88, 91, 101, 109, 126-143, 153-169, 183, 187-195, 208-221
dftimewolf/lib/collectors/workspace_audit.py                     92     60    35%   22, 56-58, 66-107, 132-142, 146-189
dftimewolf/lib/collectors/yara.py                                34      0   100%
dftimewolf/lib/containers/__init__.py                             0      0   100%
dftimewolf/lib/containers/containers.py                         220     16    93%   11-14, 120-123, 127, 257-260, 264, 524, 630
dftimewolf/lib/containers/interface.py                           19      1    95%   50
dftimewolf/lib/enhancers/__init__.py                              1      0   100%
dftimewolf/lib/enhancers/timesketch.py                          197    162    18%   16-21, 97-121, 125-127, 144-157, 170-193, 213-219, 230-238, 259-275, 289-316, 329-349, 353-481
dftimewolf/lib/errors.py                                         13      0   100%
dftimewolf/lib/exporters/__init__.py                              0      0   100%
dftimewolf/lib/exporters/gce_disk_export.py                      45      1    98%   132
dftimewolf/lib/exporters/gce_disk_export_base.py                 65     28    57%   57-58, 76-83, 92, 96, 105-118, 121, 136-147
dftimewolf/lib/exporters/gce_disk_export_dd.py                   69     14    80%   131, 161-167, 173-184, 204
dftimewolf/lib/exporters/gce_disk_from_image.py                  37      1    97%   87
dftimewolf/lib/exporters/gce_image_from_disk.py                  48      3    94%   78-80, 107
dftimewolf/lib/exporters/gcs_to_gce_image.py                    112     21    81%   112-121, 134-136, 167-169, 187, 252-256, 285-288, 301-304, 332
dftimewolf/lib/exporters/local_filesystem.py                     53      6    89%   75-77, 100-101, 106
dftimewolf/lib/exporters/s3_to_gcs.py                            75     26    65%   79, 82, 91-102, 107-109, 129-147, 162, 167, 170
dftimewolf/lib/exporters/scp_ex.py                              106     10    91%   76, 82, 95-101, 104, 189, 202, 212
dftimewolf/lib/exporters/timesketch.py                          130     32    75%   79, 88-89, 108, 120, 129, 144, 154-158, 177, 188, 196-216, 220, 223, 228-229, 233-234
dftimewolf/lib/logging_utils.py                                  61      0   100%
dftimewolf/lib/module.py                                         83      2    98%   92, 128
dftimewolf/lib/modules/__init__.py                                0      0   100%
dftimewolf/lib/modules/manager.py                                26      2    92%   7, 32
dftimewolf/lib/preflights/__init__.py                             1      0   100%
dftimewolf/lib/preflights/cloud_token.py                         33     18    45%   24-42, 66-76
dftimewolf/lib/preflights/sanity_checks.py                       30      1    97%   63
dftimewolf/lib/preflights/ssh_multiplexer.py                     38      3    92%   56, 69, 80
dftimewolf/lib/processors/__init__.py                             0      0   100%
dftimewolf/lib/processors/gce_forensics_vm.py                    78      8    90%   117, 160-162, 166, 173-179
dftimewolf/lib/processors/gcp_cloud_resource_tree.py            452    128    72%   19, 83, 92-95, 100-142, 151-169, 177-200, 270, 301-303, 338, 342, 368-418, 427-447, 463, 507, 605-615, 668, 673-677, 691-713, 792-795, 883, 908, 951-962, 971, 993, 1038
dftimewolf/lib/processors/gcp_cloud_resource_tree_helper.py     180     67    63%   95, 97, 99, 101, 105, 110, 151, 162-163, 198, 217-249, 261-272, 276-313, 354-371, 382
dftimewolf/lib/processors/gcp_logging_timesketch.py             146     30    79%   13, 84, 166-171, 177, 183-184, 205-206, 242, 255-275, 279-281
dftimewolf/lib/processors/grepper.py                             58      4    93%   18-19, 79-80
dftimewolf/lib/processors/localplaso.py                          93      6    94%   79-80, 83-86, 134, 173
dftimewolf/lib/processors/turbinia_artifact.py                   61     11    82%   18, 67-68, 72-74, 92-93, 100, 114, 118
dftimewolf/lib/processors/turbinia_base.py                      102      7    93%   202, 260-267
dftimewolf/lib/processors/turbinia_gcp.py                        97     18    81%   18, 66, 117-119, 133-134, 142, 152-155, 161, 170-171, 176-182, 191
dftimewolf/lib/processors/workspace_audit_timesketch.py         110     12    89%   17, 80-83, 87-88, 181-182, 193-196, 208
dftimewolf/lib/recipes/__init__.py                                0      0   100%
dftimewolf/lib/recipes/manager.py                                46      3    93%   56, 80-81
dftimewolf/lib/resources.py                                      12      0   100%
dftimewolf/lib/state.py                                         339     21    94%   25-26, 122-124, 131-133, 179, 186, 194, 350-362, 558-560, 829
dftimewolf/lib/timesketch_utils.py                               30     16    47%   13, 47-73
dftimewolf/lib/utils.py                                         110     37    66%   38-41, 47-48, 98, 104-105, 118, 131, 135, 139, 143, 147, 151, 155, 159, 163, 175, 188, 192, 196, 200, 204, 208, 212, 216, 220, 240, 244, 248, 252, 256, 260, 264, 268, 272, 276
dftimewolf/metawolf/__init__.py                                   0      0   100%
dftimewolf/metawolf/metawolf.py                                 505    353    30%   177, 179, 181-182, 188-199, 203-214, 235-349, 356-393, 422-561, 578-603, 607-608, 612, 620-631, 639-649, 657-663, 671, 680-690, 709-710, 714, 721-740, 744, 752, 762-773, 782-784, 806, 816, 822-888, 906-911, 930-955, 959-964, 968
dftimewolf/metawolf/output.py                                   143     54    62%   60, 114, 117-123, 134-135, 162-173, 200-219, 236-237, 273, 276, 287-294, 304-318
dftimewolf/metawolf/session.py                                   19      1    95%   52
dftimewolf/metawolf/utils.py                                    148     28    81%   18, 37-40, 50, 96, 121, 126, 144, 149, 154, 157, 214-227, 270-271, 317
tests/__init__.py                                                 0      0   100%
tests/cli/__init__.py                                             0      0   100%
tests/cli/curses_display_manager.py                             331      1    99%   663
tests/cli/main_tool.py                                           41      0   100%
tests/cli/recipes.py                                             62      3    95%   76, 104, 116
tests/lib/__init__.py                                             0      0   100%
tests/lib/collectors/__init__.py                                  0      0   100%
tests/lib/collectors/aws.py                                     113      1    99%   265
tests/lib/collectors/aws_logging.py                              49      1    98%   94
tests/lib/collectors/aws_snapshot_s3_copy.py                    124      2    98%   128, 309
tests/lib/collectors/aws_volume_snapshot.py                      72      2    97%   70, 143
tests/lib/collectors/azure.py                                   120      1    99%   294
tests/lib/collectors/azure_logging.py                            48      0   100%
tests/lib/collectors/bigquery.py                                 22      1    95%   36
tests/lib/collectors/filesystem.py                               27      1    96%   40
tests/lib/collectors/gce_disk_copy.py                           190      1    99%   468
tests/lib/collectors/grr_base.py                                 66      1    98%   155
tests/lib/collectors/grr_hosts.py                               522      1    99%   1090
tests/lib/collectors/grr_hunt.py                                169      1    99%   338
tests/lib/collectors/gsheets.py                                  51      1    98%   102
tests/lib/collectors/osquery.py                                  72      1    99%   143
tests/lib/collectors/stackdriver.py                              12      1    92%   23
tests/lib/collectors/test_data/__init__.py                        0      0   100%
tests/lib/collectors/test_data/mock_grr_hosts.py                 27      0   100%
tests/lib/collectors/virustotal.py                               24      1    96%   56
tests/lib/collectors/yara.py                                     38      1    97%   104
tests/lib/containers/__init__.py                                  0      0   100%
tests/lib/containers/containers.py                               48      1    98%   140
tests/lib/containers/interface.py                                18      1    94%   36
tests/lib/exporters/__init__.py                                   0      0   100%
tests/lib/exporters/gce_disk_export.py                           58      1    98%   119
tests/lib/exporters/gce_disk_export_dd.py                        55      1    98%   113
tests/lib/exporters/gce_disk_from_image.py                       58      1    98%   122
tests/lib/exporters/gce_image_from_disk.py                       73      1    99%   161
tests/lib/exporters/gcs_to_gce_image.py                          71      1    99%   158
tests/lib/exporters/local_filesystem.py                          74      2    97%   28, 127
tests/lib/exporters/s3_to_gcs.py                                 83      1    99%   156
tests/lib/exporters/scp_ex.py                                    91      1    99%   157
tests/lib/exporters/timesketch.py                                84      1    99%   136
tests/lib/modules/__init__.py                                     0      0   100%
tests/lib/modules/manager.py                                     32      1    97%   74
tests/lib/preflights/__init__.py                                  0      0   100%
tests/lib/preflights/sanity_checks.py                            33      1    97%   65
tests/lib/preflights/ssh_multiplexer.py                          29      1    97%   57
tests/lib/processors/__init__.py                                  0      0   100%
tests/lib/processors/gce_forensics_vm.py                         92      1    99%   205
tests/lib/processors/gcp_cloud_resource_tree.py                 223      0   100%
tests/lib/processors/gcp_logging_timesketch.py                   56      1    98%   542
tests/lib/processors/grepper.py                                  15      0   100%
tests/lib/processors/localplaso.py                               86      1    99%   130
tests/lib/processors/test_data/turbinia.conf                     49      0   100%
tests/lib/processors/turbinia_artifact.py                        53      1    98%   112
tests/lib/processors/turbinia_gcp.py                            194      1    99%   452
tests/lib/processors/workspace_audit_timesketch.py               48      0   100%
tests/lib/recipes/__init__.py                                     0      0   100%
tests/lib/recipes/manager.py                                     62      1    98%   144
tests/lib/resources.py                                           17      1    94%   47
tests/lib/state.py                                              476      1    99%   821
tests/lib/timesketch_utils.py                                    16      1    94%   30
tests/lib/utils.py                                               34      0   100%
tests/metawolf/__init__.py                                        0      0   100%
tests/metawolf/metawolf.py                                       79      2    97%   148-149
tests/metawolf/output.py                                         32      0   100%
tests/metawolf/utils.py                                          83      0   100%
tests/test_dftimewolf.py                                         55      3    95%   40, 43-44
tests/test_modules/__init__.py                                    0      0   100%
tests/test_modules/modules.py                                    38      3    92%   55, 59, 63
tests/test_modules/test_recipe.py                                 8      0   100%
tests/test_modules/thread_aware_modules.py                       85      0   100%
utils/__init__.py                                                 0      0   100%
utils/utils.py                                                    9      2    78%   23-24
-------------------------------------------------------------------------------------------
TOTAL                                                         11360   1748    85%
ramo-j commented 1 year ago

codecov.io is also an option - which was previously set up in fact: https://app.codecov.io/gh/log2timeline/dftimewolf/pull/366