Add support for external timestamps

This allows external files containing

    timestamps = {
        "db_create_start"      : pd.Timestamp(0.0, unit='s'),
        "db_create_stop"       : pd.Timestamp(0.0, unit='s'),
        "scan_start_date"      : pd.Timestamp(0.0, unit='s'),
        "scan_stop_date"       : pd.Timestamp(0.0, unit='s'),
    }

to be used to provide those values, instead of the above defaults.

This patch changes the top-level scripts
        bin/sarif-extract-scans
        bin/sarif-extract-scans-runner
and provides
        scripts/test-timestamps.sh
for verification.

The following keys are also accepted:
    {
      "db_create_start": ...,
      "db_create_stop": ...,
      "scan_start": ...
      "scan_stop": ...
    }
This commit is contained in:
Michael Hohn
2023-08-18 17:00:11 -07:00
committed by =Michael Hohn
parent 57710bdd14
commit ee11214aee
4 changed files with 153 additions and 15 deletions

View File

@@ -116,7 +116,7 @@ def joins_for_projects(basetables, external_info):
#
# Scans table
#
def joins_for_scans(basetables, external_info, scantables, sarif_type):
def joins_for_scans(basetables, external_info, scantables, sarif_type, timestamps : dict):
"""
Form the `scans` table for the ScanTables dataclass
"""
@@ -135,12 +135,7 @@ def joins_for_scans(basetables, external_info, scantables, sarif_type):
"id" : e.scan_id,
"commit_id" : commit_id,
"project_id" : e.project_id,
# TODO extract real date information from somewhere external
"db_create_start" : pd.Timestamp(0.0, unit='s'),
"db_create_stop" : pd.Timestamp(0.0, unit='s'),
"scan_start_date" : pd.Timestamp(0.0, unit='s'),
"scan_stop_date" : pd.Timestamp(0.0, unit='s'),
#
**timestamps,
"tool_name" : driver_name[0],
"tool_version" : driver_version[0],
"tool_query_commit_id" : pd.NA,