diff --git a/README.rst b/README.rst index 227984a..d19d947 100644 --- a/README.rst +++ b/README.rst @@ -22,6 +22,71 @@ 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 + + from sarif_om import SarifLog, Run, Tool, ToolComponent, Result, Message + + + sarif_log = SarifLog( + version="2.1.0", + runs=[ + Run( + tool=Tool( + driver=ToolComponent( + name="My Static Analyzer", + version="1.0.0", + ) + ), + results=[ + Result( + rule_id="R001", + message=Message(text="Use of uninitialized variable 'x'"), + ) + ], + ) + ], + ) + + print(sarif_log) + +To serialize it to plain dict or JSON: + +.. code-block:: python + + from sarif_om import to_dict, to_json + + print(to_json(sarif_log)) + print(to_dict(sarif_log)) + +To deserialize dict/JSON data to ``sarif_om.SarifLog``: + +.. code-block:: python + + import json + from sarif_om import from_dict, from_json + + + sarif_log_dict = { + "runs": [ + { + "tool": {"driver": {"name": "My Static Analyzer", "version": "1.0.0"}}, + "results": [ + { + "message": {"text": "Use of uninitialized variable 'x'"}, + "ruleId": "R001", + } + ], + } + ], + "version": "2.1.0", + } + + print(from_dict(sarif_log_dict)) + print(from_json(json.dumps(sarif_log_dict))) + Generation ========== diff --git a/sarif_om/__init__.py b/sarif_om/__init__.py index c5a1f49..b742320 100644 --- a/sarif_om/__init__.py +++ b/sarif_om/__init__.py @@ -1,55 +1,114 @@ # 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 +import json +from typing import Dict +from attrs import has, fields +from cattrs import Converter +from cattrs.gen import make_dict_unstructure_fn, make_dict_structure_fn, override + +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 + + +def _generate_sarif_report_cattrs_converter() -> Converter: + converter = Converter() + + def _unstructure(cls): + return make_dict_unstructure_fn( + cls, + converter, + **{ + a.name: override( + rename=a.metadata["schema_property_name"], + omit_if_default=True, + ) + for a in fields(cls) + }, + ) + + def _structure(cls): + return make_dict_structure_fn( + cls, + converter, + **{ + a.name: override( + rename=a.metadata["schema_property_name"], + ) + for a in fields(cls) + }, + ) + + converter.register_unstructure_hook_factory(has, _unstructure) + converter.register_structure_hook_factory(has, _structure) + return converter + + +_converter = _generate_sarif_report_cattrs_converter() + + +def to_dict(sarif_log: SarifLog) -> Dict: + return _converter.unstructure(sarif_log, SarifLog) + + +def to_json(sarif_log: SarifLog, indent=2) -> str: + obj = to_dict(sarif_log) + return json.dumps(obj, indent=indent) + + +def from_dict(data: Dict) -> SarifLog: + return _converter.structure(data, SarifLog) + + +def from_json(data: str) -> SarifLog: + return from_dict(json.loads(data)) diff --git a/sarif_om/_address.py b/sarif_om/_address.py index 0bbb92a..20a5ffb 100644 --- a/sarif_om/_address.py +++ b/sarif_om/_address.py @@ -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"}) diff --git a/sarif_om/_artifact.py b/sarif_om/_artifact.py index 8b9a6ed..e21c51a 100644 --- a/sarif_om/_artifact.py +++ b/sarif_om/_artifact.py @@ -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"}) diff --git a/sarif_om/_artifact_change.py b/sarif_om/_artifact_change.py index d4ab577..9ad1211 100644 --- a/sarif_om/_artifact_change.py +++ b/sarif_om/_artifact_change.py @@ -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"}) diff --git a/sarif_om/_artifact_content.py b/sarif_om/_artifact_content.py index 3d6445b..026daf1 100644 --- a/sarif_om/_artifact_content.py +++ b/sarif_om/_artifact_content.py @@ -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"}) diff --git a/sarif_om/_artifact_location.py b/sarif_om/_artifact_location.py index abf652d..e1bf236 100644 --- a/sarif_om/_artifact_location.py +++ b/sarif_om/_artifact_location.py @@ -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"}) diff --git a/sarif_om/_attachment.py b/sarif_om/_attachment.py index 20e580e..71c95ab 100644 --- a/sarif_om/_attachment.py +++ b/sarif_om/_attachment.py @@ -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"}) diff --git a/sarif_om/_code_flow.py b/sarif_om/_code_flow.py index e96bb62..601dc5f 100644 --- a/sarif_om/_code_flow.py +++ b/sarif_om/_code_flow.py @@ -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"}) diff --git a/sarif_om/_configuration_override.py b/sarif_om/_configuration_override.py index 8a6b8b0..3207050 100644 --- a/sarif_om/_configuration_override.py +++ b/sarif_om/_configuration_override.py @@ -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"}) diff --git a/sarif_om/_conversion.py b/sarif_om/_conversion.py index bd3cbcc..3487e4c 100644 --- a/sarif_om/_conversion.py +++ b/sarif_om/_conversion.py @@ -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"}) diff --git a/sarif_om/_edge.py b/sarif_om/_edge.py index b972653..a5acfc1 100644 --- a/sarif_om/_edge.py +++ b/sarif_om/_edge.py @@ -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 Edge(object): +@define() +class Edge: """Represents a directed edge in a graph.""" - id = attr.ib(metadata={"schema_property_name": "id"}) - source_node_id = attr.ib(metadata={"schema_property_name": "sourceNodeId"}) - target_node_id = attr.ib(metadata={"schema_property_name": "targetNodeId"}) - label = attr.ib(default=None, metadata={"schema_property_name": "label"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) + id : str = field(metadata={"schema_property_name": "id"}) + source_node_id : str = field(metadata={"schema_property_name": "sourceNodeId"}) + target_node_id : str = field(metadata={"schema_property_name": "targetNodeId"}) + label : Message = field(default=None, metadata={"schema_property_name": "label"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) diff --git a/sarif_om/_edge_traversal.py b/sarif_om/_edge_traversal.py index 6462245..a841c0c 100644 --- a/sarif_om/_edge_traversal.py +++ b/sarif_om/_edge_traversal.py @@ -1,14 +1,18 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._message import Message +from ._multiformat_message_string import MultiformatMessageString +from ._property_bag import PropertyBag +from attrs import define +from attrs import field -@attr.s -class EdgeTraversal(object): +@define() +class EdgeTraversal: """Represents the traversal of a single edge during a graph traversal.""" - edge_id = attr.ib(metadata={"schema_property_name": "edgeId"}) - final_state = attr.ib(default=None, metadata={"schema_property_name": "finalState"}) - message = attr.ib(default=None, metadata={"schema_property_name": "message"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - step_over_edge_count = attr.ib(default=None, metadata={"schema_property_name": "stepOverEdgeCount"}) + edge_id : str = field(metadata={"schema_property_name": "edgeId"}) + final_state : dict[str, MultiformatMessageString] = field(default=None, metadata={"schema_property_name": "finalState"}) + message : Message = field(default=None, metadata={"schema_property_name": "message"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + step_over_edge_count : int = field(default=None, metadata={"schema_property_name": "stepOverEdgeCount"}) diff --git a/sarif_om/_exception.py b/sarif_om/_exception.py index a52fb0f..1a8b637 100644 --- a/sarif_om/_exception.py +++ b/sarif_om/_exception.py @@ -1,14 +1,17 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._property_bag import PropertyBag +from ._stack import Stack +from attrs import define +from attrs import field -@attr.s -class Exception(object): +@define() +class Exception: """Describes a runtime exception encountered during the execution of an analysis tool.""" - inner_exceptions = attr.ib(default=None, metadata={"schema_property_name": "innerExceptions"}) - kind = attr.ib(default=None, metadata={"schema_property_name": "kind"}) - message = attr.ib(default=None, metadata={"schema_property_name": "message"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - stack = attr.ib(default=None, metadata={"schema_property_name": "stack"}) + inner_exceptions : list["Exception"] = field(factory=list, metadata={"schema_property_name": "innerExceptions"}) + kind : str = field(default=None, metadata={"schema_property_name": "kind"}) + message : str = field(default=None, metadata={"schema_property_name": "message"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + stack : Stack = field(default=None, metadata={"schema_property_name": "stack"}) diff --git a/sarif_om/_external_properties.py b/sarif_om/_external_properties.py index 0bc0b7d..67e5875 100644 --- a/sarif_om/_external_properties.py +++ b/sarif_om/_external_properties.py @@ -1,30 +1,43 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._address import Address +from ._artifact import Artifact +from ._conversion import Conversion +from ._graph import Graph +from ._invocation import Invocation +from ._logical_location import LogicalLocation +from ._property_bag import PropertyBag +from ._result import Result +from ._thread_flow_location import ThreadFlowLocation +from ._tool_component import ToolComponent +from ._web_request import WebRequest +from ._web_response import WebResponse +from attrs import define +from attrs import field -@attr.s -class ExternalProperties(object): +@define() +class ExternalProperties: """The top-level element of an external property file.""" - addresses = attr.ib(default=None, metadata={"schema_property_name": "addresses"}) - artifacts = attr.ib(default=None, metadata={"schema_property_name": "artifacts"}) - conversion = attr.ib(default=None, metadata={"schema_property_name": "conversion"}) - driver = attr.ib(default=None, metadata={"schema_property_name": "driver"}) - extensions = attr.ib(default=None, metadata={"schema_property_name": "extensions"}) - externalized_properties = attr.ib(default=None, metadata={"schema_property_name": "externalizedProperties"}) - graphs = attr.ib(default=None, metadata={"schema_property_name": "graphs"}) - guid = attr.ib(default=None, metadata={"schema_property_name": "guid"}) - invocations = attr.ib(default=None, metadata={"schema_property_name": "invocations"}) - logical_locations = attr.ib(default=None, metadata={"schema_property_name": "logicalLocations"}) - policies = attr.ib(default=None, metadata={"schema_property_name": "policies"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - results = attr.ib(default=None, metadata={"schema_property_name": "results"}) - run_guid = attr.ib(default=None, metadata={"schema_property_name": "runGuid"}) - schema = attr.ib(default=None, metadata={"schema_property_name": "schema"}) - taxonomies = attr.ib(default=None, metadata={"schema_property_name": "taxonomies"}) - thread_flow_locations = attr.ib(default=None, metadata={"schema_property_name": "threadFlowLocations"}) - translations = attr.ib(default=None, metadata={"schema_property_name": "translations"}) - version = attr.ib(default=None, metadata={"schema_property_name": "version"}) - web_requests = attr.ib(default=None, metadata={"schema_property_name": "webRequests"}) - web_responses = attr.ib(default=None, metadata={"schema_property_name": "webResponses"}) + addresses : list[Address] = field(factory=list, metadata={"schema_property_name": "addresses"}) + artifacts : list[Artifact] = field(factory=list, metadata={"schema_property_name": "artifacts"}) + conversion : Conversion = field(default=None, metadata={"schema_property_name": "conversion"}) + driver : ToolComponent = field(default=None, metadata={"schema_property_name": "driver"}) + extensions : list[ToolComponent] = field(factory=list, metadata={"schema_property_name": "extensions"}) + externalized_properties : PropertyBag = field(default=None, metadata={"schema_property_name": "externalizedProperties"}) + graphs : list[Graph] = field(factory=list, metadata={"schema_property_name": "graphs"}) + guid : str = field(default=None, metadata={"schema_property_name": "guid"}) + invocations : list[Invocation] = field(factory=list, metadata={"schema_property_name": "invocations"}) + logical_locations : list[LogicalLocation] = field(factory=list, metadata={"schema_property_name": "logicalLocations"}) + policies : list[ToolComponent] = field(factory=list, metadata={"schema_property_name": "policies"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + results : list[Result] = field(factory=list, metadata={"schema_property_name": "results"}) + run_guid : str = field(default=None, metadata={"schema_property_name": "runGuid"}) + schema : str = field(default=None, metadata={"schema_property_name": "schema"}) + taxonomies : list[ToolComponent] = field(factory=list, metadata={"schema_property_name": "taxonomies"}) + thread_flow_locations : list[ThreadFlowLocation] = field(factory=list, metadata={"schema_property_name": "threadFlowLocations"}) + translations : list[ToolComponent] = field(factory=list, metadata={"schema_property_name": "translations"}) + version : str = field(default=None, metadata={"schema_property_name": "version"}) + web_requests : list[WebRequest] = field(factory=list, metadata={"schema_property_name": "webRequests"}) + web_responses : list[WebResponse] = field(factory=list, metadata={"schema_property_name": "webResponses"}) diff --git a/sarif_om/_external_property_file_reference.py b/sarif_om/_external_property_file_reference.py index 7358f3a..f0b6046 100644 --- a/sarif_om/_external_property_file_reference.py +++ b/sarif_om/_external_property_file_reference.py @@ -1,13 +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 attrs import define +from attrs import field -@attr.s -class ExternalPropertyFileReference(object): +@define() +class ExternalPropertyFileReference: """Contains information that enables a SARIF consumer to locate the external property file that contains the value of an externalized property associated with the run.""" - guid = attr.ib(default=None, metadata={"schema_property_name": "guid"}) - item_count = attr.ib(default=-1, metadata={"schema_property_name": "itemCount"}) - location = attr.ib(default=None, metadata={"schema_property_name": "location"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) + guid : str = field(default=None, metadata={"schema_property_name": "guid"}) + item_count : int = field(default=-1, metadata={"schema_property_name": "itemCount"}) + location : ArtifactLocation = field(default=None, metadata={"schema_property_name": "location"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) diff --git a/sarif_om/_external_property_file_references.py b/sarif_om/_external_property_file_references.py index 979f1d0..1597590 100644 --- a/sarif_om/_external_property_file_references.py +++ b/sarif_om/_external_property_file_references.py @@ -1,26 +1,29 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._external_property_file_reference import ExternalPropertyFileReference +from ._property_bag import PropertyBag +from attrs import define +from attrs import field -@attr.s -class ExternalPropertyFileReferences(object): +@define() +class ExternalPropertyFileReferences: """References to external property files that should be inlined with the content of a root log file.""" - addresses = attr.ib(default=None, metadata={"schema_property_name": "addresses"}) - artifacts = attr.ib(default=None, metadata={"schema_property_name": "artifacts"}) - conversion = attr.ib(default=None, metadata={"schema_property_name": "conversion"}) - driver = attr.ib(default=None, metadata={"schema_property_name": "driver"}) - extensions = attr.ib(default=None, metadata={"schema_property_name": "extensions"}) - externalized_properties = attr.ib(default=None, metadata={"schema_property_name": "externalizedProperties"}) - graphs = attr.ib(default=None, metadata={"schema_property_name": "graphs"}) - invocations = attr.ib(default=None, metadata={"schema_property_name": "invocations"}) - logical_locations = attr.ib(default=None, metadata={"schema_property_name": "logicalLocations"}) - policies = attr.ib(default=None, metadata={"schema_property_name": "policies"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - results = attr.ib(default=None, metadata={"schema_property_name": "results"}) - taxonomies = attr.ib(default=None, metadata={"schema_property_name": "taxonomies"}) - thread_flow_locations = attr.ib(default=None, metadata={"schema_property_name": "threadFlowLocations"}) - translations = attr.ib(default=None, metadata={"schema_property_name": "translations"}) - web_requests = attr.ib(default=None, metadata={"schema_property_name": "webRequests"}) - web_responses = attr.ib(default=None, metadata={"schema_property_name": "webResponses"}) + addresses : list[ExternalPropertyFileReference] = field(factory=list, metadata={"schema_property_name": "addresses"}) + artifacts : list[ExternalPropertyFileReference] = field(factory=list, metadata={"schema_property_name": "artifacts"}) + conversion : ExternalPropertyFileReference = field(default=None, metadata={"schema_property_name": "conversion"}) + driver : ExternalPropertyFileReference = field(default=None, metadata={"schema_property_name": "driver"}) + extensions : list[ExternalPropertyFileReference] = field(factory=list, metadata={"schema_property_name": "extensions"}) + externalized_properties : ExternalPropertyFileReference = field(default=None, metadata={"schema_property_name": "externalizedProperties"}) + graphs : list[ExternalPropertyFileReference] = field(factory=list, metadata={"schema_property_name": "graphs"}) + invocations : list[ExternalPropertyFileReference] = field(factory=list, metadata={"schema_property_name": "invocations"}) + logical_locations : list[ExternalPropertyFileReference] = field(factory=list, metadata={"schema_property_name": "logicalLocations"}) + policies : list[ExternalPropertyFileReference] = field(factory=list, metadata={"schema_property_name": "policies"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + results : list[ExternalPropertyFileReference] = field(factory=list, metadata={"schema_property_name": "results"}) + taxonomies : list[ExternalPropertyFileReference] = field(factory=list, metadata={"schema_property_name": "taxonomies"}) + thread_flow_locations : list[ExternalPropertyFileReference] = field(factory=list, metadata={"schema_property_name": "threadFlowLocations"}) + translations : list[ExternalPropertyFileReference] = field(factory=list, metadata={"schema_property_name": "translations"}) + web_requests : list[ExternalPropertyFileReference] = field(factory=list, metadata={"schema_property_name": "webRequests"}) + web_responses : list[ExternalPropertyFileReference] = field(factory=list, metadata={"schema_property_name": "webResponses"}) diff --git a/sarif_om/_fix.py b/sarif_om/_fix.py index d0c3409..413b432 100644 --- a/sarif_om/_fix.py +++ b/sarif_om/_fix.py @@ -1,12 +1,16 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._artifact_change import ArtifactChange +from ._message import Message +from ._property_bag import PropertyBag +from attrs import define +from attrs import field -@attr.s -class Fix(object): +@define() +class Fix: """A proposed fix for the problem represented by a result object. A fix specifies a set of artifacts to modify. For each artifact, it specifies a set of bytes to remove, and provides a set of new bytes to replace them.""" - artifact_changes = attr.ib(metadata={"schema_property_name": "artifactChanges"}) - description = attr.ib(default=None, metadata={"schema_property_name": "description"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) + artifact_changes : list[ArtifactChange] = field(metadata={"schema_property_name": "artifactChanges"}) + description : Message = field(default=None, metadata={"schema_property_name": "description"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) diff --git a/sarif_om/_graph.py b/sarif_om/_graph.py index fd70013..b1e8c6a 100644 --- a/sarif_om/_graph.py +++ b/sarif_om/_graph.py @@ -1,13 +1,18 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._edge import Edge +from ._message import Message +from ._node import Node +from ._property_bag import PropertyBag +from attrs import define +from attrs import field -@attr.s -class Graph(object): +@define() +class Graph: """A network of nodes and directed edges that describes some aspect of the structure of the code (for example, a call graph).""" - description = attr.ib(default=None, metadata={"schema_property_name": "description"}) - edges = attr.ib(default=None, metadata={"schema_property_name": "edges"}) - nodes = attr.ib(default=None, metadata={"schema_property_name": "nodes"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) + description : Message = field(default=None, metadata={"schema_property_name": "description"}) + edges : list[Edge] = field(factory=list, metadata={"schema_property_name": "edges"}) + nodes : list[Node] = field(factory=list, metadata={"schema_property_name": "nodes"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) diff --git a/sarif_om/_graph_traversal.py b/sarif_om/_graph_traversal.py index 798d167..361a899 100644 --- a/sarif_om/_graph_traversal.py +++ b/sarif_om/_graph_traversal.py @@ -1,16 +1,21 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._edge_traversal import EdgeTraversal +from ._message import Message +from ._multiformat_message_string import MultiformatMessageString +from ._property_bag import PropertyBag +from attrs import define +from attrs import field -@attr.s -class GraphTraversal(object): +@define() +class GraphTraversal: """Represents a path through a graph.""" - description = attr.ib(default=None, metadata={"schema_property_name": "description"}) - edge_traversals = attr.ib(default=None, metadata={"schema_property_name": "edgeTraversals"}) - immutable_state = attr.ib(default=None, metadata={"schema_property_name": "immutableState"}) - initial_state = attr.ib(default=None, metadata={"schema_property_name": "initialState"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - result_graph_index = attr.ib(default=-1, metadata={"schema_property_name": "resultGraphIndex"}) - run_graph_index = attr.ib(default=-1, metadata={"schema_property_name": "runGraphIndex"}) + description : Message = field(default=None, metadata={"schema_property_name": "description"}) + edge_traversals : list[EdgeTraversal] = field(factory=list, metadata={"schema_property_name": "edgeTraversals"}) + immutable_state : dict[str, MultiformatMessageString] = field(default=None, metadata={"schema_property_name": "immutableState"}) + initial_state : dict[str, MultiformatMessageString] = field(default=None, metadata={"schema_property_name": "initialState"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + result_graph_index : int = field(default=-1, metadata={"schema_property_name": "resultGraphIndex"}) + run_graph_index : int = field(default=-1, metadata={"schema_property_name": "runGraphIndex"}) diff --git a/sarif_om/_invocation.py b/sarif_om/_invocation.py index 86ec577..a3a2059 100644 --- a/sarif_om/_invocation.py +++ b/sarif_om/_invocation.py @@ -1,35 +1,40 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._artifact_location import ArtifactLocation +from ._configuration_override import ConfigurationOverride +from ._notification import Notification +from ._property_bag import PropertyBag +from attrs import define +from attrs import field -@attr.s -class Invocation(object): +@define() +class Invocation: """The runtime environment of the analysis tool run.""" - execution_successful = attr.ib(metadata={"schema_property_name": "executionSuccessful"}) - account = attr.ib(default=None, metadata={"schema_property_name": "account"}) - arguments = attr.ib(default=None, metadata={"schema_property_name": "arguments"}) - command_line = attr.ib(default=None, metadata={"schema_property_name": "commandLine"}) - end_time_utc = attr.ib(default=None, metadata={"schema_property_name": "endTimeUtc"}) - environment_variables = attr.ib(default=None, metadata={"schema_property_name": "environmentVariables"}) - executable_location = attr.ib(default=None, metadata={"schema_property_name": "executableLocation"}) - exit_code = attr.ib(default=None, metadata={"schema_property_name": "exitCode"}) - exit_code_description = attr.ib(default=None, metadata={"schema_property_name": "exitCodeDescription"}) - exit_signal_name = attr.ib(default=None, metadata={"schema_property_name": "exitSignalName"}) - exit_signal_number = attr.ib(default=None, metadata={"schema_property_name": "exitSignalNumber"}) - machine = attr.ib(default=None, metadata={"schema_property_name": "machine"}) - notification_configuration_overrides = attr.ib(default=None, metadata={"schema_property_name": "notificationConfigurationOverrides"}) - process_id = attr.ib(default=None, metadata={"schema_property_name": "processId"}) - process_start_failure_message = attr.ib(default=None, metadata={"schema_property_name": "processStartFailureMessage"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - response_files = attr.ib(default=None, metadata={"schema_property_name": "responseFiles"}) - rule_configuration_overrides = attr.ib(default=None, metadata={"schema_property_name": "ruleConfigurationOverrides"}) - start_time_utc = attr.ib(default=None, metadata={"schema_property_name": "startTimeUtc"}) - stderr = attr.ib(default=None, metadata={"schema_property_name": "stderr"}) - stdin = attr.ib(default=None, metadata={"schema_property_name": "stdin"}) - stdout = attr.ib(default=None, metadata={"schema_property_name": "stdout"}) - stdout_stderr = attr.ib(default=None, metadata={"schema_property_name": "stdoutStderr"}) - tool_configuration_notifications = attr.ib(default=None, metadata={"schema_property_name": "toolConfigurationNotifications"}) - tool_execution_notifications = attr.ib(default=None, metadata={"schema_property_name": "toolExecutionNotifications"}) - working_directory = attr.ib(default=None, metadata={"schema_property_name": "workingDirectory"}) + execution_successful : bool = field(metadata={"schema_property_name": "executionSuccessful"}) + account : str = field(default=None, metadata={"schema_property_name": "account"}) + arguments : list[str] = field(factory=list, metadata={"schema_property_name": "arguments"}) + command_line : str = field(default=None, metadata={"schema_property_name": "commandLine"}) + end_time_utc : str = field(default=None, metadata={"schema_property_name": "endTimeUtc"}) + environment_variables : dict[str, str] = field(default=None, metadata={"schema_property_name": "environmentVariables"}) + executable_location : ArtifactLocation = field(default=None, metadata={"schema_property_name": "executableLocation"}) + exit_code : int = field(default=None, metadata={"schema_property_name": "exitCode"}) + exit_code_description : str = field(default=None, metadata={"schema_property_name": "exitCodeDescription"}) + exit_signal_name : str = field(default=None, metadata={"schema_property_name": "exitSignalName"}) + exit_signal_number : int = field(default=None, metadata={"schema_property_name": "exitSignalNumber"}) + machine : str = field(default=None, metadata={"schema_property_name": "machine"}) + notification_configuration_overrides : list[ConfigurationOverride] = field(factory=list, metadata={"schema_property_name": "notificationConfigurationOverrides"}) + process_id : int = field(default=None, metadata={"schema_property_name": "processId"}) + process_start_failure_message : str = field(default=None, metadata={"schema_property_name": "processStartFailureMessage"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + response_files : list[ArtifactLocation] = field(factory=list, metadata={"schema_property_name": "responseFiles"}) + rule_configuration_overrides : list[ConfigurationOverride] = field(factory=list, metadata={"schema_property_name": "ruleConfigurationOverrides"}) + start_time_utc : str = field(default=None, metadata={"schema_property_name": "startTimeUtc"}) + stderr : ArtifactLocation = field(default=None, metadata={"schema_property_name": "stderr"}) + stdin : ArtifactLocation = field(default=None, metadata={"schema_property_name": "stdin"}) + stdout : ArtifactLocation = field(default=None, metadata={"schema_property_name": "stdout"}) + stdout_stderr : ArtifactLocation = field(default=None, metadata={"schema_property_name": "stdoutStderr"}) + tool_configuration_notifications : list[Notification] = field(factory=list, metadata={"schema_property_name": "toolConfigurationNotifications"}) + tool_execution_notifications : list[Notification] = field(factory=list, metadata={"schema_property_name": "toolExecutionNotifications"}) + working_directory : ArtifactLocation = field(default=None, metadata={"schema_property_name": "workingDirectory"}) diff --git a/sarif_om/_location.py b/sarif_om/_location.py index 51538d1..e3ae727 100644 --- a/sarif_om/_location.py +++ b/sarif_om/_location.py @@ -1,16 +1,23 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._location_relationship import LocationRelationship +from ._logical_location import LogicalLocation +from ._message import Message +from ._physical_location import PhysicalLocation +from ._property_bag import PropertyBag +from ._region import Region +from attrs import define +from attrs import field -@attr.s -class Location(object): +@define() +class Location: """A location within a programming artifact.""" - annotations = attr.ib(default=None, metadata={"schema_property_name": "annotations"}) - id = attr.ib(default=-1, metadata={"schema_property_name": "id"}) - logical_locations = attr.ib(default=None, metadata={"schema_property_name": "logicalLocations"}) - message = attr.ib(default=None, metadata={"schema_property_name": "message"}) - physical_location = attr.ib(default=None, metadata={"schema_property_name": "physicalLocation"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - relationships = attr.ib(default=None, metadata={"schema_property_name": "relationships"}) + annotations : list[Region] = field(factory=list, metadata={"schema_property_name": "annotations"}) + id : int = field(default=-1, metadata={"schema_property_name": "id"}) + logical_locations : list[LogicalLocation] = field(factory=list, metadata={"schema_property_name": "logicalLocations"}) + message : Message = field(default=None, metadata={"schema_property_name": "message"}) + physical_location : PhysicalLocation = field(default=None, metadata={"schema_property_name": "physicalLocation"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + relationships : list[LocationRelationship] = field(factory=list, metadata={"schema_property_name": "relationships"}) diff --git a/sarif_om/_location_relationship.py b/sarif_om/_location_relationship.py index 4fdc137..ac70330 100644 --- a/sarif_om/_location_relationship.py +++ b/sarif_om/_location_relationship.py @@ -1,13 +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 attrs import define +from attrs import field -@attr.s -class LocationRelationship(object): +@define() +class LocationRelationship: """Information about the relation of one location to another.""" - target = attr.ib(metadata={"schema_property_name": "target"}) - description = attr.ib(default=None, metadata={"schema_property_name": "description"}) - kinds = attr.ib(default=attr.Factory(lambda: ['relevant']), metadata={"schema_property_name": "kinds"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) + target : int = field(metadata={"schema_property_name": "target"}) + description : Message = field(default=None, metadata={"schema_property_name": "description"}) + kinds : list[str] = field(factory=lambda: ['relevant'], metadata={"schema_property_name": "kinds"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) diff --git a/sarif_om/_logical_location.py b/sarif_om/_logical_location.py index 5737db5..09abfa5 100644 --- a/sarif_om/_logical_location.py +++ b/sarif_om/_logical_location.py @@ -1,16 +1,18 @@ # 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 LogicalLocation(object): +@define() +class LogicalLocation: """A logical location of a construct that produced a result.""" - decorated_name = attr.ib(default=None, metadata={"schema_property_name": "decoratedName"}) - 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"}) - name = attr.ib(default=None, metadata={"schema_property_name": "name"}) - parent_index = attr.ib(default=-1, metadata={"schema_property_name": "parentIndex"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) + decorated_name : str = field(default=None, metadata={"schema_property_name": "decoratedName"}) + 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"}) + name : str = field(default=None, metadata={"schema_property_name": "name"}) + parent_index : int = field(default=-1, metadata={"schema_property_name": "parentIndex"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) diff --git a/sarif_om/_message.py b/sarif_om/_message.py index 10c7516..9d080ea 100644 --- a/sarif_om/_message.py +++ b/sarif_om/_message.py @@ -1,14 +1,16 @@ # 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 Message(object): +@define() +class Message: """Encapsulates a message intended to be read by the end user.""" - arguments = attr.ib(default=None, metadata={"schema_property_name": "arguments"}) - id = attr.ib(default=None, metadata={"schema_property_name": "id"}) - markdown = attr.ib(default=None, metadata={"schema_property_name": "markdown"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - text = attr.ib(default=None, metadata={"schema_property_name": "text"}) + arguments : list[str] = field(factory=list, metadata={"schema_property_name": "arguments"}) + id : str = field(default=None, metadata={"schema_property_name": "id"}) + markdown : str = field(default=None, metadata={"schema_property_name": "markdown"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + text : str = field(default=None, metadata={"schema_property_name": "text"}) diff --git a/sarif_om/_multiformat_message_string.py b/sarif_om/_multiformat_message_string.py index 8c1270a..67b841e 100644 --- a/sarif_om/_multiformat_message_string.py +++ b/sarif_om/_multiformat_message_string.py @@ -1,12 +1,14 @@ # 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 MultiformatMessageString(object): +@define() +class MultiformatMessageString: """A message string or message format string rendered in multiple formats.""" - text = attr.ib(metadata={"schema_property_name": "text"}) - markdown = attr.ib(default=None, metadata={"schema_property_name": "markdown"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) + text : str = field(metadata={"schema_property_name": "text"}) + markdown : str = field(default=None, metadata={"schema_property_name": "markdown"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) diff --git a/sarif_om/_node.py b/sarif_om/_node.py index 103783a..cfa9b55 100644 --- a/sarif_om/_node.py +++ b/sarif_om/_node.py @@ -1,14 +1,18 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._location import Location +from ._message import Message +from ._property_bag import PropertyBag +from attrs import define +from attrs import field -@attr.s -class Node(object): +@define() +class Node: """Represents a node in a graph.""" - id = attr.ib(metadata={"schema_property_name": "id"}) - children = attr.ib(default=None, metadata={"schema_property_name": "children"}) - label = attr.ib(default=None, metadata={"schema_property_name": "label"}) - location = attr.ib(default=None, metadata={"schema_property_name": "location"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) + id : str = field(metadata={"schema_property_name": "id"}) + children : list["Node"] = field(factory=list, metadata={"schema_property_name": "children"}) + label : Message = field(default=None, metadata={"schema_property_name": "label"}) + location : Location = field(default=None, metadata={"schema_property_name": "location"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) diff --git a/sarif_om/_notification.py b/sarif_om/_notification.py index 880988f..f527394 100644 --- a/sarif_om/_notification.py +++ b/sarif_om/_notification.py @@ -1,18 +1,24 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._exception import Exception +from ._location import Location +from ._message import Message +from ._property_bag import PropertyBag +from ._reporting_descriptor_reference import ReportingDescriptorReference +from attrs import define +from attrs import field -@attr.s -class Notification(object): +@define() +class Notification: """Describes a condition relevant to the tool itself, as opposed to being relevant to a target being analyzed by the tool.""" - message = attr.ib(metadata={"schema_property_name": "message"}) - associated_rule = attr.ib(default=None, metadata={"schema_property_name": "associatedRule"}) - descriptor = attr.ib(default=None, metadata={"schema_property_name": "descriptor"}) - exception = attr.ib(default=None, metadata={"schema_property_name": "exception"}) - level = attr.ib(default="warning", metadata={"schema_property_name": "level"}) - locations = attr.ib(default=None, metadata={"schema_property_name": "locations"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - thread_id = attr.ib(default=None, metadata={"schema_property_name": "threadId"}) - time_utc = attr.ib(default=None, metadata={"schema_property_name": "timeUtc"}) + message : Message = field(metadata={"schema_property_name": "message"}) + associated_rule : ReportingDescriptorReference = field(default=None, metadata={"schema_property_name": "associatedRule"}) + descriptor : ReportingDescriptorReference = field(default=None, metadata={"schema_property_name": "descriptor"}) + exception : Exception = field(default=None, metadata={"schema_property_name": "exception"}) + level : str = field(default="warning", metadata={"schema_property_name": "level"}) + locations : list[Location] = field(factory=list, metadata={"schema_property_name": "locations"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + thread_id : int = field(default=None, metadata={"schema_property_name": "threadId"}) + time_utc : str = field(default=None, metadata={"schema_property_name": "timeUtc"}) diff --git a/sarif_om/_physical_location.py b/sarif_om/_physical_location.py index 8288280..59b2893 100644 --- a/sarif_om/_physical_location.py +++ b/sarif_om/_physical_location.py @@ -1,14 +1,19 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._address import Address +from ._artifact_location import ArtifactLocation +from ._property_bag import PropertyBag +from ._region import Region +from attrs import define +from attrs import field -@attr.s -class PhysicalLocation(object): +@define() +class PhysicalLocation: """A physical location relevant to a result. Specifies a reference to a programming artifact together with a range of bytes or characters within that artifact.""" - address = attr.ib(default=None, metadata={"schema_property_name": "address"}) - artifact_location = attr.ib(default=None, metadata={"schema_property_name": "artifactLocation"}) - context_region = attr.ib(default=None, metadata={"schema_property_name": "contextRegion"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - region = attr.ib(default=None, metadata={"schema_property_name": "region"}) + address : Address = field(default=None, metadata={"schema_property_name": "address"}) + artifact_location : ArtifactLocation = field(default=None, metadata={"schema_property_name": "artifactLocation"}) + context_region : Region = field(default=None, metadata={"schema_property_name": "contextRegion"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + region : Region = field(default=None, metadata={"schema_property_name": "region"}) diff --git a/sarif_om/_property_bag.py b/sarif_om/_property_bag.py index 2000ea7..aa51ede 100644 --- a/sarif_om/_property_bag.py +++ b/sarif_om/_property_bag.py @@ -1,10 +1,11 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from attrs import define +from attrs import field -@attr.s -class PropertyBag(object): +@define() +class PropertyBag: """Key/value pairs that provide additional information about the object.""" - tags = attr.ib(default=None, metadata={"schema_property_name": "tags"}) + tags : list[str] = field(factory=list, metadata={"schema_property_name": "tags"}) diff --git a/sarif_om/_rectangle.py b/sarif_om/_rectangle.py index 255064c..e483997 100644 --- a/sarif_om/_rectangle.py +++ b/sarif_om/_rectangle.py @@ -1,15 +1,18 @@ # 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 Rectangle(object): +@define() +class Rectangle: """An area within an image.""" - bottom = attr.ib(default=None, metadata={"schema_property_name": "bottom"}) - left = attr.ib(default=None, metadata={"schema_property_name": "left"}) - message = attr.ib(default=None, metadata={"schema_property_name": "message"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - right = attr.ib(default=None, metadata={"schema_property_name": "right"}) - top = attr.ib(default=None, metadata={"schema_property_name": "top"}) + bottom : float = field(default=None, metadata={"schema_property_name": "bottom"}) + left : float = field(default=None, metadata={"schema_property_name": "left"}) + message : Message = field(default=None, metadata={"schema_property_name": "message"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + right : float = field(default=None, metadata={"schema_property_name": "right"}) + top : float = field(default=None, metadata={"schema_property_name": "top"}) diff --git a/sarif_om/_region.py b/sarif_om/_region.py index 8822b96..99a6853 100644 --- a/sarif_om/_region.py +++ b/sarif_om/_region.py @@ -1,21 +1,25 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._artifact_content import ArtifactContent +from ._message import Message +from ._property_bag import PropertyBag +from attrs import define +from attrs import field -@attr.s -class Region(object): +@define() +class Region: """A region within an artifact where a result was detected.""" - byte_length = attr.ib(default=None, metadata={"schema_property_name": "byteLength"}) - byte_offset = attr.ib(default=-1, metadata={"schema_property_name": "byteOffset"}) - char_length = attr.ib(default=None, metadata={"schema_property_name": "charLength"}) - char_offset = attr.ib(default=-1, metadata={"schema_property_name": "charOffset"}) - end_column = attr.ib(default=None, metadata={"schema_property_name": "endColumn"}) - end_line = attr.ib(default=None, metadata={"schema_property_name": "endLine"}) - message = attr.ib(default=None, metadata={"schema_property_name": "message"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - snippet = attr.ib(default=None, metadata={"schema_property_name": "snippet"}) - source_language = attr.ib(default=None, metadata={"schema_property_name": "sourceLanguage"}) - start_column = attr.ib(default=None, metadata={"schema_property_name": "startColumn"}) - start_line = attr.ib(default=None, metadata={"schema_property_name": "startLine"}) + byte_length : int = field(default=None, metadata={"schema_property_name": "byteLength"}) + byte_offset : int = field(default=-1, metadata={"schema_property_name": "byteOffset"}) + char_length : int = field(default=None, metadata={"schema_property_name": "charLength"}) + char_offset : int = field(default=-1, metadata={"schema_property_name": "charOffset"}) + end_column : int = field(default=None, metadata={"schema_property_name": "endColumn"}) + end_line : int = field(default=None, metadata={"schema_property_name": "endLine"}) + message : Message = field(default=None, metadata={"schema_property_name": "message"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + snippet : ArtifactContent = field(default=None, metadata={"schema_property_name": "snippet"}) + source_language : str = field(default=None, metadata={"schema_property_name": "sourceLanguage"}) + start_column : int = field(default=None, metadata={"schema_property_name": "startColumn"}) + start_line : int = field(default=None, metadata={"schema_property_name": "startLine"}) diff --git a/sarif_om/_replacement.py b/sarif_om/_replacement.py index bcef430..dedcc16 100644 --- a/sarif_om/_replacement.py +++ b/sarif_om/_replacement.py @@ -1,12 +1,16 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._artifact_content import ArtifactContent +from ._property_bag import PropertyBag +from ._region import Region +from attrs import define +from attrs import field -@attr.s -class Replacement(object): +@define() +class Replacement: """The replacement of a single region of an artifact.""" - deleted_region = attr.ib(metadata={"schema_property_name": "deletedRegion"}) - inserted_content = attr.ib(default=None, metadata={"schema_property_name": "insertedContent"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) + deleted_region : Region = field(metadata={"schema_property_name": "deletedRegion"}) + inserted_content : ArtifactContent = field(default=None, metadata={"schema_property_name": "insertedContent"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) diff --git a/sarif_om/_reporting_configuration.py b/sarif_om/_reporting_configuration.py index 06aaf6d..ae3efe7 100644 --- a/sarif_om/_reporting_configuration.py +++ b/sarif_om/_reporting_configuration.py @@ -1,14 +1,16 @@ # 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 ReportingConfiguration(object): +@define() +class ReportingConfiguration: """Information about a rule or notification that can be configured at runtime.""" - enabled = attr.ib(default=True, metadata={"schema_property_name": "enabled"}) - level = attr.ib(default="warning", metadata={"schema_property_name": "level"}) - parameters = attr.ib(default=None, metadata={"schema_property_name": "parameters"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - rank = attr.ib(default=-1.0, metadata={"schema_property_name": "rank"}) + enabled : bool = field(default=True, metadata={"schema_property_name": "enabled"}) + level : str = field(default="warning", metadata={"schema_property_name": "level"}) + parameters : PropertyBag = field(default=None, metadata={"schema_property_name": "parameters"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + rank : float = field(default=-1.0, metadata={"schema_property_name": "rank"}) diff --git a/sarif_om/_reporting_descriptor.py b/sarif_om/_reporting_descriptor.py index e95563f..937c58c 100644 --- a/sarif_om/_reporting_descriptor.py +++ b/sarif_om/_reporting_descriptor.py @@ -1,23 +1,28 @@ # 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 ._reporting_configuration import ReportingConfiguration +from ._reporting_descriptor_relationship import ReportingDescriptorRelationship +from attrs import define +from attrs import field -@attr.s -class ReportingDescriptor(object): +@define() +class ReportingDescriptor: """Metadata that describes a specific report produced by the tool, as part of the analysis it provides or its runtime reporting.""" - id = attr.ib(metadata={"schema_property_name": "id"}) - default_configuration = attr.ib(default=None, metadata={"schema_property_name": "defaultConfiguration"}) - deprecated_guids = attr.ib(default=None, metadata={"schema_property_name": "deprecatedGuids"}) - deprecated_ids = attr.ib(default=None, metadata={"schema_property_name": "deprecatedIds"}) - deprecated_names = attr.ib(default=None, metadata={"schema_property_name": "deprecatedNames"}) - full_description = attr.ib(default=None, metadata={"schema_property_name": "fullDescription"}) - guid = attr.ib(default=None, metadata={"schema_property_name": "guid"}) - help = attr.ib(default=None, metadata={"schema_property_name": "help"}) - help_uri = attr.ib(default=None, metadata={"schema_property_name": "helpUri"}) - message_strings = attr.ib(default=None, metadata={"schema_property_name": "messageStrings"}) - name = attr.ib(default=None, metadata={"schema_property_name": "name"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - relationships = attr.ib(default=None, metadata={"schema_property_name": "relationships"}) - short_description = attr.ib(default=None, metadata={"schema_property_name": "shortDescription"}) + id : str = field(metadata={"schema_property_name": "id"}) + default_configuration : ReportingConfiguration = field(default=None, metadata={"schema_property_name": "defaultConfiguration"}) + deprecated_guids : list[str] = field(factory=list, metadata={"schema_property_name": "deprecatedGuids"}) + deprecated_ids : list[str] = field(factory=list, metadata={"schema_property_name": "deprecatedIds"}) + deprecated_names : list[str] = field(factory=list, metadata={"schema_property_name": "deprecatedNames"}) + full_description : MultiformatMessageString = field(default=None, metadata={"schema_property_name": "fullDescription"}) + guid : str = field(default=None, metadata={"schema_property_name": "guid"}) + help : MultiformatMessageString = field(default=None, metadata={"schema_property_name": "help"}) + help_uri : str = field(default=None, metadata={"schema_property_name": "helpUri"}) + message_strings : dict[str, MultiformatMessageString] = field(default=None, metadata={"schema_property_name": "messageStrings"}) + name : str = field(default=None, metadata={"schema_property_name": "name"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + relationships : list[ReportingDescriptorRelationship] = field(factory=list, metadata={"schema_property_name": "relationships"}) + short_description : MultiformatMessageString = field(default=None, metadata={"schema_property_name": "shortDescription"}) diff --git a/sarif_om/_reporting_descriptor_reference.py b/sarif_om/_reporting_descriptor_reference.py index 5a4fc70..f8cb962 100644 --- a/sarif_om/_reporting_descriptor_reference.py +++ b/sarif_om/_reporting_descriptor_reference.py @@ -1,14 +1,17 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._property_bag import PropertyBag +from ._tool_component_reference import ToolComponentReference +from attrs import define +from attrs import field -@attr.s -class ReportingDescriptorReference(object): +@define() +class ReportingDescriptorReference: """Information about how to locate a relevant reporting descriptor.""" - guid = attr.ib(default=None, metadata={"schema_property_name": "guid"}) - id = attr.ib(default=None, metadata={"schema_property_name": "id"}) - index = attr.ib(default=-1, metadata={"schema_property_name": "index"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - tool_component = attr.ib(default=None, metadata={"schema_property_name": "toolComponent"}) + guid : str = field(default=None, metadata={"schema_property_name": "guid"}) + id : str = field(default=None, metadata={"schema_property_name": "id"}) + index : int = field(default=-1, metadata={"schema_property_name": "index"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + tool_component : ToolComponentReference = field(default=None, metadata={"schema_property_name": "toolComponent"}) diff --git a/sarif_om/_reporting_descriptor_relationship.py b/sarif_om/_reporting_descriptor_relationship.py index 03b0627..5ca59aa 100644 --- a/sarif_om/_reporting_descriptor_relationship.py +++ b/sarif_om/_reporting_descriptor_relationship.py @@ -1,13 +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 ._reporting_descriptor_reference import ReportingDescriptorReference +from attrs import define +from attrs import field -@attr.s -class ReportingDescriptorRelationship(object): +@define() +class ReportingDescriptorRelationship: """Information about the relation of one reporting descriptor to another.""" - target = attr.ib(metadata={"schema_property_name": "target"}) - description = attr.ib(default=None, metadata={"schema_property_name": "description"}) - kinds = attr.ib(default=attr.Factory(lambda: ['relevant']), metadata={"schema_property_name": "kinds"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) + target : ReportingDescriptorReference = field(metadata={"schema_property_name": "target"}) + description : Message = field(default=None, metadata={"schema_property_name": "description"}) + kinds : list[str] = field(factory=lambda: ['relevant'], metadata={"schema_property_name": "kinds"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) diff --git a/sarif_om/_result.py b/sarif_om/_result.py index 66fb865..5119642 100644 --- a/sarif_om/_result.py +++ b/sarif_om/_result.py @@ -1,39 +1,55 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._artifact_location import ArtifactLocation +from ._attachment import Attachment +from ._code_flow import CodeFlow +from ._fix import Fix +from ._graph import Graph +from ._graph_traversal import GraphTraversal +from ._location import Location +from ._message import Message +from ._property_bag import PropertyBag +from ._reporting_descriptor_reference import ReportingDescriptorReference +from ._result_provenance import ResultProvenance +from ._stack import Stack +from ._suppression import Suppression +from ._web_request import WebRequest +from ._web_response import WebResponse +from attrs import define +from attrs import field -@attr.s -class Result(object): +@define() +class Result: """A result produced by an analysis tool.""" - message = attr.ib(metadata={"schema_property_name": "message"}) - analysis_target = attr.ib(default=None, metadata={"schema_property_name": "analysisTarget"}) - attachments = attr.ib(default=None, metadata={"schema_property_name": "attachments"}) - baseline_state = attr.ib(default=None, metadata={"schema_property_name": "baselineState"}) - code_flows = attr.ib(default=None, metadata={"schema_property_name": "codeFlows"}) - correlation_guid = attr.ib(default=None, metadata={"schema_property_name": "correlationGuid"}) - fingerprints = attr.ib(default=None, metadata={"schema_property_name": "fingerprints"}) - fixes = attr.ib(default=None, metadata={"schema_property_name": "fixes"}) - graph_traversals = attr.ib(default=None, metadata={"schema_property_name": "graphTraversals"}) - graphs = attr.ib(default=None, metadata={"schema_property_name": "graphs"}) - guid = attr.ib(default=None, metadata={"schema_property_name": "guid"}) - hosted_viewer_uri = attr.ib(default=None, metadata={"schema_property_name": "hostedViewerUri"}) - kind = attr.ib(default="fail", metadata={"schema_property_name": "kind"}) - level = attr.ib(default="warning", metadata={"schema_property_name": "level"}) - locations = attr.ib(default=None, metadata={"schema_property_name": "locations"}) - occurrence_count = attr.ib(default=None, metadata={"schema_property_name": "occurrenceCount"}) - partial_fingerprints = attr.ib(default=None, metadata={"schema_property_name": "partialFingerprints"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - provenance = attr.ib(default=None, metadata={"schema_property_name": "provenance"}) - rank = attr.ib(default=-1.0, metadata={"schema_property_name": "rank"}) - related_locations = attr.ib(default=None, metadata={"schema_property_name": "relatedLocations"}) - rule = attr.ib(default=None, metadata={"schema_property_name": "rule"}) - rule_id = attr.ib(default=None, metadata={"schema_property_name": "ruleId"}) - rule_index = attr.ib(default=-1, metadata={"schema_property_name": "ruleIndex"}) - stacks = attr.ib(default=None, metadata={"schema_property_name": "stacks"}) - suppressions = attr.ib(default=None, metadata={"schema_property_name": "suppressions"}) - taxa = attr.ib(default=None, metadata={"schema_property_name": "taxa"}) - web_request = attr.ib(default=None, metadata={"schema_property_name": "webRequest"}) - web_response = attr.ib(default=None, metadata={"schema_property_name": "webResponse"}) - work_item_uris = attr.ib(default=None, metadata={"schema_property_name": "workItemUris"}) + message : Message = field(metadata={"schema_property_name": "message"}) + analysis_target : ArtifactLocation = field(default=None, metadata={"schema_property_name": "analysisTarget"}) + attachments : list[Attachment] = field(factory=list, metadata={"schema_property_name": "attachments"}) + baseline_state : str = field(default=None, metadata={"schema_property_name": "baselineState"}) + code_flows : list[CodeFlow] = field(factory=list, metadata={"schema_property_name": "codeFlows"}) + correlation_guid : str = field(default=None, metadata={"schema_property_name": "correlationGuid"}) + fingerprints : dict[str, str] = field(default=None, metadata={"schema_property_name": "fingerprints"}) + fixes : list[Fix] = field(factory=list, metadata={"schema_property_name": "fixes"}) + graph_traversals : list[GraphTraversal] = field(factory=list, metadata={"schema_property_name": "graphTraversals"}) + graphs : list[Graph] = field(factory=list, metadata={"schema_property_name": "graphs"}) + guid : str = field(default=None, metadata={"schema_property_name": "guid"}) + hosted_viewer_uri : str = field(default=None, metadata={"schema_property_name": "hostedViewerUri"}) + kind : str = field(default="fail", metadata={"schema_property_name": "kind"}) + level : str = field(default="warning", metadata={"schema_property_name": "level"}) + locations : list[Location] = field(factory=list, metadata={"schema_property_name": "locations"}) + occurrence_count : int = field(default=None, metadata={"schema_property_name": "occurrenceCount"}) + partial_fingerprints : dict[str, str] = field(default=None, metadata={"schema_property_name": "partialFingerprints"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + provenance : ResultProvenance = field(default=None, metadata={"schema_property_name": "provenance"}) + rank : float = field(default=-1.0, metadata={"schema_property_name": "rank"}) + related_locations : list[Location] = field(factory=list, metadata={"schema_property_name": "relatedLocations"}) + rule : ReportingDescriptorReference = field(default=None, metadata={"schema_property_name": "rule"}) + rule_id : str = field(default=None, metadata={"schema_property_name": "ruleId"}) + rule_index : int = field(default=-1, metadata={"schema_property_name": "ruleIndex"}) + stacks : list[Stack] = field(factory=list, metadata={"schema_property_name": "stacks"}) + suppressions : list[Suppression] = field(factory=list, metadata={"schema_property_name": "suppressions"}) + taxa : list[ReportingDescriptorReference] = field(factory=list, metadata={"schema_property_name": "taxa"}) + web_request : WebRequest = field(default=None, metadata={"schema_property_name": "webRequest"}) + web_response : WebResponse = field(default=None, metadata={"schema_property_name": "webResponse"}) + work_item_uris : list[str] = field(factory=list, metadata={"schema_property_name": "workItemUris"}) diff --git a/sarif_om/_result_provenance.py b/sarif_om/_result_provenance.py index 8a8ac0d..5e724ef 100644 --- a/sarif_om/_result_provenance.py +++ b/sarif_om/_result_provenance.py @@ -1,16 +1,19 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._physical_location import PhysicalLocation +from ._property_bag import PropertyBag +from attrs import define +from attrs import field -@attr.s -class ResultProvenance(object): +@define() +class ResultProvenance: """Contains information about how and when a result was detected.""" - conversion_sources = attr.ib(default=None, metadata={"schema_property_name": "conversionSources"}) - first_detection_run_guid = attr.ib(default=None, metadata={"schema_property_name": "firstDetectionRunGuid"}) - first_detection_time_utc = attr.ib(default=None, metadata={"schema_property_name": "firstDetectionTimeUtc"}) - invocation_index = attr.ib(default=-1, metadata={"schema_property_name": "invocationIndex"}) - last_detection_run_guid = attr.ib(default=None, metadata={"schema_property_name": "lastDetectionRunGuid"}) - last_detection_time_utc = attr.ib(default=None, metadata={"schema_property_name": "lastDetectionTimeUtc"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) + conversion_sources : list[PhysicalLocation] = field(factory=list, metadata={"schema_property_name": "conversionSources"}) + first_detection_run_guid : str = field(default=None, metadata={"schema_property_name": "firstDetectionRunGuid"}) + first_detection_time_utc : str = field(default=None, metadata={"schema_property_name": "firstDetectionTimeUtc"}) + invocation_index : int = field(default=-1, metadata={"schema_property_name": "invocationIndex"}) + last_detection_run_guid : str = field(default=None, metadata={"schema_property_name": "lastDetectionRunGuid"}) + last_detection_time_utc : str = field(default=None, metadata={"schema_property_name": "lastDetectionTimeUtc"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) diff --git a/sarif_om/_run.py b/sarif_om/_run.py index 8b33012..c6a85a8 100644 --- a/sarif_om/_run.py +++ b/sarif_om/_run.py @@ -1,37 +1,56 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._address import Address +from ._artifact import Artifact +from ._artifact_location import ArtifactLocation +from ._conversion import Conversion +from ._external_property_file_references import ExternalPropertyFileReferences +from ._graph import Graph +from ._invocation import Invocation +from ._logical_location import LogicalLocation +from ._property_bag import PropertyBag +from ._result import Result +from ._run_automation_details import RunAutomationDetails +from ._special_locations import SpecialLocations +from ._thread_flow_location import ThreadFlowLocation +from ._tool import Tool +from ._tool_component import ToolComponent +from ._version_control_details import VersionControlDetails +from ._web_request import WebRequest +from ._web_response import WebResponse +from attrs import define +from attrs import field -@attr.s -class Run(object): +@define() +class Run: """Describes a single run of an analysis tool, and contains the reported output of that run.""" - tool = attr.ib(metadata={"schema_property_name": "tool"}) - addresses = attr.ib(default=None, metadata={"schema_property_name": "addresses"}) - artifacts = attr.ib(default=None, metadata={"schema_property_name": "artifacts"}) - automation_details = attr.ib(default=None, metadata={"schema_property_name": "automationDetails"}) - baseline_guid = attr.ib(default=None, metadata={"schema_property_name": "baselineGuid"}) - column_kind = attr.ib(default=None, metadata={"schema_property_name": "columnKind"}) - conversion = attr.ib(default=None, metadata={"schema_property_name": "conversion"}) - default_encoding = attr.ib(default=None, metadata={"schema_property_name": "defaultEncoding"}) - default_source_language = attr.ib(default=None, metadata={"schema_property_name": "defaultSourceLanguage"}) - external_property_file_references = attr.ib(default=None, metadata={"schema_property_name": "externalPropertyFileReferences"}) - graphs = attr.ib(default=None, metadata={"schema_property_name": "graphs"}) - invocations = attr.ib(default=None, metadata={"schema_property_name": "invocations"}) - language = attr.ib(default="en-US", metadata={"schema_property_name": "language"}) - logical_locations = attr.ib(default=None, metadata={"schema_property_name": "logicalLocations"}) - newline_sequences = attr.ib(default=attr.Factory(lambda: ['\r\n', '\n']), metadata={"schema_property_name": "newlineSequences"}) - original_uri_base_ids = attr.ib(default=None, metadata={"schema_property_name": "originalUriBaseIds"}) - policies = attr.ib(default=None, metadata={"schema_property_name": "policies"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - redaction_tokens = attr.ib(default=None, metadata={"schema_property_name": "redactionTokens"}) - results = attr.ib(default=None, metadata={"schema_property_name": "results"}) - run_aggregates = attr.ib(default=None, metadata={"schema_property_name": "runAggregates"}) - special_locations = attr.ib(default=None, metadata={"schema_property_name": "specialLocations"}) - taxonomies = attr.ib(default=None, metadata={"schema_property_name": "taxonomies"}) - thread_flow_locations = attr.ib(default=None, metadata={"schema_property_name": "threadFlowLocations"}) - translations = attr.ib(default=None, metadata={"schema_property_name": "translations"}) - version_control_provenance = attr.ib(default=None, metadata={"schema_property_name": "versionControlProvenance"}) - web_requests = attr.ib(default=None, metadata={"schema_property_name": "webRequests"}) - web_responses = attr.ib(default=None, metadata={"schema_property_name": "webResponses"}) + tool : Tool = field(metadata={"schema_property_name": "tool"}) + addresses : list[Address] = field(factory=list, metadata={"schema_property_name": "addresses"}) + artifacts : list[Artifact] = field(factory=list, metadata={"schema_property_name": "artifacts"}) + automation_details : RunAutomationDetails = field(default=None, metadata={"schema_property_name": "automationDetails"}) + baseline_guid : str = field(default=None, metadata={"schema_property_name": "baselineGuid"}) + column_kind : str = field(default=None, metadata={"schema_property_name": "columnKind"}) + conversion : Conversion = field(default=None, metadata={"schema_property_name": "conversion"}) + default_encoding : str = field(default=None, metadata={"schema_property_name": "defaultEncoding"}) + default_source_language : str = field(default=None, metadata={"schema_property_name": "defaultSourceLanguage"}) + external_property_file_references : ExternalPropertyFileReferences = field(default=None, metadata={"schema_property_name": "externalPropertyFileReferences"}) + graphs : list[Graph] = field(factory=list, metadata={"schema_property_name": "graphs"}) + invocations : list[Invocation] = field(factory=list, metadata={"schema_property_name": "invocations"}) + language : str = field(default="en-US", metadata={"schema_property_name": "language"}) + logical_locations : list[LogicalLocation] = field(factory=list, metadata={"schema_property_name": "logicalLocations"}) + newline_sequences : list[str] = field(factory=lambda: ['\r\n', '\n'], metadata={"schema_property_name": "newlineSequences"}) + original_uri_base_ids : dict[str, ArtifactLocation] = field(default=None, metadata={"schema_property_name": "originalUriBaseIds"}) + policies : list[ToolComponent] = field(factory=list, metadata={"schema_property_name": "policies"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + redaction_tokens : list[str] = field(factory=list, metadata={"schema_property_name": "redactionTokens"}) + results : list[Result] = field(factory=list, metadata={"schema_property_name": "results"}) + run_aggregates : list[RunAutomationDetails] = field(factory=list, metadata={"schema_property_name": "runAggregates"}) + special_locations : SpecialLocations = field(default=None, metadata={"schema_property_name": "specialLocations"}) + taxonomies : list[ToolComponent] = field(factory=list, metadata={"schema_property_name": "taxonomies"}) + thread_flow_locations : list[ThreadFlowLocation] = field(factory=list, metadata={"schema_property_name": "threadFlowLocations"}) + translations : list[ToolComponent] = field(factory=list, metadata={"schema_property_name": "translations"}) + version_control_provenance : list[VersionControlDetails] = field(factory=list, metadata={"schema_property_name": "versionControlProvenance"}) + web_requests : list[WebRequest] = field(factory=list, metadata={"schema_property_name": "webRequests"}) + web_responses : list[WebResponse] = field(factory=list, metadata={"schema_property_name": "webResponses"}) diff --git a/sarif_om/_run_automation_details.py b/sarif_om/_run_automation_details.py index ea7dd7e..1670038 100644 --- a/sarif_om/_run_automation_details.py +++ b/sarif_om/_run_automation_details.py @@ -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 RunAutomationDetails(object): +@define() +class RunAutomationDetails: """Information that describes a run's identity and role within an engineering system process.""" - correlation_guid = attr.ib(default=None, metadata={"schema_property_name": "correlationGuid"}) - description = attr.ib(default=None, metadata={"schema_property_name": "description"}) - guid = attr.ib(default=None, metadata={"schema_property_name": "guid"}) - id = attr.ib(default=None, metadata={"schema_property_name": "id"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) + correlation_guid : str = field(default=None, metadata={"schema_property_name": "correlationGuid"}) + description : Message = field(default=None, metadata={"schema_property_name": "description"}) + guid : str = field(default=None, metadata={"schema_property_name": "guid"}) + id : str = field(default=None, metadata={"schema_property_name": "id"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) diff --git a/sarif_om/_sarif_log.py b/sarif_om/_sarif_log.py index c4468d3..ef5def4 100644 --- a/sarif_om/_sarif_log.py +++ b/sarif_om/_sarif_log.py @@ -1,14 +1,18 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._external_properties import ExternalProperties +from ._property_bag import PropertyBag +from ._run import Run +from attrs import define +from attrs import field -@attr.s -class SarifLog(object): +@define() +class SarifLog: """Static Analysis Results Format (SARIF) Version 2.1.0 JSON Schema: a standard format for the output of static analysis tools.""" - runs = attr.ib(metadata={"schema_property_name": "runs"}) - version = attr.ib(metadata={"schema_property_name": "version"}) - schema_uri = attr.ib(default=None, metadata={"schema_property_name": "$schema"}) - inline_external_properties = attr.ib(default=None, metadata={"schema_property_name": "inlineExternalProperties"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) + runs : list[Run] = field(metadata={"schema_property_name": "runs"}) + version : str = field(metadata={"schema_property_name": "version"}) + schema_uri : str = field(default=None, metadata={"schema_property_name": "$schema"}) + inline_external_properties : list[ExternalProperties] = field(factory=list, metadata={"schema_property_name": "inlineExternalProperties"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) diff --git a/sarif_om/_special_locations.py b/sarif_om/_special_locations.py index b887291..3841bd0 100644 --- a/sarif_om/_special_locations.py +++ b/sarif_om/_special_locations.py @@ -1,11 +1,14 @@ # 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 attrs import define +from attrs import field -@attr.s -class SpecialLocations(object): +@define() +class SpecialLocations: """Defines locations of special significance to SARIF consumers.""" - display_base = attr.ib(default=None, metadata={"schema_property_name": "displayBase"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) + display_base : ArtifactLocation = field(default=None, metadata={"schema_property_name": "displayBase"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) diff --git a/sarif_om/_stack.py b/sarif_om/_stack.py index 620a309..048b76c 100644 --- a/sarif_om/_stack.py +++ b/sarif_om/_stack.py @@ -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 ._stack_frame import StackFrame +from attrs import define +from attrs import field -@attr.s -class Stack(object): +@define() +class Stack: """A call stack that is relevant to a result.""" - frames = attr.ib(metadata={"schema_property_name": "frames"}) - message = attr.ib(default=None, metadata={"schema_property_name": "message"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) + frames : list[StackFrame] = field(metadata={"schema_property_name": "frames"}) + message : Message = field(default=None, metadata={"schema_property_name": "message"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) diff --git a/sarif_om/_stack_frame.py b/sarif_om/_stack_frame.py index 78b3153..d53d096 100644 --- a/sarif_om/_stack_frame.py +++ b/sarif_om/_stack_frame.py @@ -1,14 +1,17 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._location import Location +from ._property_bag import PropertyBag +from attrs import define +from attrs import field -@attr.s -class StackFrame(object): +@define() +class StackFrame: """A function call within a stack trace.""" - location = attr.ib(default=None, metadata={"schema_property_name": "location"}) - module = attr.ib(default=None, metadata={"schema_property_name": "module"}) - parameters = attr.ib(default=None, metadata={"schema_property_name": "parameters"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - thread_id = attr.ib(default=None, metadata={"schema_property_name": "threadId"}) + location : Location = field(default=None, metadata={"schema_property_name": "location"}) + module : str = field(default=None, metadata={"schema_property_name": "module"}) + parameters : list[str] = field(factory=list, metadata={"schema_property_name": "parameters"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + thread_id : int = field(default=None, metadata={"schema_property_name": "threadId"}) diff --git a/sarif_om/_suppression.py b/sarif_om/_suppression.py index 7c781fe..b67faa0 100644 --- a/sarif_om/_suppression.py +++ b/sarif_om/_suppression.py @@ -1,15 +1,18 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._location import Location +from ._property_bag import PropertyBag +from attrs import define +from attrs import field -@attr.s -class Suppression(object): +@define() +class Suppression: """A suppression that is relevant to a result.""" - kind = attr.ib(metadata={"schema_property_name": "kind"}) - guid = attr.ib(default=None, metadata={"schema_property_name": "guid"}) - justification = attr.ib(default=None, metadata={"schema_property_name": "justification"}) - location = attr.ib(default=None, metadata={"schema_property_name": "location"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - state = attr.ib(default=None, metadata={"schema_property_name": "state"}) + kind : str = field(metadata={"schema_property_name": "kind"}) + guid : str = field(default=None, metadata={"schema_property_name": "guid"}) + justification : str = field(default=None, metadata={"schema_property_name": "justification"}) + location : Location = field(default=None, metadata={"schema_property_name": "location"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + state : str = field(default=None, metadata={"schema_property_name": "state"}) diff --git a/sarif_om/_thread_flow.py b/sarif_om/_thread_flow.py index 0c3453a..30d4347 100644 --- a/sarif_om/_thread_flow.py +++ b/sarif_om/_thread_flow.py @@ -1,15 +1,20 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._message import Message +from ._multiformat_message_string import MultiformatMessageString +from ._property_bag import PropertyBag +from ._thread_flow_location import ThreadFlowLocation +from attrs import define +from attrs import field -@attr.s -class ThreadFlow(object): +@define() +class ThreadFlow: """Describes a sequence of code locations that specify a path through a single thread of execution such as an operating system or fiber.""" - locations = attr.ib(metadata={"schema_property_name": "locations"}) - id = attr.ib(default=None, metadata={"schema_property_name": "id"}) - immutable_state = attr.ib(default=None, metadata={"schema_property_name": "immutableState"}) - initial_state = attr.ib(default=None, metadata={"schema_property_name": "initialState"}) - message = attr.ib(default=None, metadata={"schema_property_name": "message"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) + locations : list[ThreadFlowLocation] = field(metadata={"schema_property_name": "locations"}) + id : str = field(default=None, metadata={"schema_property_name": "id"}) + immutable_state : dict[str, MultiformatMessageString] = field(default=None, metadata={"schema_property_name": "immutableState"}) + initial_state : dict[str, MultiformatMessageString] = field(default=None, metadata={"schema_property_name": "initialState"}) + message : Message = field(default=None, metadata={"schema_property_name": "message"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) diff --git a/sarif_om/_thread_flow_location.py b/sarif_om/_thread_flow_location.py index 7c51896..28941cd 100644 --- a/sarif_om/_thread_flow_location.py +++ b/sarif_om/_thread_flow_location.py @@ -1,23 +1,31 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._location import Location +from ._multiformat_message_string import MultiformatMessageString +from ._property_bag import PropertyBag +from ._reporting_descriptor_reference import ReportingDescriptorReference +from ._stack import Stack +from ._web_request import WebRequest +from ._web_response import WebResponse +from attrs import define +from attrs import field -@attr.s -class ThreadFlowLocation(object): +@define() +class ThreadFlowLocation: """A location visited by an analysis tool while simulating or monitoring the execution of a program.""" - execution_order = attr.ib(default=-1, metadata={"schema_property_name": "executionOrder"}) - execution_time_utc = attr.ib(default=None, metadata={"schema_property_name": "executionTimeUtc"}) - importance = attr.ib(default="important", metadata={"schema_property_name": "importance"}) - index = attr.ib(default=-1, metadata={"schema_property_name": "index"}) - kinds = attr.ib(default=None, metadata={"schema_property_name": "kinds"}) - location = attr.ib(default=None, metadata={"schema_property_name": "location"}) - module = attr.ib(default=None, metadata={"schema_property_name": "module"}) - nesting_level = attr.ib(default=None, metadata={"schema_property_name": "nestingLevel"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - stack = attr.ib(default=None, metadata={"schema_property_name": "stack"}) - state = attr.ib(default=None, metadata={"schema_property_name": "state"}) - taxa = attr.ib(default=None, metadata={"schema_property_name": "taxa"}) - web_request = attr.ib(default=None, metadata={"schema_property_name": "webRequest"}) - web_response = attr.ib(default=None, metadata={"schema_property_name": "webResponse"}) + execution_order : int = field(default=-1, metadata={"schema_property_name": "executionOrder"}) + execution_time_utc : str = field(default=None, metadata={"schema_property_name": "executionTimeUtc"}) + importance : str = field(default="important", metadata={"schema_property_name": "importance"}) + index : int = field(default=-1, metadata={"schema_property_name": "index"}) + kinds : list[str] = field(factory=list, metadata={"schema_property_name": "kinds"}) + location : Location = field(default=None, metadata={"schema_property_name": "location"}) + module : str = field(default=None, metadata={"schema_property_name": "module"}) + nesting_level : int = field(default=None, metadata={"schema_property_name": "nestingLevel"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + stack : Stack = field(default=None, metadata={"schema_property_name": "stack"}) + state : dict[str, MultiformatMessageString] = field(default=None, metadata={"schema_property_name": "state"}) + taxa : list[ReportingDescriptorReference] = field(factory=list, metadata={"schema_property_name": "taxa"}) + web_request : WebRequest = field(default=None, metadata={"schema_property_name": "webRequest"}) + web_response : WebResponse = field(default=None, metadata={"schema_property_name": "webResponse"}) diff --git a/sarif_om/_tool.py b/sarif_om/_tool.py index ae4d727..570425a 100644 --- a/sarif_om/_tool.py +++ b/sarif_om/_tool.py @@ -1,12 +1,15 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._property_bag import PropertyBag +from ._tool_component import ToolComponent +from attrs import define +from attrs import field -@attr.s -class Tool(object): +@define() +class Tool: """The analysis tool that was run.""" - driver = attr.ib(metadata={"schema_property_name": "driver"}) - extensions = attr.ib(default=None, metadata={"schema_property_name": "extensions"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) + driver : ToolComponent = field(metadata={"schema_property_name": "driver"}) + extensions : list[ToolComponent] = field(factory=list, metadata={"schema_property_name": "extensions"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) diff --git a/sarif_om/_tool_component.py b/sarif_om/_tool_component.py index fac2c14..647b45b 100644 --- a/sarif_om/_tool_component.py +++ b/sarif_om/_tool_component.py @@ -1,37 +1,44 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._artifact_location import ArtifactLocation +from ._multiformat_message_string import MultiformatMessageString +from ._property_bag import PropertyBag +from ._reporting_descriptor import ReportingDescriptor +from ._tool_component_reference import ToolComponentReference +from ._translation_metadata import TranslationMetadata +from attrs import define +from attrs import field -@attr.s -class ToolComponent(object): +@define() +class ToolComponent: """A component, such as a plug-in or the driver, of the analysis tool that was run.""" - name = attr.ib(metadata={"schema_property_name": "name"}) - associated_component = attr.ib(default=None, metadata={"schema_property_name": "associatedComponent"}) - contents = attr.ib(default=attr.Factory(lambda: ['localizedData', 'nonLocalizedData']), metadata={"schema_property_name": "contents"}) - dotted_quad_file_version = attr.ib(default=None, metadata={"schema_property_name": "dottedQuadFileVersion"}) - download_uri = attr.ib(default=None, metadata={"schema_property_name": "downloadUri"}) - full_description = attr.ib(default=None, metadata={"schema_property_name": "fullDescription"}) - full_name = attr.ib(default=None, metadata={"schema_property_name": "fullName"}) - global_message_strings = attr.ib(default=None, metadata={"schema_property_name": "globalMessageStrings"}) - guid = attr.ib(default=None, metadata={"schema_property_name": "guid"}) - information_uri = attr.ib(default=None, metadata={"schema_property_name": "informationUri"}) - is_comprehensive = attr.ib(default=None, metadata={"schema_property_name": "isComprehensive"}) - language = attr.ib(default="en-US", metadata={"schema_property_name": "language"}) - localized_data_semantic_version = attr.ib(default=None, metadata={"schema_property_name": "localizedDataSemanticVersion"}) - locations = attr.ib(default=None, metadata={"schema_property_name": "locations"}) - minimum_required_localized_data_semantic_version = attr.ib(default=None, metadata={"schema_property_name": "minimumRequiredLocalizedDataSemanticVersion"}) - notifications = attr.ib(default=None, metadata={"schema_property_name": "notifications"}) - organization = attr.ib(default=None, metadata={"schema_property_name": "organization"}) - product = attr.ib(default=None, metadata={"schema_property_name": "product"}) - product_suite = attr.ib(default=None, metadata={"schema_property_name": "productSuite"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - release_date_utc = attr.ib(default=None, metadata={"schema_property_name": "releaseDateUtc"}) - rules = attr.ib(default=None, metadata={"schema_property_name": "rules"}) - semantic_version = attr.ib(default=None, metadata={"schema_property_name": "semanticVersion"}) - short_description = attr.ib(default=None, metadata={"schema_property_name": "shortDescription"}) - supported_taxonomies = attr.ib(default=None, metadata={"schema_property_name": "supportedTaxonomies"}) - taxa = attr.ib(default=None, metadata={"schema_property_name": "taxa"}) - translation_metadata = attr.ib(default=None, metadata={"schema_property_name": "translationMetadata"}) - version = attr.ib(default=None, metadata={"schema_property_name": "version"}) + name : str = field(metadata={"schema_property_name": "name"}) + associated_component : ToolComponentReference = field(default=None, metadata={"schema_property_name": "associatedComponent"}) + contents : list[str] = field(factory=lambda: ['localizedData', 'nonLocalizedData'], metadata={"schema_property_name": "contents"}) + dotted_quad_file_version : str = field(default=None, metadata={"schema_property_name": "dottedQuadFileVersion"}) + download_uri : str = field(default=None, metadata={"schema_property_name": "downloadUri"}) + full_description : MultiformatMessageString = field(default=None, metadata={"schema_property_name": "fullDescription"}) + full_name : str = field(default=None, metadata={"schema_property_name": "fullName"}) + global_message_strings : dict[str, MultiformatMessageString] = field(default=None, metadata={"schema_property_name": "globalMessageStrings"}) + guid : str = field(default=None, metadata={"schema_property_name": "guid"}) + information_uri : str = field(default=None, metadata={"schema_property_name": "informationUri"}) + is_comprehensive : bool = field(default=False, metadata={"schema_property_name": "isComprehensive"}) + language : str = field(default="en-US", metadata={"schema_property_name": "language"}) + localized_data_semantic_version : str = field(default=None, metadata={"schema_property_name": "localizedDataSemanticVersion"}) + locations : list[ArtifactLocation] = field(factory=list, metadata={"schema_property_name": "locations"}) + minimum_required_localized_data_semantic_version : str = field(default=None, metadata={"schema_property_name": "minimumRequiredLocalizedDataSemanticVersion"}) + notifications : list[ReportingDescriptor] = field(factory=list, metadata={"schema_property_name": "notifications"}) + organization : str = field(default=None, metadata={"schema_property_name": "organization"}) + product : str = field(default=None, metadata={"schema_property_name": "product"}) + product_suite : str = field(default=None, metadata={"schema_property_name": "productSuite"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + release_date_utc : str = field(default=None, metadata={"schema_property_name": "releaseDateUtc"}) + rules : list[ReportingDescriptor] = field(factory=list, metadata={"schema_property_name": "rules"}) + semantic_version : str = field(default=None, metadata={"schema_property_name": "semanticVersion"}) + short_description : MultiformatMessageString = field(default=None, metadata={"schema_property_name": "shortDescription"}) + supported_taxonomies : list[ToolComponentReference] = field(factory=list, metadata={"schema_property_name": "supportedTaxonomies"}) + taxa : list[ReportingDescriptor] = field(factory=list, metadata={"schema_property_name": "taxa"}) + translation_metadata : TranslationMetadata = field(default=None, metadata={"schema_property_name": "translationMetadata"}) + version : str = field(default=None, metadata={"schema_property_name": "version"}) diff --git a/sarif_om/_tool_component_reference.py b/sarif_om/_tool_component_reference.py index 0f6fc82..65d9e73 100644 --- a/sarif_om/_tool_component_reference.py +++ b/sarif_om/_tool_component_reference.py @@ -1,13 +1,15 @@ # 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 ToolComponentReference(object): +@define() +class ToolComponentReference: """Identifies a particular toolComponent object, either the driver or an extension.""" - guid = attr.ib(default=None, metadata={"schema_property_name": "guid"}) - index = attr.ib(default=-1, metadata={"schema_property_name": "index"}) - name = attr.ib(default=None, metadata={"schema_property_name": "name"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) + guid : str = field(default=None, metadata={"schema_property_name": "guid"}) + index : int = field(default=-1, metadata={"schema_property_name": "index"}) + name : str = field(default=None, metadata={"schema_property_name": "name"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) diff --git a/sarif_om/_translation_metadata.py b/sarif_om/_translation_metadata.py index fac33fc..0bb0990 100644 --- a/sarif_om/_translation_metadata.py +++ b/sarif_om/_translation_metadata.py @@ -1,16 +1,19 @@ # 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 TranslationMetadata(object): +@define() +class TranslationMetadata: """Provides additional metadata related to translation.""" - name = attr.ib(metadata={"schema_property_name": "name"}) - download_uri = attr.ib(default=None, metadata={"schema_property_name": "downloadUri"}) - full_description = attr.ib(default=None, metadata={"schema_property_name": "fullDescription"}) - full_name = attr.ib(default=None, metadata={"schema_property_name": "fullName"}) - information_uri = attr.ib(default=None, metadata={"schema_property_name": "informationUri"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - short_description = attr.ib(default=None, metadata={"schema_property_name": "shortDescription"}) + name : str = field(metadata={"schema_property_name": "name"}) + download_uri : str = field(default=None, metadata={"schema_property_name": "downloadUri"}) + full_description : MultiformatMessageString = field(default=None, metadata={"schema_property_name": "fullDescription"}) + full_name : str = field(default=None, metadata={"schema_property_name": "fullName"}) + information_uri : str = field(default=None, metadata={"schema_property_name": "informationUri"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + short_description : MultiformatMessageString = field(default=None, metadata={"schema_property_name": "shortDescription"}) diff --git a/sarif_om/_version_control_details.py b/sarif_om/_version_control_details.py index 53eebee..e80af65 100644 --- a/sarif_om/_version_control_details.py +++ b/sarif_om/_version_control_details.py @@ -1,16 +1,19 @@ # 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 attrs import define +from attrs import field -@attr.s -class VersionControlDetails(object): +@define() +class VersionControlDetails: """Specifies the information necessary to retrieve a desired revision from a version control system.""" - repository_uri = attr.ib(metadata={"schema_property_name": "repositoryUri"}) - as_of_time_utc = attr.ib(default=None, metadata={"schema_property_name": "asOfTimeUtc"}) - branch = attr.ib(default=None, metadata={"schema_property_name": "branch"}) - mapped_to = attr.ib(default=None, metadata={"schema_property_name": "mappedTo"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - revision_id = attr.ib(default=None, metadata={"schema_property_name": "revisionId"}) - revision_tag = attr.ib(default=None, metadata={"schema_property_name": "revisionTag"}) + repository_uri : str = field(metadata={"schema_property_name": "repositoryUri"}) + as_of_time_utc : str = field(default=None, metadata={"schema_property_name": "asOfTimeUtc"}) + branch : str = field(default=None, metadata={"schema_property_name": "branch"}) + mapped_to : ArtifactLocation = field(default=None, metadata={"schema_property_name": "mappedTo"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + revision_id : str = field(default=None, metadata={"schema_property_name": "revisionId"}) + revision_tag : str = field(default=None, metadata={"schema_property_name": "revisionTag"}) diff --git a/sarif_om/_web_request.py b/sarif_om/_web_request.py index 78403ca..e0f971e 100644 --- a/sarif_om/_web_request.py +++ b/sarif_om/_web_request.py @@ -1,18 +1,21 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._artifact_content import ArtifactContent +from ._property_bag import PropertyBag +from attrs import define +from attrs import field -@attr.s -class WebRequest(object): +@define() +class WebRequest: """Describes an HTTP request.""" - body = attr.ib(default=None, metadata={"schema_property_name": "body"}) - headers = attr.ib(default=None, metadata={"schema_property_name": "headers"}) - index = attr.ib(default=-1, metadata={"schema_property_name": "index"}) - method = attr.ib(default=None, metadata={"schema_property_name": "method"}) - parameters = attr.ib(default=None, metadata={"schema_property_name": "parameters"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - protocol = attr.ib(default=None, metadata={"schema_property_name": "protocol"}) - target = attr.ib(default=None, metadata={"schema_property_name": "target"}) - version = attr.ib(default=None, metadata={"schema_property_name": "version"}) + body : ArtifactContent = field(default=None, metadata={"schema_property_name": "body"}) + headers : dict[str, str] = field(default=None, metadata={"schema_property_name": "headers"}) + index : int = field(default=-1, metadata={"schema_property_name": "index"}) + method : str = field(default=None, metadata={"schema_property_name": "method"}) + parameters : dict[str, str] = field(default=None, metadata={"schema_property_name": "parameters"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + protocol : str = field(default=None, metadata={"schema_property_name": "protocol"}) + target : str = field(default=None, metadata={"schema_property_name": "target"}) + version : str = field(default=None, metadata={"schema_property_name": "version"}) diff --git a/sarif_om/_web_response.py b/sarif_om/_web_response.py index 4f5c98c..a9f7e55 100644 --- a/sarif_om/_web_response.py +++ b/sarif_om/_web_response.py @@ -1,18 +1,21 @@ # This file was generated by jschema_to_python version 1.2.3. -import attr +from ._artifact_content import ArtifactContent +from ._property_bag import PropertyBag +from attrs import define +from attrs import field -@attr.s -class WebResponse(object): +@define() +class WebResponse: """Describes the response to an HTTP request.""" - body = attr.ib(default=None, metadata={"schema_property_name": "body"}) - headers = attr.ib(default=None, metadata={"schema_property_name": "headers"}) - index = attr.ib(default=-1, metadata={"schema_property_name": "index"}) - no_response_received = attr.ib(default=None, metadata={"schema_property_name": "noResponseReceived"}) - properties = attr.ib(default=None, metadata={"schema_property_name": "properties"}) - protocol = attr.ib(default=None, metadata={"schema_property_name": "protocol"}) - reason_phrase = attr.ib(default=None, metadata={"schema_property_name": "reasonPhrase"}) - status_code = attr.ib(default=None, metadata={"schema_property_name": "statusCode"}) - version = attr.ib(default=None, metadata={"schema_property_name": "version"}) + body : ArtifactContent = field(default=None, metadata={"schema_property_name": "body"}) + headers : dict[str, str] = field(default=None, metadata={"schema_property_name": "headers"}) + index : int = field(default=-1, metadata={"schema_property_name": "index"}) + no_response_received : bool = field(default=False, metadata={"schema_property_name": "noResponseReceived"}) + properties : PropertyBag = field(default=None, metadata={"schema_property_name": "properties"}) + protocol : str = field(default=None, metadata={"schema_property_name": "protocol"}) + reason_phrase : str = field(default=None, metadata={"schema_property_name": "reasonPhrase"}) + status_code : int = field(default=None, metadata={"schema_property_name": "statusCode"}) + version : str = field(default=None, metadata={"schema_property_name": "version"}) diff --git a/setup.cfg b/setup.cfg index 9338bba..2207515 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,6 +20,7 @@ classifier = python_requires = >= 2.7 install_requires = attrs + cattrs pbr [files] diff --git a/setup.py b/setup.py index 78b91d7..c7ead35 100644 --- a/setup.py +++ b/setup.py @@ -2,4 +2,4 @@ from setuptools import setup -setup(setup_requires=["pbr"], pbr=True) +setup(setup_requires=["pbr"], install_requires=["attrs", "cattrs"], pbr=True)