Skip to content

Modernize the code base #6

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ To learn more about SARIF and find resources for working with it, you can visit

The source code is available at https://github.com/microsoft/sarif-python-om.

How to use
==========

.. code-block:: python

import cattrs
import json
import sys

from sarif_om import SarifLog


with open(sys.argv[1]) as fp:
data = json.load(fp)

sarif_log = cattrs.structure(data, SarifLog)


Generation
==========

Expand Down
106 changes: 53 additions & 53 deletions sarif_om/__init__.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
# This file was generated by jschema_to_python version 1.2.3.

from sarif_om._sarif_log import SarifLog
from sarif_om._address import Address
from sarif_om._artifact import Artifact
from sarif_om._artifact_change import ArtifactChange
from sarif_om._artifact_content import ArtifactContent
from sarif_om._artifact_location import ArtifactLocation
from sarif_om._attachment import Attachment
from sarif_om._code_flow import CodeFlow
from sarif_om._configuration_override import ConfigurationOverride
from sarif_om._conversion import Conversion
from sarif_om._edge import Edge
from sarif_om._edge_traversal import EdgeTraversal
from sarif_om._exception import Exception
from sarif_om._external_properties import ExternalProperties
from sarif_om._external_property_file_reference import ExternalPropertyFileReference
from sarif_om._external_property_file_references import ExternalPropertyFileReferences
from sarif_om._fix import Fix
from sarif_om._graph import Graph
from sarif_om._graph_traversal import GraphTraversal
from sarif_om._invocation import Invocation
from sarif_om._location import Location
from sarif_om._location_relationship import LocationRelationship
from sarif_om._logical_location import LogicalLocation
from sarif_om._message import Message
from sarif_om._multiformat_message_string import MultiformatMessageString
from sarif_om._node import Node
from sarif_om._notification import Notification
from sarif_om._physical_location import PhysicalLocation
from sarif_om._property_bag import PropertyBag
from sarif_om._rectangle import Rectangle
from sarif_om._region import Region
from sarif_om._replacement import Replacement
from sarif_om._reporting_configuration import ReportingConfiguration
from sarif_om._reporting_descriptor import ReportingDescriptor
from sarif_om._reporting_descriptor_reference import ReportingDescriptorReference
from sarif_om._reporting_descriptor_relationship import ReportingDescriptorRelationship
from sarif_om._result import Result
from sarif_om._result_provenance import ResultProvenance
from sarif_om._run import Run
from sarif_om._run_automation_details import RunAutomationDetails
from sarif_om._special_locations import SpecialLocations
from sarif_om._stack import Stack
from sarif_om._stack_frame import StackFrame
from sarif_om._suppression import Suppression
from sarif_om._thread_flow import ThreadFlow
from sarif_om._thread_flow_location import ThreadFlowLocation
from sarif_om._tool import Tool
from sarif_om._tool_component import ToolComponent
from sarif_om._tool_component_reference import ToolComponentReference
from sarif_om._translation_metadata import TranslationMetadata
from sarif_om._version_control_details import VersionControlDetails
from sarif_om._web_request import WebRequest
from sarif_om._web_response import WebResponse
from ._sarif_log import SarifLog
from ._address import Address
from ._artifact import Artifact
from ._artifact_change import ArtifactChange
from ._artifact_content import ArtifactContent
from ._artifact_location import ArtifactLocation
from ._attachment import Attachment
from ._code_flow import CodeFlow
from ._configuration_override import ConfigurationOverride
from ._conversion import Conversion
from ._edge import Edge
from ._edge_traversal import EdgeTraversal
from ._exception import Exception
from ._external_properties import ExternalProperties
from ._external_property_file_reference import ExternalPropertyFileReference
from ._external_property_file_references import ExternalPropertyFileReferences
from ._fix import Fix
from ._graph import Graph
from ._graph_traversal import GraphTraversal
from ._invocation import Invocation
from ._location import Location
from ._location_relationship import LocationRelationship
from ._logical_location import LogicalLocation
from ._message import Message
from ._multiformat_message_string import MultiformatMessageString
from ._node import Node
from ._notification import Notification
from ._physical_location import PhysicalLocation
from ._property_bag import PropertyBag
from ._rectangle import Rectangle
from ._region import Region
from ._replacement import Replacement
from ._reporting_configuration import ReportingConfiguration
from ._reporting_descriptor import ReportingDescriptor
from ._reporting_descriptor_reference import ReportingDescriptorReference
from ._reporting_descriptor_relationship import ReportingDescriptorRelationship
from ._result import Result
from ._result_provenance import ResultProvenance
from ._run import Run
from ._run_automation_details import RunAutomationDetails
from ._special_locations import SpecialLocations
from ._stack import Stack
from ._stack_frame import StackFrame
from ._suppression import Suppression
from ._thread_flow import ThreadFlow
from ._thread_flow_location import ThreadFlowLocation
from ._tool import Tool
from ._tool_component import ToolComponent
from ._tool_component_reference import ToolComponentReference
from ._translation_metadata import TranslationMetadata
from ._version_control_details import VersionControlDetails
from ._web_request import WebRequest
from ._web_response import WebResponse
28 changes: 15 additions & 13 deletions sarif_om/_address.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# This file was generated by jschema_to_python version 1.2.3.

