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

Update JSON reporting schema #102

Merged
merged 1 commit into from
Feb 9, 2024
Merged

Update JSON reporting schema #102

merged 1 commit into from
Feb 9, 2024

Conversation

mehrinkiani
Copy link
Member

This PR updates JSON reporting schema as outlined in #100. The field timestamp: datetime.datetime.now() has isoformat, i.e. timestamp: datetime.datetime.now().isoformat to make it JSON serializable.

Closes #100

Copy link
Member

@willarmiros willarmiros left a comment

Choose a reason for hiding this comment

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

LGTM, and no problem on the ISO Format! @mehrinkiani can you possibly post a sample output with the new format (showing 1 or 2 vulns) for our reference?

@mehrinkiani
Copy link
Member Author

Thank you for the review @willarmiros. Here is a JSON report generated by scanning Tensorflow safe and unsafe models from notebooks/tensorflow_fashion_mnist.ipynb

{
    "summary": {
        "total_issues_by_severity": {
            "LOW": 0,
            "MEDIUM": 0,
            "HIGH": 2,
            "CRITICAL": 0
        },
        "total_issues": 2,
        "input_path": "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels",
        "modelscan_version": "0.0.0",
        "timestamp": "2024-02-09T11:19:02.261556",
        "scanned": {
            "total_scanned": 6,
            "scanned_files": [
                "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/unsafe_model/fingerprint.pb",
                "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/unsafe_model/keras_metadata.pb",
                "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/unsafe_model/saved_model.pb",
                "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/safe_model/fingerprint.pb",
                "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/safe_model/keras_metadata.pb",
                "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/safe_model/saved_model.pb"
            ]
        }
    },
    "issues": [
        {
            "description": "Use of unsafe operator 'ReadFile' from module 'Tensorflow'",
            "operator": "ReadFile",
            "module": "Tensorflow",
            "source": "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/unsafe_model/saved_model.pb",
            "scanner": "modelscan.scanners.SavedModelTensorflowOpScan",
            "severity": "HIGH"
        },
        {
            "description": "Use of unsafe operator 'WriteFile' from module 'Tensorflow'",
            "operator": "WriteFile",
            "module": "Tensorflow",
            "source": "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/unsafe_model/saved_model.pb",
            "scanner": "modelscan.scanners.SavedModelTensorflowOpScan",
            "severity": "HIGH"
        }
    ],
    "errors": []
}

@mehrinkiani mehrinkiani merged commit 2e15e17 into main Feb 9, 2024
8 checks passed
@mehrinkiani mehrinkiani deleted the 100-refactor-json-schema branch February 9, 2024 16:28
@willarmiros
Copy link
Member

@mehrinkiani thank you for this, it will be super helpful for us! I noticed there is no skipped field in the summar, is that expected when no files are skipped?

@mehrinkiani
Copy link
Member Author

@willarmiros thank you for the feedback. To view skipped files scan command needs a --show-skipped argument. I generated the previous report without --show-skipped. Below is the report with --show-skipped

{
    "summary": {
        "total_issues_by_severity": {
            "LOW": 0,
            "MEDIUM": 0,
            "HIGH": 2,
            "CRITICAL": 0
        },
        "total_issues": 2,
        "input_path": "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels",
        "modelscan_version": "0.0.0",
        "timestamp": "2024-02-09T11:31:10.138955",
        "skipped": {
            "total_skipped": 4,
            "skipped_files": [
                "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/unsafe_model/variables/variables.data-00000-of-00001",
                "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/unsafe_model/variables/variables.index",
                "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/safe_model/variables/variables.data-00000-of-00001",
                "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/safe_model/variables/variables.index"
            ]
        },
        "scanned": {
            "total_scanned": 6,
            "scanned_files": [
                "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/unsafe_model/fingerprint.pb",
                "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/unsafe_model/keras_metadata.pb",
                "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/unsafe_model/saved_model.pb",
                "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/safe_model/fingerprint.pb",
                "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/safe_model/keras_metadata.pb",
                "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/safe_model/saved_model.pb"
            ]
        }
    },
    "issues": [
        {
            "description": "Use of unsafe operator 'ReadFile' from module 'Tensorflow'",
            "operator": "ReadFile",
            "module": "Tensorflow",
            "source": "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/unsafe_model/saved_model.pb",
            "scanner": "modelscan.scanners.SavedModelTensorflowOpScan",
            "severity": "HIGH"
        },
        {
            "description": "Use of unsafe operator 'WriteFile' from module 'Tensorflow'",
            "operator": "WriteFile",
            "module": "Tensorflow",
            "source": "/Users/mehrinkiani/Documents/modelscan/notebooks/TensorFlowModels/unsafe_model/saved_model.pb",
            "scanner": "modelscan.scanners.SavedModelTensorflowOpScan",
            "severity": "HIGH"
        }
    ],
    "errors": []
}

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.

Refactor JSON reporting schema
2 participants