import attr
from ._property_bag import PropertyBag
from attrs import define
from attrs import field


@attr.s
class Address(object):
@define()
class Address:
"""A physical or virtual address, or a range of addresses, in an 'addressable region' (memory or a binary file)."""

absolute_address = attr.ib(default=-1, metadata={"schema_property_name": "absoluteAddress"})
fully_qualified_name = attr.ib(default=None, metadata={"schema_property_name": "fullyQualifiedName"})
index = attr.ib(default=-1, metadata={"schema_property_name": "index"})
kind = attr.ib(default=None, metadata={"schema_property_name": "kind"})
length = attr.ib(default=None, metadata={"schema_property_name": "length"})
name = attr.ib(default=None, metadata={"schema_property_name": "name"})
offset_from_parent = attr.ib(default=None, metadata={"schema_property_name": "offsetFromParent"})
parent_index = attr.ib(default=-1, metadata={"schema_property_name": "parentIndex"})
properties = attr.ib(default=None, metadata={"schema_property_name": "properties"})
relative_address = attr.ib(default=None, metadata={"schema_property_name": "relativeAddress"})
absolute_address : int = field(default=-1, metadata={"schema_property_name": "absoluteAddress"})
fully_qualified_name : str = field(default=None, metadata={"schema_property_name": "fullyQualifiedName"})
index : int = field(default=-1, metadata={"schema_property_name": "index"})
kind : str = field(default=None, metadata={"schema_property_name": "kind"})
length : int = field(default=None, metadata={"schema_property_name": "length"})
name : str = field(default=None, metadata={"schema_property_name": "name"})
offset_from_parent : int = field(default=None, metadata={"schema_property_name": "offsetFromParent"})
parent_index : int = field(default=-1, metadata={"schema_property_name": "parentIndex"})
properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"})
relative_address : int = field(default=None, metadata={"schema_property_name": "relativeAddress"})
37 changes: 21 additions & 16 deletions sarif_om/_artifact.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
# This file was generated by jschema_to_python version 1.2.3.

import attr
from ._artifact_content import ArtifactContent
from ._artifact_location import ArtifactLocation
from ._message import Message
from ._property_bag import PropertyBag
from attrs import define
from attrs import field


@attr.s
class Artifact(object):
@define()
class Artifact:
"""A single artifact. In some cases, this artifact might be nested within another artifact."""

contents = attr.ib(default=None, metadata={"schema_property_name": "contents"})
description = attr.ib(default=None, metadata={"schema_property_name": "description"})
encoding = attr.ib(default=None, metadata={"schema_property_name": "encoding"})
hashes = attr.ib(default=None, metadata={"schema_property_name": "hashes"})
last_modified_time_utc = attr.ib(default=None, metadata={"schema_property_name": "lastModifiedTimeUtc"})
length = attr.ib(default=-1, metadata={"schema_property_name": "length"})
location = attr.ib(default=None, metadata={"schema_property_name": "location"})
mime_type = attr.ib(default=None, metadata={"schema_property_name": "mimeType"})
offset = attr.ib(default=None, metadata={"schema_property_name": "offset"})
parent_index = attr.ib(default=-1, metadata={"schema_property_name": "parentIndex"})
properties = attr.ib(default=None, metadata={"schema_property_name": "properties"})
roles = attr.ib(default=None, metadata={"schema_property_name": "roles"})
source_language = attr.ib(default=None, metadata={"schema_property_name": "sourceLanguage"})
contents : ArtifactContent = field(default=None, metadata={"schema_property_name": "contents"})
description : Message = field(default=None, metadata={"schema_property_name": "description"})
encoding : str = field(default=None, metadata={"schema_property_name": "encoding"})
hashes : dict[str, str] = field(default=None, metadata={"schema_property_name": "hashes"})
last_modified_time_utc : str = field(default=None, metadata={"schema_property_name": "lastModifiedTimeUtc"})
length : int = field(default=-1, metadata={"schema_property_name": "length"})
location : ArtifactLocation = field(default=None, metadata={"schema_property_name": "location"})
mime_type : str = field(default=None, metadata={"schema_property_name": "mimeType"})
offset : int = field(default=None, metadata={"schema_property_name": "offset"})
parent_index : int = field(default=-1, metadata={"schema_property_name": "parentIndex"})
properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"})
roles : list[str] = field(factory=list, metadata={"schema_property_name": "roles"})
source_language : str = field(default=None, metadata={"schema_property_name": "sourceLanguage"})
16 changes: 10 additions & 6 deletions sarif_om/_artifact_change.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# This file was generated by jschema_to_python version 1.2.3.

import attr
from ._artifact_location import ArtifactLocation
from ._property_bag import PropertyBag
from ._replacement import Replacement
from attrs import define
from attrs import field


@attr.s
class ArtifactChange(object):
@define()
class ArtifactChange:
"""A change to a single artifact."""

artifact_location = attr.ib(metadata={"schema_property_name": "artifactLocation"})
replacements = attr.ib(metadata={"schema_property_name": "replacements"})
properties = attr.ib(default=None, metadata={"schema_property_name": "properties"})
artifact_location : ArtifactLocation = field(metadata={"schema_property_name": "artifactLocation"})
replacements : list[Replacement] = field(metadata={"schema_property_name": "replacements"})
properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"})
17 changes: 10 additions & 7 deletions sarif_om/_artifact_content.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# This file was generated by jschema_to_python version 1.2.3.

import attr
from ._multiformat_message_string import MultiformatMessageString
from ._property_bag import PropertyBag
from attrs import define
from attrs import field


@attr.s
class ArtifactContent(object):
@define()
class ArtifactContent:
"""Represents the contents of an artifact."""

binary = attr.ib(default=None, metadata={"schema_property_name": "binary"})
properties = attr.ib(default=None, metadata={"schema_property_name": "properties"})
rendered = attr.ib(default=None, metadata={"schema_property_name": "rendered"})
text = attr.ib(default=None, metadata={"schema_property_name": "text"})
binary : str = field(default=None, metadata={"schema_property_name": "binary"})
properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"})
rendered : MultiformatMessageString = field(default=None, metadata={"schema_property_name": "rendered"})
text : str = field(default=None, metadata={"schema_property_name": "text"})
19 changes: 11 additions & 8 deletions sarif_om/_artifact_location.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# This file was generated by jschema_to_python version 1.2.3.

import attr
from ._message import Message
from ._property_bag import PropertyBag
from attrs import define
from attrs import field


@attr.s
class ArtifactLocation(object):
@define()
class ArtifactLocation:
"""Specifies the location of an artifact."""

description = attr.ib(default=None, metadata={"schema_property_name": "description"})
index = attr.ib(default=-1, metadata={"schema_property_name": "index"})
properties = attr.ib(default=None, metadata={"schema_property_name": "properties"})
uri = attr.ib(default=None, metadata={"schema_property_name": "uri"})
uri_base_id = attr.ib(default=None, metadata={"schema_property_name": "uriBaseId"})
description : Message = field(default=None, metadata={"schema_property_name": "description"})
index : int = field(default=-1, metadata={"schema_property_name": "index"})
properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"})
uri : str = field(default=None, metadata={"schema_property_name": "uri"})
uri_base_id : str = field(default=None, metadata={"schema_property_name": "uriBaseId"})
22 changes: 14 additions & 8 deletions sarif_om/_attachment.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# This file was generated by jschema_to_python version 1.2.3.

import attr
from ._artifact_location import ArtifactLocation
from ._message import Message
from ._property_bag import PropertyBag
from ._rectangle import Rectangle
from ._region import Region
from attrs import define
from attrs import field


@attr.s
class Attachment(object):
@define()
class Attachment:
"""An artifact relevant to a result."""

artifact_location = attr.ib(metadata={"schema_property_name": "artifactLocation"})
description = attr.ib(default=None, metadata={"schema_property_name": "description"})
properties = attr.ib(default=None, metadata={"schema_property_name": "properties"})
rectangles = attr.ib(default=None, metadata={"schema_property_name": "rectangles"})
regions = attr.ib(default=None, metadata={"schema_property_name": "regions"})
artifact_location : ArtifactLocation = field(metadata={"schema_property_name": "artifactLocation"})
description : Message = field(default=None, metadata={"schema_property_name": "description"})
properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"})
rectangles : list[Rectangle] = field(factory=list, metadata={"schema_property_name": "rectangles"})
regions : list[Region] = field(factory=list, metadata={"schema_property_name": "regions"})
16 changes: 10 additions & 6 deletions sarif_om/_code_flow.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# This file was generated by jschema_to_python version 1.2.3.

import attr
from ._message import Message
from ._property_bag import PropertyBag
from ._thread_flow import ThreadFlow
from attrs import define
from attrs import field


@attr.s
class CodeFlow(object):
@define()
class CodeFlow:
"""A set of threadFlows which together describe a pattern of code execution relevant to detecting a result."""

thread_flows = attr.ib(metadata={"schema_property_name": "threadFlows"})
message = attr.ib(default=None, metadata={"schema_property_name": "message"})
properties = attr.ib(default=None, metadata={"schema_property_name": "properties"})
thread_flows : list[ThreadFlow] = field(metadata={"schema_property_name": "threadFlows"})
message : Message = field(default=None, metadata={"schema_property_name": "message"})
properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"})
16 changes: 10 additions & 6 deletions sarif_om/_configuration_override.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# This file was generated by jschema_to_python version 1.2.3.

import attr
from ._property_bag import PropertyBag
from ._reporting_configuration import ReportingConfiguration
from ._reporting_descriptor_reference import ReportingDescriptorReference
from attrs import define
from attrs import field


@attr.s
class ConfigurationOverride(object):
@define()
class ConfigurationOverride:
"""Information about how a specific rule or notification was reconfigured at runtime."""

configuration = attr.ib(metadata={"schema_property_name": "configuration"})
descriptor = attr.ib(metadata={"schema_property_name": "descriptor"})
properties = attr.ib(default=None, metadata={"schema_property_name": "properties"})
configuration : ReportingConfiguration = field(metadata={"schema_property_name": "configuration"})
descriptor : ReportingDescriptorReference = field(metadata={"schema_property_name": "descriptor"})
properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"})
19 changes: 12 additions & 7 deletions sarif_om/_conversion.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# This file was generated by jschema_to_python version 1.2.3.

import attr
from ._artifact_location import ArtifactLocation
from ._invocation import Invocation
from ._property_bag import PropertyBag
from ._tool import Tool
from attrs import define
from attrs import field


@attr.s
class Conversion(object):
@define()
class Conversion:
"""Describes how a converter transformed the output of a static analysis tool from the analysis tool's native output format into the SARIF format."""

tool = attr.ib(metadata={"schema_property_name": "tool"})
analysis_tool_log_files = attr.ib(default=None, metadata={"schema_property_name": "analysisToolLogFiles"})
invocation = attr.ib(default=None, metadata={"schema_property_name": "invocation"})
properties = attr.ib(default=None, metadata={"schema_property_name": "properties"})
tool : Tool = field(metadata={"schema_property_name": "tool"})
analysis_tool_log_files : list[ArtifactLocation] = field(factory=list, metadata={"schema_property_name": "analysisToolLogFiles"})
invocation : Invocation = field(default=None, metadata={"schema_property_name": "invocation"})
properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"})
Loading