diff --git a/sarif/CMakeLists.txt b/sarif/CMakeLists.txt index 74f48cd..c6f9fe4 100644 --- a/sarif/CMakeLists.txt +++ b/sarif/CMakeLists.txt @@ -6,5 +6,9 @@ add_headers(sarif GAP_SARIF_HEADERS definitions.hpp ) -add_gap_library(gap-sarif "${GAP_SARIF_HEADERS}") -target_link_libraries(gap-sarif INTERFACE nlohmann_json::nlohmann_json) \ No newline at end of file +add_sources(sarif GAP_SARIF_SOURCES + definitions.cpp +) + +add_gap_static_library(gap-sarif "${GAP_SARIF_HEADERS}" "${GAP_SARIF_SOURCES}") +target_link_libraries(gap-sarif PUBLIC nlohmann_json::nlohmann_json) \ No newline at end of file diff --git a/sarif/include/gap/sarif/definitions.hpp b/sarif/include/gap/sarif/definitions.hpp index eb762dd..a78a2e0 100644 --- a/sarif/include/gap/sarif/definitions.hpp +++ b/sarif/include/gap/sarif/definitions.hpp @@ -3,6 +3,7 @@ #pragma once #include +#include #include #include #include @@ -21,6 +22,21 @@ namespace gap::sarif::definitions struct run_struct; struct external_properties_struct; + // + // Key/value pairs that provide additional information about the object. + // + struct property_bag_struct { + // + // A set of distinct strings that provide additional information. + // + std::optional> tags; + + std::unordered_map additional_properties; + }; + + void to_json(nlohmann::json &, const property_bag_struct &); + void from_json(const nlohmann::json &, property_bag_struct &); + // // Static Analysis Results Format (SARIF) Version 2.1.0 JSON Schema: a standard format for the output of static analysis tools. // @@ -38,12 +54,12 @@ namespace gap::sarif::definitions // // References to external property files that share data between runs. // - std::vector inlineExternalProperties; + std::optional> inlineExternalProperties; // // Key/value pairs that provide additional information about the log file. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const root_struct &); @@ -56,52 +72,52 @@ namespace gap::sarif::definitions // // The address expressed as a byte offset from the start of the addressable region. // - int64_t absoluteAddress; + std::optional absoluteAddress; // // The address expressed as a byte offset from the absolute address of the top-most parent object. // - int64_t relativeAddress; + std::optional relativeAddress; // // The number of bytes in this range of addresses. // - int64_t length; + std::optional length; // // An open-ended string that identifies the address kind. 'data', 'function', 'header','instruction', 'module', 'page', 'section', 'segment', 'stack', 'stackFrame', 'table' are well-known values. // - std::string kind; + std::optional kind; // // A name that is associated with the address, e.g., '.text'. // - std::string name; + std::optional name; // // A human-readable fully qualified name that is associated with the address. // - std::string fullyQualifiedName; + std::optional fullyQualifiedName; // // The byte offset of this address from the absolute or relative address of the parent object. // - int64_t offsetFromParent; + std::optional offsetFromParent; // // The index within run.addresses of the cached object for this address. // - int64_t index; + std::optional index; // // The index within run.addresses of the parent object. // - int64_t parentIndex; + std::optional parentIndex; // // Key/value pairs that provide additional information about the address. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const address_struct &); @@ -114,27 +130,27 @@ namespace gap::sarif::definitions // // A plain text message string. // - std::string text; + std::optional text; // // A Markdown message string. // - std::string markdown; + std::optional markdown; // // The identifier for this message. // - std::string id; + std::optional id; // // An array of strings to substitute into the message string. // - std::vector arguments; + std::optional> arguments; // // Key/value pairs that provide additional information about the message. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const message_struct &); @@ -147,27 +163,27 @@ namespace gap::sarif::definitions // // A string containing a valid relative or absolute URI. // - std::string uri; + std::optional uri; // // A string which indirectly specifies the absolute URI with respect to which a relative URI in the "uri" property is interpreted. // - std::string uriBaseId; + std::optional uriBaseId; // // The index within the run artifacts array of the artifact object associated with the artifact location. // - int64_t index; + std::optional index; // // A short description of the artifact location. // - message_struct description; + std::optional description; // // Key/value pairs that provide additional information about the artifact location. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const artifact_location_struct &); @@ -237,12 +253,12 @@ namespace gap::sarif::definitions // // A Markdown message string or format string. // - std::string markdown; + std::optional markdown; // // Key/value pairs that provide additional information about the message. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const multiformat_message_string_struct &); @@ -255,27 +271,37 @@ namespace gap::sarif::definitions // // UTF-8-encoded content from a text artifact. // - std::string text; + std::optional text; // // MIME Base64-encoded content from a binary artifact, or from a text artifact in its original encoding. // - std::string binary; + std::optional binary; // // An alternate rendered representation of the artifact (e.g., a decompiled representation of a binary region). // - multiformat_message_string_struct rendered; + std::optional rendered; // // Key/value pairs that provide additional information about the artifact content. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const artifact_content_struct &); void from_json(const nlohmann::json &, artifact_content_struct &); + // + // A dictionary, each of whose keys is the name of a hash function and each of whose values is the hashed value of the artifact produced by the specified hash function. + // + struct artifact_hashes_struct { + std::unordered_map additional_properties; + }; + + void to_json(nlohmann::json &, const artifact_hashes_struct &); + void from_json(const nlohmann::json &, artifact_hashes_struct &); + // // A single artifact. In some cases, this artifact might be nested within another artifact. // @@ -283,67 +309,67 @@ namespace gap::sarif::definitions // // A short description of the artifact. // - message_struct description; + std::optional description; // // The location of the artifact. // - artifact_location_struct location; + std::optional location; // // Identifies the index of the immediate parent of the artifact, if this artifact is nested. // - int64_t parentIndex; + std::optional parentIndex; // // The offset in bytes of the artifact within its containing artifact. // - int64_t offset; + std::optional offset; // // The length of the artifact in bytes. // - int64_t length; + std::optional length; // // The role or roles played by the artifact in the analysis. // - std::vector roles; + std::optional> roles; // // The MIME type (RFC 2045) of the artifact. // - std::string mimeType; + std::optional mimeType; // // The contents of the artifact. // - artifact_content_struct contents; + std::optional contents; // // Specifies the encoding for an artifact object that refers to a text file. // - std::string encoding; + std::optional encoding; // // Specifies the source language for any artifact object that refers to a text file that contains source code. // - std::string sourceLanguage; + std::optional sourceLanguage; // // A dictionary, each of whose keys is the name of a hash function and each of whose values is the hashed value of the artifact produced by the specified hash function. // - std::unordered_map hashes; + std::optional hashes; // // The Coordinated Universal Time (UTC) date and time at which the artifact was most recently modified. See "Date/time properties" in the SARIF spec for the required format. // - std::string lastModifiedTimeUtc; + std::optional lastModifiedTimeUtc; // // Key/value pairs that provide additional information about the artifact. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const artifact_struct &); @@ -367,7 +393,7 @@ namespace gap::sarif::definitions // // Key/value pairs that provide additional information about the change. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const artifact_change_struct &); @@ -382,7 +408,7 @@ namespace gap::sarif::definitions // // A message describing the role played by the attachment. // - message_struct description; + std::optional description; // // The location of the attachment. @@ -392,17 +418,17 @@ namespace gap::sarif::definitions // // An array of regions of interest within the attachment. // - std::vector regions; + std::optional> regions; // // An array of rectangles specifying areas of interest within the image. // - std::vector rectangles; + std::optional> rectangles; // // Key/value pairs that provide additional information about the attachment. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const attachment_struct &); @@ -416,7 +442,7 @@ namespace gap::sarif::definitions // // A message relevant to the code flow. // - message_struct message; + std::optional message; // // An array of one or more unique threadFlow objects, each of which describes the progress of a program through a thread of execution. @@ -426,7 +452,7 @@ namespace gap::sarif::definitions // // Key/value pairs that provide additional information about the code flow. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const code_flow_struct &); @@ -453,27 +479,27 @@ namespace gap::sarif::definitions // // Specifies whether the report may be produced during the scan. // - bool enabled; + std::optional enabled; // // Specifies the failure level for the report. // - level_enum level; + std::optional level; // // Specifies the relative priority of the report. Used for analysis output only. // - double rank; + std::optional rank; // // Contains configuration information specific to a report. // - std::unordered_map parameters; + std::optional parameters; // // Key/value pairs that provide additional information about the reporting configuration. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const reporting_configuration_struct &); @@ -486,22 +512,22 @@ namespace gap::sarif::definitions // // The 'name' property of the referenced toolComponent. // - std::string name; + std::optional name; // // An index into the referenced toolComponent in tool.extensions. // - int64_t index; + std::optional index; // // The 'guid' property of the referenced toolComponent. // - std::string guid; + std::optional guid; // // Key/value pairs that provide additional information about the toolComponentReference. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const tool_component_reference_struct &); @@ -514,27 +540,27 @@ namespace gap::sarif::definitions // // The id of the descriptor. // - std::string id; + std::optional id; // // The index into an array of descriptors in toolComponent.ruleDescriptors, toolComponent.notificationDescriptors, or toolComponent.taxonomyDescriptors, depending on context. // - int64_t index; + std::optional index; // // A guid that uniquely identifies the descriptor. // - std::string guid; + std::optional guid; // // A reference used to locate the toolComponent associated with the descriptor. // - tool_component_reference_struct toolComponent; + std::optional toolComponent; // // Key/value pairs that provide additional information about the reporting descriptor reference. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const reporting_descriptor_reference_struct &); @@ -557,11 +583,21 @@ namespace gap::sarif::definitions // // Key/value pairs that provide additional information about the configuration override. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const configuration_override_struct &); void from_json(const nlohmann::json &, configuration_override_struct &); + + // + // A dictionary, each of whose keys is a resource identifier and each of whose values is a multiformatMessageString object, which holds message strings in plain text and (optionally) Markdown format. The strings can include placeholders, which can be used to construct a message in combination with an arbitrary number of additional string arguments. + // + struct tool_component_global_message_strings_struct { + std::unordered_map additional_properties; + }; + + void to_json(nlohmann::json &, const tool_component_global_message_strings_struct &); + void from_json(const nlohmann::json &, tool_component_global_message_strings_struct &); struct reporting_descriptor_struct; enum class contents_enum { @@ -586,32 +622,32 @@ namespace gap::sarif::definitions // // The full name associated with the translation metadata. // - std::string fullName; + std::optional fullName; // // A brief description of the translation metadata. // - multiformat_message_string_struct shortDescription; + std::optional shortDescription; // // A comprehensive description of the translation metadata. // - multiformat_message_string_struct fullDescription; + std::optional fullDescription; // // The absolute URI from which the translation metadata can be downloaded. // - std::string downloadUri; + std::optional downloadUri; // // The absolute URI from which information related to the translation metadata can be downloaded. // - std::string informationUri; + std::optional informationUri; // // Key/value pairs that provide additional information about the translation metadata. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const translation_metadata_struct &); @@ -624,7 +660,7 @@ namespace gap::sarif::definitions // // A unique identifer for the tool component in the form of a GUID. // - std::string guid; + std::optional guid; // // The name of the tool component. @@ -634,132 +670,132 @@ namespace gap::sarif::definitions // // The organization or company that produced the tool component. // - std::string organization; + std::optional organization; // // A product suite to which the tool component belongs. // - std::string product; + std::optional product; // // A localizable string containing the name of the suite of products to which the tool component belongs. // - std::string productSuite; + std::optional productSuite; // // A brief description of the tool component. // - multiformat_message_string_struct shortDescription; + std::optional shortDescription; // // A comprehensive description of the tool component. // - multiformat_message_string_struct fullDescription; + std::optional fullDescription; // // The name of the tool component along with its version and any other useful identifying information, such as its locale. // - std::string fullName; + std::optional fullName; // // The tool component version, in whatever format the component natively provides. // - std::string version; + std::optional version; // // The tool component version in the format specified by Semantic Versioning 2.0. // - std::string semanticVersion; + std::optional semanticVersion; // // The binary version of the tool component's primary executable file expressed as four non-negative integers separated by a period (for operating systems that express file versions in this way). // - std::string dottedQuadFileVersion; + std::optional dottedQuadFileVersion; // // A string specifying the UTC date (and optionally, the time) of the component's release. // - std::string releaseDateUtc; + std::optional releaseDateUtc; // // The absolute URI from which the tool component can be downloaded. // - std::string downloadUri; + std::optional downloadUri; // // The absolute URI at which information about this version of the tool component can be found. // - std::string informationUri; + std::optional informationUri; // // A dictionary, each of whose keys is a resource identifier and each of whose values is a multiformatMessageString object, which holds message strings in plain text and (optionally) Markdown format. The strings can include placeholders, which can be used to construct a message in combination with an arbitrary number of additional string arguments. // - std::unordered_map globalMessageStrings; + std::optional globalMessageStrings; // // An array of reportingDescriptor objects relevant to the notifications related to the configuration and runtime execution of the tool component. // - std::vector notifications; + std::optional> notifications; // // An array of reportingDescriptor objects relevant to the analysis performed by the tool component. // - std::vector rules; + std::optional> rules; // // An array of reportingDescriptor objects relevant to the definitions of both standalone and tool-defined taxonomies. // - std::vector taxa; + std::optional> taxa; // // An array of the artifactLocation objects associated with the tool component. // - std::vector locations; + std::optional> locations; // // The language of the messages emitted into the log file during this run (expressed as an ISO 639-1 two-letter lowercase language code) and an optional region (expressed as an ISO 3166-1 two-letter uppercase subculture code associated with a country or region). The casing is recommended but not required (in order for this data to conform to RFC5646). // - std::string language; + std::optional language; // // The kinds of data contained in this object. // - std::vector contents; + std::optional> contents; // // Specifies whether this object contains a complete definition of the localizable and/or non-localizable data for this component, as opposed to including only data that is relevant to the results persisted to this log file. // - bool isComprehensive; + std::optional isComprehensive; // // The semantic version of the localized strings defined in this component; maintained by components that provide translations. // - std::string localizedDataSemanticVersion; + std::optional localizedDataSemanticVersion; // // The minimum value of localizedDataSemanticVersion required in translations consumed by this component; used by components that consume translations. // - std::string minimumRequiredLocalizedDataSemanticVersion; + std::optional minimumRequiredLocalizedDataSemanticVersion; // // The component which is strongly associated with this component. For a translation, this refers to the component which has been translated. For an extension, this is the driver that provides the extension's plugin model. // - tool_component_reference_struct associatedComponent; + std::optional associatedComponent; // // Translation metadata, required for a translation, not populated by other component types. // - translation_metadata_struct translationMetadata; + std::optional translationMetadata; // // An array of toolComponentReference objects to declare the taxonomies supported by the tool component. // - std::vector supportedTaxonomies; + std::optional> supportedTaxonomies; // // Key/value pairs that provide additional information about the tool component. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const tool_component_struct &); @@ -777,18 +813,28 @@ namespace gap::sarif::definitions // // Tool extensions that contributed to or reconfigured the analysis tool that was run. // - std::vector extensions; + std::optional> extensions; // // Key/value pairs that provide additional information about the tool. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const tool_struct &); void from_json(const nlohmann::json &, tool_struct &); struct notification_struct; + // + // The environment variables associated with the analysis tool process, expressed as key/value pairs. + // + struct invocation_environment_variables_struct { + std::unordered_map additional_properties; + }; + + void to_json(nlohmann::json &, const invocation_environment_variables_struct &); + void from_json(const nlohmann::json &, invocation_environment_variables_struct &); + // // The runtime environment of the analysis tool run. // @@ -796,72 +842,72 @@ namespace gap::sarif::definitions // // The command line used to invoke the tool. // - std::string commandLine; + std::optional commandLine; // // An array of strings, containing in order the command line arguments passed to the tool from the operating system. // - std::vector arguments; + std::optional> arguments; // // The locations of any response files specified on the tool's command line. // - std::vector responseFiles; + std::optional> responseFiles; // // The Coordinated Universal Time (UTC) date and time at which the run started. See "Date/time properties" in the SARIF spec for the required format. // - std::string startTimeUtc; + std::optional startTimeUtc; // // The Coordinated Universal Time (UTC) date and time at which the run ended. See "Date/time properties" in the SARIF spec for the required format. // - std::string endTimeUtc; + std::optional endTimeUtc; // // The process exit code. // - int64_t exitCode; + std::optional exitCode; // // An array of configurationOverride objects that describe rules related runtime overrides. // - std::vector ruleConfigurationOverrides; + std::optional> ruleConfigurationOverrides; // // An array of configurationOverride objects that describe notifications related runtime overrides. // - std::vector notificationConfigurationOverrides; + std::optional> notificationConfigurationOverrides; // // A list of runtime conditions detected by the tool during the analysis. // - std::vector toolExecutionNotifications; + std::optional> toolExecutionNotifications; // // A list of conditions detected by the tool that are relevant to the tool's configuration. // - std::vector toolConfigurationNotifications; + std::optional> toolConfigurationNotifications; // // The reason for the process exit. // - std::string exitCodeDescription; + std::optional exitCodeDescription; // // The name of the signal that caused the process to exit. // - std::string exitSignalName; + std::optional exitSignalName; // // The numeric value of the signal that caused the process to exit. // - int64_t exitSignalNumber; + std::optional exitSignalNumber; // // The reason given by the operating system that the process failed to start. // - std::string processStartFailureMessage; + std::optional processStartFailureMessage; // // Specifies whether the tool's execution completed successfully. @@ -871,57 +917,57 @@ namespace gap::sarif::definitions // // The machine that hosted the analysis tool run. // - std::string machine; + std::optional machine; // // The account that ran the analysis tool. // - std::string account; + std::optional account; // // The process id for the analysis tool run. // - int64_t processId; + std::optional processId; // // An absolute URI specifying the location of the analysis tool's executable. // - artifact_location_struct executableLocation; + std::optional executableLocation; // // The working directory for the analysis tool run. // - artifact_location_struct workingDirectory; + std::optional workingDirectory; // // The environment variables associated with the analysis tool process, expressed as key/value pairs. // - std::unordered_map environmentVariables; + std::optional environmentVariables; // // A file containing the standard input stream to the process that was invoked. // - artifact_location_struct stdin; + std::optional stdin; // // A file containing the standard output stream from the process that was invoked. // - artifact_location_struct stdout; + std::optional stdout; // // A file containing the standard error stream from the process that was invoked. // - artifact_location_struct stderr; + std::optional stderr; // // A file containing the interleaved standard output and standard error stream from the process that was invoked. // - artifact_location_struct stdoutStderr; + std::optional stdoutStderr; // // Key/value pairs that provide additional information about the invocation. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const invocation_struct &); @@ -939,17 +985,17 @@ namespace gap::sarif::definitions // // An invocation object that describes the invocation of the converter. // - invocation_struct invocation; + std::optional invocation; // // The locations of the analysis tool's per-run log files. // - std::vector analysisToolLogFiles; + std::optional> analysisToolLogFiles; // // Key/value pairs that provide additional information about the conversion. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const conversion_struct &); @@ -967,7 +1013,7 @@ namespace gap::sarif::definitions // // A short description of the edge. // - message_struct label; + std::optional label; // // Identifies the source node (the node at which the edge starts). @@ -982,12 +1028,22 @@ namespace gap::sarif::definitions // // Key/value pairs that provide additional information about the edge. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const edge_struct &); void from_json(const nlohmann::json &, edge_struct &); + // + // The values of relevant expressions after the edge has been traversed. + // + struct edge_traversal_final_state_struct { + std::unordered_map additional_properties; + }; + + void to_json(nlohmann::json &, const edge_traversal_final_state_struct &); + void from_json(const nlohmann::json &, edge_traversal_final_state_struct &); + // // Represents the traversal of a single edge during a graph traversal. // @@ -1000,22 +1056,22 @@ namespace gap::sarif::definitions // // A message to display to the user as the edge is traversed. // - message_struct message; + std::optional message; // // The values of relevant expressions after the edge has been traversed. // - std::unordered_map finalState; + std::optional finalState; // // The number of edge traversals necessary to return from a nested graph. // - int64_t stepOverEdgeCount; + std::optional stepOverEdgeCount; // // Key/value pairs that provide additional information about the edge traversal. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const edge_traversal_struct &); @@ -1029,7 +1085,7 @@ namespace gap::sarif::definitions // // A message relevant to this call stack. // - message_struct message; + std::optional message; // // An array of stack frames that represents a sequence of calls, rendered in reverse chronological order, that comprise the call stack. @@ -1039,7 +1095,7 @@ namespace gap::sarif::definitions // // Key/value pairs that provide additional information about the stack. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const stack_struct &); @@ -1053,27 +1109,27 @@ namespace gap::sarif::definitions // // A string that identifies the kind of exception, for example, the fully qualified type name of an object that was thrown, or the symbolic name of a signal. // - std::string kind; + std::optional kind; // // A message that describes the exception. // - std::string message; + std::optional message; // // The sequence of function calls leading to the exception. // - stack_struct stack; + std::optional stack; // // An array of exception objects each of which is considered a cause of this exception. // - std::vector innerExceptions; + std::optional> innerExceptions; // // Key/value pairs that provide additional information about the exception. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const exception_struct &); @@ -1092,107 +1148,107 @@ namespace gap::sarif::definitions // // The URI of the JSON schema corresponding to the version of the external property file format. // - std::string schema; + std::optional schema; // // The SARIF format version of this external properties object. // - version_enum version; + std::optional version; // // A stable, unique identifer for this external properties object, in the form of a GUID. // - std::string guid; + std::optional guid; // // A stable, unique identifer for the run associated with this external properties object, in the form of a GUID. // - std::string runGuid; + std::optional runGuid; // // A conversion object that will be merged with a separate run. // - conversion_struct conversion; + std::optional conversion; // // An array of graph objects that will be merged with a separate run. // - std::vector graphs; + std::optional> graphs; // // Key/value pairs that provide additional information that will be merged with a separate run. // - std::unordered_map externalizedProperties; + std::optional externalizedProperties; // // An array of artifact objects that will be merged with a separate run. // - std::vector artifacts; + std::optional> artifacts; // // Describes the invocation of the analysis tool that will be merged with a separate run. // - std::vector invocations; + std::optional> invocations; // // An array of logical locations such as namespaces, types or functions that will be merged with a separate run. // - std::vector logicalLocations; + std::optional> logicalLocations; // // An array of threadFlowLocation objects that will be merged with a separate run. // - std::vector threadFlowLocations; + std::optional> threadFlowLocations; // // An array of result objects that will be merged with a separate run. // - std::vector results; + std::optional> results; // // Tool taxonomies that will be merged with a separate run. // - std::vector taxonomies; + std::optional> taxonomies; // // The analysis tool object that will be merged with a separate run. // - tool_component_struct driver; + std::optional driver; // // Tool extensions that will be merged with a separate run. // - std::vector extensions; + std::optional> extensions; // // Tool policies that will be merged with a separate run. // - std::vector policies; + std::optional> policies; // // Tool translations that will be merged with a separate run. // - std::vector translations; + std::optional> translations; // // Addresses that will be merged with a separate run. // - std::vector addresses; + std::optional> addresses; // // Requests that will be merged with a separate run. // - std::vector webRequests; + std::optional> webRequests; // // Responses that will be merged with a separate run. // - std::vector webResponses; + std::optional> webResponses; // // Key/value pairs that provide additional information about the external properties. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const external_properties_struct &); @@ -1205,22 +1261,22 @@ namespace gap::sarif::definitions // // The location of the external property file. // - artifact_location_struct location; + std::optional location; // // A stable, unique identifer for the external property file in the form of a GUID. // - std::string guid; + std::optional guid; // // A non-negative integer specifying the number of items contained in the external property file. // - int64_t itemCount; + std::optional itemCount; // // Key/value pairs that provide additional information about the external property file. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const external_property_file_reference_struct &); @@ -1233,87 +1289,87 @@ namespace gap::sarif::definitions // // An external property file containing a run.conversion object to be merged with the root log file. // - external_property_file_reference_struct conversion; + std::optional conversion; // // An array of external property files containing a run.graphs object to be merged with the root log file. // - std::vector graphs; + std::optional> graphs; // // An external property file containing a run.properties object to be merged with the root log file. // - external_property_file_reference_struct externalizedProperties; + std::optional externalizedProperties; // // An array of external property files containing run.artifacts arrays to be merged with the root log file. // - std::vector artifacts; + std::optional> artifacts; // // An array of external property files containing run.invocations arrays to be merged with the root log file. // - std::vector invocations; + std::optional> invocations; // // An array of external property files containing run.logicalLocations arrays to be merged with the root log file. // - std::vector logicalLocations; + std::optional> logicalLocations; // // An array of external property files containing run.threadFlowLocations arrays to be merged with the root log file. // - std::vector threadFlowLocations; + std::optional> threadFlowLocations; // // An array of external property files containing run.results arrays to be merged with the root log file. // - std::vector results; + std::optional> results; // // An array of external property files containing run.taxonomies arrays to be merged with the root log file. // - std::vector taxonomies; + std::optional> taxonomies; // // An array of external property files containing run.addresses arrays to be merged with the root log file. // - std::vector addresses; + std::optional> addresses; // // An external property file containing a run.driver object to be merged with the root log file. // - external_property_file_reference_struct driver; + std::optional driver; // // An array of external property files containing run.extensions arrays to be merged with the root log file. // - std::vector extensions; + std::optional> extensions; // // An array of external property files containing run.policies arrays to be merged with the root log file. // - std::vector policies; + std::optional> policies; // // An array of external property files containing run.translations arrays to be merged with the root log file. // - std::vector translations; + std::optional> translations; // // An array of external property files containing run.requests arrays to be merged with the root log file. // - std::vector webRequests; + std::optional> webRequests; // // An array of external property files containing run.responses arrays to be merged with the root log file. // - std::vector webResponses; + std::optional> webResponses; // // Key/value pairs that provide additional information about the external property files. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const external_property_file_references_struct &); @@ -1326,7 +1382,7 @@ namespace gap::sarif::definitions // // A message that describes the proposed fix, enabling viewers to present the proposed change to an end user. // - message_struct description; + std::optional description; // // One or more artifact changes that comprise a fix for a result. @@ -1336,7 +1392,7 @@ namespace gap::sarif::definitions // // Key/value pairs that provide additional information about the fix. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const fix_struct &); @@ -1350,27 +1406,47 @@ namespace gap::sarif::definitions // // A description of the graph. // - message_struct description; + std::optional description; // // An array of node objects representing the nodes of the graph. // - std::vector nodes; + std::optional> nodes; // // An array of edge objects representing the edges of the graph. // - std::vector edges; + std::optional> edges; // // Key/value pairs that provide additional information about the graph. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const graph_struct &); void from_json(const nlohmann::json &, graph_struct &); + // + // Values of relevant expressions at the start of the graph traversal that may change during graph traversal. + // + struct graph_traversal_initial_state_struct { + std::unordered_map additional_properties; + }; + + void to_json(nlohmann::json &, const graph_traversal_initial_state_struct &); + void from_json(const nlohmann::json &, graph_traversal_initial_state_struct &); + + // + // Values of relevant expressions at the start of the graph traversal that remain constant for the graph traversal. + // + struct graph_traversal_immutable_state_struct { + std::unordered_map additional_properties; + }; + + void to_json(nlohmann::json &, const graph_traversal_immutable_state_struct &); + void from_json(const nlohmann::json &, graph_traversal_immutable_state_struct &); + // // Represents a path through a graph. // @@ -1378,37 +1454,37 @@ namespace gap::sarif::definitions // // The index within the run.graphs to be associated with the result. // - int64_t runGraphIndex; + std::optional runGraphIndex; // // The index within the result.graphs to be associated with the result. // - int64_t resultGraphIndex; + std::optional resultGraphIndex; // // A description of this graph traversal. // - message_struct description; + std::optional description; // // Values of relevant expressions at the start of the graph traversal that may change during graph traversal. // - std::unordered_map initialState; + std::optional initialState; // // Values of relevant expressions at the start of the graph traversal that remain constant for the graph traversal. // - std::unordered_map immutableState; + std::optional immutableState; // // The sequences of edges traversed by this graph traversal. // - std::vector edgeTraversals; + std::optional> edgeTraversals; // // Key/value pairs that provide additional information about the graph traversal. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const graph_traversal_struct &); @@ -1421,62 +1497,62 @@ namespace gap::sarif::definitions // // The line number of the first character in the region. // - int64_t startLine; + std::optional startLine; // // The column number of the first character in the region. // - int64_t startColumn; + std::optional startColumn; // // The line number of the last character in the region. // - int64_t endLine; + std::optional endLine; // // The column number of the character following the end of the region. // - int64_t endColumn; + std::optional endColumn; // // The zero-based offset from the beginning of the artifact of the first character in the region. // - int64_t charOffset; + std::optional charOffset; // // The length of the region in characters. // - int64_t charLength; + std::optional charLength; // // The zero-based offset from the beginning of the artifact of the first byte in the region. // - int64_t byteOffset; + std::optional byteOffset; // // The length of the region in bytes. // - int64_t byteLength; + std::optional byteLength; // // The portion of the artifact contents within the specified region. // - artifact_content_struct snippet; + std::optional snippet; // // A message relevant to the region. // - message_struct message; + std::optional message; // // Specifies the source language, if any, of the portion of the artifact specified by the region object. // - std::string sourceLanguage; + std::optional sourceLanguage; // // Key/value pairs that provide additional information about the region. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const region_struct &); @@ -1489,27 +1565,27 @@ namespace gap::sarif::definitions // // The address of the location. // - address_struct address; + std::optional address; // // The location of the artifact. // - artifact_location_struct artifactLocation; + std::optional artifactLocation; // // Specifies a portion of the artifact. // - region_struct region; + std::optional region; // // Specifies a portion of the artifact that encloses the region. Allows a viewer to display additional context around the region. // - region_struct contextRegion; + std::optional contextRegion; // // Key/value pairs that provide additional information about the physical location. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const physical_location_struct &); @@ -1523,37 +1599,37 @@ namespace gap::sarif::definitions // // Value that distinguishes this location from all other locations within a single result object. // - int64_t id; + std::optional id; // // Identifies the artifact and region. // - physical_location_struct physicalLocation; + std::optional physicalLocation; // // The logical locations associated with the result. // - std::vector logicalLocations; + std::optional> logicalLocations; // // A message relevant to the location. // - message_struct message; + std::optional message; // // A set of regions relevant to the location. // - std::vector annotations; + std::optional> annotations; // // An array of objects that describe relationships between this location and others. // - std::vector relationships; + std::optional> relationships; // // Key/value pairs that provide additional information about the location. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const location_struct &); @@ -1571,17 +1647,17 @@ namespace gap::sarif::definitions // // A set of distinct strings that categorize the relationship. Well-known kinds include 'includes', 'isIncludedBy' and 'relevant'. // - std::vector kinds; + std::optional> kinds; // // A description of the location relationship. // - message_struct description; + std::optional description; // // Key/value pairs that provide additional information about the location relationship. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const location_relationship_struct &); @@ -1594,37 +1670,37 @@ namespace gap::sarif::definitions // // Identifies the construct in which the result occurred. For example, this property might contain the name of a class or a method. // - std::string name; + std::optional name; // // The index within the logical locations array. // - int64_t index; + std::optional index; // // The human-readable fully qualified name of the logical location. // - std::string fullyQualifiedName; + std::optional fullyQualifiedName; // // The machine-readable name for the logical location, such as a mangled function name provided by a C++ compiler that encodes calling convention, return type and other details along with the function name. // - std::string decoratedName; + std::optional decoratedName; // // Identifies the index of the immediate parent of the construct in which the result was detected. For example, this property might point to a logical location that represents the namespace that holds a type. // - int64_t parentIndex; + std::optional parentIndex; // // The type of construct this logical location component refers to. Should be one of 'function', 'member', 'module', 'namespace', 'parameter', 'resource', 'returnType', 'type', 'variable', 'object', 'array', 'property', 'value', 'element', 'text', 'attribute', 'comment', 'declaration', 'dtd' or 'processingInstruction', if any of those accurately describe the construct. // - std::string kind; + std::optional kind; // // Key/value pairs that provide additional information about the logical location. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const logical_location_struct &); @@ -1642,22 +1718,22 @@ namespace gap::sarif::definitions // // A short description of the node. // - message_struct label; + std::optional label; // // A code location associated with the node. // - location_struct location; + std::optional location; // // Array of child nodes. // - std::vector children; + std::optional> children; // // Key/value pairs that provide additional information about the node. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const node_struct &); @@ -1670,7 +1746,7 @@ namespace gap::sarif::definitions // // The locations relevant to this notification. // - std::vector locations; + std::optional> locations; // // A message that describes the condition that was encountered. @@ -1680,37 +1756,37 @@ namespace gap::sarif::definitions // // A value specifying the severity level of the notification. // - level_enum level; + std::optional level; // // The thread identifier of the code that generated the notification. // - int64_t threadId; + std::optional threadId; // // The Coordinated Universal Time (UTC) date and time at which the analysis tool generated the notification. // - std::string timeUtc; + std::optional timeUtc; // // The runtime exception, if any, relevant to this notification. // - exception_struct exception; + std::optional exception; // // A reference used to locate the descriptor relevant to this notification. // - reporting_descriptor_reference_struct descriptor; + std::optional descriptor; // // A reference used to locate the rule descriptor associated with this notification. // - reporting_descriptor_reference_struct associatedRule; + std::optional associatedRule; // // Key/value pairs that provide additional information about the notification. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const notification_struct &); @@ -1723,32 +1799,32 @@ namespace gap::sarif::definitions // // The Y coordinate of the top edge of the rectangle, measured in the image's natural units. // - double top; + std::optional top; // // The X coordinate of the left edge of the rectangle, measured in the image's natural units. // - double left; + std::optional left; // // The Y coordinate of the bottom edge of the rectangle, measured in the image's natural units. // - double bottom; + std::optional bottom; // // The X coordinate of the right edge of the rectangle, measured in the image's natural units. // - double right; + std::optional right; // // A message relevant to the rectangle. // - message_struct message; + std::optional message; // // Key/value pairs that provide additional information about the rectangle. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const rectangle_struct &); @@ -1766,16 +1842,26 @@ namespace gap::sarif::definitions // // The content to insert at the location specified by the 'deletedRegion' property. // - artifact_content_struct insertedContent; + std::optional insertedContent; // // Key/value pairs that provide additional information about the replacement. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const replacement_struct &); void from_json(const nlohmann::json &, replacement_struct &); + + // + // A set of name/value pairs with arbitrary names. Each value is a multiformatMessageString object, which holds message strings in plain text and (optionally) Markdown format. The strings can include placeholders, which can be used to construct a message in combination with an arbitrary number of additional string arguments. + // + struct reporting_descriptor_message_strings_struct { + std::unordered_map additional_properties; + }; + + void to_json(nlohmann::json &, const reporting_descriptor_message_strings_struct &); + void from_json(const nlohmann::json &, reporting_descriptor_message_strings_struct &); struct reporting_descriptor_relationship_struct; // @@ -1790,67 +1876,67 @@ namespace gap::sarif::definitions // // An array of stable, opaque identifiers by which this report was known in some previous version of the analysis tool. // - std::vector deprecatedIds; + std::optional> deprecatedIds; // // A unique identifer for the reporting descriptor in the form of a GUID. // - std::string guid; + std::optional guid; // // An array of unique identifies in the form of a GUID by which this report was known in some previous version of the analysis tool. // - std::vector deprecatedGuids; + std::optional> deprecatedGuids; // // A report identifier that is understandable to an end user. // - std::string name; + std::optional name; // // An array of readable identifiers by which this report was known in some previous version of the analysis tool. // - std::vector deprecatedNames; + std::optional> deprecatedNames; // // A concise description of the report. Should be a single sentence that is understandable when visible space is limited to a single line of text. // - multiformat_message_string_struct shortDescription; + std::optional shortDescription; // // A description of the report. Should, as far as possible, provide details sufficient to enable resolution of any problem indicated by the result. // - multiformat_message_string_struct fullDescription; + std::optional fullDescription; // // A set of name/value pairs with arbitrary names. Each value is a multiformatMessageString object, which holds message strings in plain text and (optionally) Markdown format. The strings can include placeholders, which can be used to construct a message in combination with an arbitrary number of additional string arguments. // - std::unordered_map messageStrings; + std::optional messageStrings; // // Default reporting configuration information. // - reporting_configuration_struct defaultConfiguration; + std::optional defaultConfiguration; // // A URI where the primary documentation for the report can be found. // - std::string helpUri; + std::optional helpUri; // // Provides the primary documentation for the report, useful when there is no online documentation. // - multiformat_message_string_struct help; + std::optional help; // // An array of objects that describe relationships between this reporting descriptor and others. // - std::vector relationships; + std::optional> relationships; // // Key/value pairs that provide additional information about the report. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const reporting_descriptor_struct &); @@ -1868,17 +1954,17 @@ namespace gap::sarif::definitions // // A set of distinct strings that categorize the relationship. Well-known kinds include 'canPrecede', 'canFollow', 'willPrecede', 'willFollow', 'superset', 'subset', 'equal', 'disjoint', 'relevant', and 'incomparable'. // - std::vector kinds; + std::optional> kinds; // // A description of the reporting descriptor relationship. // - message_struct description; + std::optional description; // // Key/value pairs that provide additional information about the reporting descriptor reference. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const reporting_descriptor_relationship_struct &); @@ -1901,6 +1987,26 @@ namespace gap::sarif::definitions {kind_enum::kOpen, "open"}, {kind_enum::kInformational, "informational"}, }) + + // + // A set of strings that contribute to the stable, unique identity of the result. + // + struct result_partial_fingerprints_struct { + std::unordered_map additional_properties; + }; + + void to_json(nlohmann::json &, const result_partial_fingerprints_struct &); + void from_json(const nlohmann::json &, result_partial_fingerprints_struct &); + + // + // A set of strings each of which individually defines a stable, unique identity for the result. + // + struct result_fingerprints_struct { + std::unordered_map additional_properties; + }; + + void to_json(nlohmann::json &, const result_fingerprints_struct &); + void from_json(const nlohmann::json &, result_fingerprints_struct &); struct suppression_struct; enum class baseline_state_enum { @@ -1924,42 +2030,62 @@ namespace gap::sarif::definitions // // The Coordinated Universal Time (UTC) date and time at which the result was first detected. See "Date/time properties" in the SARIF spec for the required format. // - std::string firstDetectionTimeUtc; + std::optional firstDetectionTimeUtc; // // The Coordinated Universal Time (UTC) date and time at which the result was most recently detected. See "Date/time properties" in the SARIF spec for the required format. // - std::string lastDetectionTimeUtc; + std::optional lastDetectionTimeUtc; // // A GUID-valued string equal to the automationDetails.guid property of the run in which the result was first detected. // - std::string firstDetectionRunGuid; + std::optional firstDetectionRunGuid; // // A GUID-valued string equal to the automationDetails.guid property of the run in which the result was most recently detected. // - std::string lastDetectionRunGuid; + std::optional lastDetectionRunGuid; // // The index within the run.invocations array of the invocation object which describes the tool invocation that detected the result. // - int64_t invocationIndex; + std::optional invocationIndex; // // An array of physicalLocation objects which specify the portions of an analysis tool's output that a converter transformed into the result. // - std::vector conversionSources; + std::optional> conversionSources; // // Key/value pairs that provide additional information about the result. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const result_provenance_struct &); void from_json(const nlohmann::json &, result_provenance_struct &); + // + // The request headers. + // + struct web_request_headers_struct { + std::unordered_map additional_properties; + }; + + void to_json(nlohmann::json &, const web_request_headers_struct &); + void from_json(const nlohmann::json &, web_request_headers_struct &); + + // + // The request parameters. + // + struct web_request_parameters_struct { + std::unordered_map additional_properties; + }; + + void to_json(nlohmann::json &, const web_request_parameters_struct &); + void from_json(const nlohmann::json &, web_request_parameters_struct &); + // // Describes an HTTP request. // @@ -1967,52 +2093,62 @@ namespace gap::sarif::definitions // // The index within the run.webRequests array of the request object associated with this result. // - int64_t index; + std::optional index; // // The request protocol. Example: 'http'. // - std::string protocol; + std::optional protocol; // // The request version. Example: '1.1'. // - std::string version; + std::optional version; // // The target of the request. // - std::string target; + std::optional target; // // The HTTP method. Well-known values are 'GET', 'PUT', 'POST', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS', 'TRACE', 'CONNECT'. // - std::string method; + std::optional method; // // The request headers. // - std::unordered_map headers; + std::optional headers; // // The request parameters. // - std::unordered_map parameters; + std::optional parameters; // // The body of the request. // - artifact_content_struct body; + std::optional body; // // Key/value pairs that provide additional information about the request. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const web_request_struct &); void from_json(const nlohmann::json &, web_request_struct &); + // + // The response headers. + // + struct web_response_headers_struct { + std::unordered_map additional_properties; + }; + + void to_json(nlohmann::json &, const web_response_headers_struct &); + void from_json(const nlohmann::json &, web_response_headers_struct &); + // // Describes the response to an HTTP request. // @@ -2020,47 +2156,47 @@ namespace gap::sarif::definitions // // The index within the run.webResponses array of the response object associated with this result. // - int64_t index; + std::optional index; // // The response protocol. Example: 'http'. // - std::string protocol; + std::optional protocol; // // The response version. Example: '1.1'. // - std::string version; + std::optional version; // // The response status code. Example: 451. // - int64_t statusCode; + std::optional statusCode; // // The response reason. Example: 'Not found'. // - std::string reasonPhrase; + std::optional reasonPhrase; // // The response headers. // - std::unordered_map headers; + std::optional headers; // // The body of the response. // - artifact_content_struct body; + std::optional body; // // Specifies whether a response was received from the server. // - bool noResponseReceived; + std::optional noResponseReceived; // // Key/value pairs that provide additional information about the response. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const web_response_struct &); @@ -2073,27 +2209,27 @@ namespace gap::sarif::definitions // // The stable, unique identifier of the rule, if any, to which this notification is relevant. This member can be used to retrieve rule metadata from the rules dictionary, if it exists. // - std::string ruleId; + std::optional ruleId; // // The index within the tool component rules array of the rule object associated with this result. // - int64_t ruleIndex; + std::optional ruleIndex; // // A reference used to locate the rule descriptor relevant to this result. // - reporting_descriptor_reference_struct rule; + std::optional rule; // // A value that categorizes results by evaluation state. // - kind_enum kind; + std::optional kind; // // A value specifying the severity level of the result. // - level_enum level; + std::optional level; // // A message that describes the result. The first sentence of the message only will be displayed when visible space is limited. @@ -2103,128 +2239,138 @@ namespace gap::sarif::definitions // // Identifies the artifact that the analysis tool was instructed to scan. This need not be the same as the artifact where the result actually occurred. // - artifact_location_struct analysisTarget; + std::optional analysisTarget; // // The set of locations where the result was detected. Specify only one location unless the problem indicated by the result can only be corrected by making a change at every specified location. // - std::vector locations; + std::optional> locations; // // A stable, unique identifer for the result in the form of a GUID. // - std::string guid; + std::optional guid; // // A stable, unique identifier for the equivalence class of logically identical results to which this result belongs, in the form of a GUID. // - std::string correlationGuid; + std::optional correlationGuid; // // A positive integer specifying the number of times this logically unique result was observed in this run. // - int64_t occurrenceCount; + std::optional occurrenceCount; // // A set of strings that contribute to the stable, unique identity of the result. // - std::unordered_map partialFingerprints; + std::optional partialFingerprints; // // A set of strings each of which individually defines a stable, unique identity for the result. // - std::unordered_map fingerprints; + std::optional fingerprints; // // An array of 'stack' objects relevant to the result. // - std::vector stacks; + std::optional> stacks; // // An array of 'codeFlow' objects relevant to the result. // - std::vector codeFlows; + std::optional> codeFlows; // // An array of zero or more unique graph objects associated with the result. // - std::vector graphs; + std::optional> graphs; // // An array of one or more unique 'graphTraversal' objects. // - std::vector graphTraversals; + std::optional> graphTraversals; // // A set of locations relevant to this result. // - std::vector relatedLocations; + std::optional> relatedLocations; // // A set of suppressions relevant to this result. // - std::vector suppressions; + std::optional> suppressions; // // The state of a result relative to a baseline of a previous run. // - baseline_state_enum baselineState; + std::optional baselineState; // // A number representing the priority or importance of the result. // - double rank; + std::optional rank; // // A set of artifacts relevant to the result. // - std::vector attachments; + std::optional> attachments; // // An absolute URI at which the result can be viewed. // - std::string hostedViewerUri; + std::optional hostedViewerUri; // // The URIs of the work items associated with this result. // - std::vector workItemUris; + std::optional> workItemUris; // // Information about how and when the result was detected. // - result_provenance_struct provenance; + std::optional provenance; // // An array of 'fix' objects, each of which represents a proposed fix to the problem indicated by the result. // - std::vector fixes; + std::optional> fixes; // // An array of references to taxonomy reporting descriptors that are applicable to the result. // - std::vector taxa; + std::optional> taxa; // // A web request associated with this result. // - web_request_struct webRequest; + std::optional webRequest; // // A web response associated with this result. // - web_response_struct webResponse; + std::optional webResponse; // // Key/value pairs that provide additional information about the result. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const result_struct &); void from_json(const nlohmann::json &, result_struct &); struct version_control_details_struct; + // + // The artifact location specified by each uriBaseId symbol on the machine where the tool originally ran. + // + struct run_original_uri_base_ids_struct { + std::unordered_map additional_properties; + }; + + void to_json(nlohmann::json &, const run_original_uri_base_ids_struct &); + void from_json(const nlohmann::json &, run_original_uri_base_ids_struct &); + // // Information that describes a run's identity and role within an engineering system process. // @@ -2232,27 +2378,27 @@ namespace gap::sarif::definitions // // A description of the identity and role played within the engineering system by this object's containing run object. // - message_struct description; + std::optional description; // // A hierarchical string that uniquely identifies this object's containing run object. // - std::string id; + std::optional id; // // A stable, unique identifer for this object's containing run object in the form of a GUID. // - std::string guid; + std::optional guid; // // A stable, unique identifier for the equivalence class of runs to which this object's containing run object belongs in the form of a GUID. // - std::string correlationGuid; + std::optional correlationGuid; // // Key/value pairs that provide additional information about the run automation details. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const run_automation_details_struct &); @@ -2275,12 +2421,12 @@ namespace gap::sarif::definitions // // Provides a suggestion to SARIF consumers to display file paths relative to the specified location. // - artifact_location_struct displayBase; + std::optional displayBase; // // Key/value pairs that provide additional information about the special locations. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const special_locations_struct &); @@ -2298,137 +2444,137 @@ namespace gap::sarif::definitions // // Describes the invocation of the analysis tool. // - std::vector invocations; + std::optional> invocations; // // A conversion object that describes how a converter transformed an analysis tool's native reporting format into the SARIF format. // - conversion_struct conversion; + std::optional conversion; // // The language of the messages emitted into the log file during this run (expressed as an ISO 639-1 two-letter lowercase culture code) and an optional region (expressed as an ISO 3166-1 two-letter uppercase subculture code associated with a country or region). The casing is recommended but not required (in order for this data to conform to RFC5646). // - std::string language; + std::optional language; // // Specifies the revision in version control of the artifacts that were scanned. // - std::vector versionControlProvenance; + std::optional> versionControlProvenance; // // The artifact location specified by each uriBaseId symbol on the machine where the tool originally ran. // - std::unordered_map originalUriBaseIds; + std::optional originalUriBaseIds; // // An array of artifact objects relevant to the run. // - std::vector artifacts; + std::optional> artifacts; // // An array of logical locations such as namespaces, types or functions. // - std::vector logicalLocations; + std::optional> logicalLocations; // // An array of zero or more unique graph objects associated with the run. // - std::vector graphs; + std::optional> graphs; // // The set of results contained in an SARIF log. The results array can be omitted when a run is solely exporting rules metadata. It must be present (but may be empty) if a log file represents an actual scan. // - std::vector results; + std::optional> results; // // Automation details that describe this run. // - run_automation_details_struct automationDetails; + std::optional automationDetails; // // Automation details that describe the aggregate of runs to which this run belongs. // - std::vector runAggregates; + std::optional> runAggregates; // // The 'guid' property of a previous SARIF 'run' that comprises the baseline that was used to compute result 'baselineState' properties for the run. // - std::string baselineGuid; + std::optional baselineGuid; // // An array of strings used to replace sensitive information in a redaction-aware property. // - std::vector redactionTokens; + std::optional> redactionTokens; // // Specifies the default encoding for any artifact object that refers to a text file. // - std::string defaultEncoding; + std::optional defaultEncoding; // // Specifies the default source language for any artifact object that refers to a text file that contains source code. // - std::string defaultSourceLanguage; + std::optional defaultSourceLanguage; // // An ordered list of character sequences that were treated as line breaks when computing region information for the run. // - std::vector newlineSequences; + std::optional> newlineSequences; // // Specifies the unit in which the tool measures columns. // - column_kind_enum columnKind; + std::optional columnKind; // // References to external property files that should be inlined with the content of a root log file. // - external_property_file_references_struct externalPropertyFileReferences; + std::optional externalPropertyFileReferences; // // An array of threadFlowLocation objects cached at run level. // - std::vector threadFlowLocations; + std::optional> threadFlowLocations; // // An array of toolComponent objects relevant to a taxonomy in which results are categorized. // - std::vector taxonomies; + std::optional> taxonomies; // // Addresses associated with this run instance, if any. // - std::vector addresses; + std::optional> addresses; // // The set of available translations of the localized data provided by the tool. // - std::vector translations; + std::optional> translations; // // Contains configurations that may potentially override both reportingDescriptor.defaultConfiguration (the tool's default severities) and invocation.configurationOverrides (severities established at run-time from the command line). // - std::vector policies; + std::optional> policies; // // An array of request objects cached at run level. // - std::vector webRequests; + std::optional> webRequests; // // An array of response objects cached at run level. // - std::vector webResponses; + std::optional> webResponses; // // A specialLocations object that defines locations of special significance to SARIF consumers. // - special_locations_struct specialLocations; + std::optional specialLocations; // // Key/value pairs that provide additional information about the run. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const run_struct &); @@ -2441,27 +2587,27 @@ namespace gap::sarif::definitions // // The location to which this stack frame refers. // - location_struct location; + std::optional location; // // The name of the module that contains the code of this stack frame. // - std::string module; + std::optional module; // // The thread identifier of the stack frame. // - int64_t threadId; + std::optional threadId; // // The parameters of the call that is executing. // - std::vector parameters; + std::optional> parameters; // // Key/value pairs that provide additional information about the stack frame. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const stack_frame_struct &); @@ -2486,7 +2632,7 @@ namespace gap::sarif::definitions // // A stable, unique identifer for the suprression in the form of a GUID. // - std::string guid; + std::optional guid; // // A string that indicates where the suppression is persisted. @@ -2496,27 +2642,47 @@ namespace gap::sarif::definitions // // A string that indicates the state of the suppression. // - state_enum state; + std::optional state; // // A string representing the justification for the suppression. // - std::string justification; + std::optional justification; // // Identifies the location associated with the suppression. // - location_struct location; + std::optional location; // // Key/value pairs that provide additional information about the suppression. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const suppression_struct &); void from_json(const nlohmann::json &, suppression_struct &); + // + // Values of relevant expressions at the start of the thread flow that may change during thread flow execution. + // + struct thread_flow_initial_state_struct { + std::unordered_map additional_properties; + }; + + void to_json(nlohmann::json &, const thread_flow_initial_state_struct &); + void from_json(const nlohmann::json &, thread_flow_initial_state_struct &); + + // + // Values of relevant expressions at the start of the thread flow that remain constant. + // + struct thread_flow_immutable_state_struct { + std::unordered_map additional_properties; + }; + + void to_json(nlohmann::json &, const thread_flow_immutable_state_struct &); + void from_json(const nlohmann::json &, thread_flow_immutable_state_struct &); + // // Describes a sequence of code locations that specify a path through a single thread of execution such as an operating system or fiber. // @@ -2524,22 +2690,22 @@ namespace gap::sarif::definitions // // An string that uniquely identifies the threadFlow within the codeFlow in which it occurs. // - std::string id; + std::optional id; // // A message relevant to the thread flow. // - message_struct message; + std::optional message; // // Values of relevant expressions at the start of the thread flow that may change during thread flow execution. // - std::unordered_map initialState; + std::optional initialState; // // Values of relevant expressions at the start of the thread flow that remain constant. // - std::unordered_map immutableState; + std::optional immutableState; // // A temporally ordered array of 'threadFlowLocation' objects, each of which describes a location visited by the tool while producing the result. @@ -2549,12 +2715,22 @@ namespace gap::sarif::definitions // // Key/value pairs that provide additional information about the thread flow. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const thread_flow_struct &); void from_json(const nlohmann::json &, thread_flow_struct &); + // + // A dictionary, each of whose keys specifies a variable or expression, the associated value of which represents the variable or expression value. For an annotation of kind 'continuation', for example, this dictionary might hold the current assumed values of a set of global variables. + // + struct thread_flow_location_state_struct { + std::unordered_map additional_properties; + }; + + void to_json(nlohmann::json &, const thread_flow_location_state_struct &); + void from_json(const nlohmann::json &, thread_flow_location_state_struct &); + enum class importance_enum { kImportant, kEssential, @@ -2574,72 +2750,72 @@ namespace gap::sarif::definitions // // The index within the run threadFlowLocations array. // - int64_t index; + std::optional index; // // The code location. // - location_struct location; + std::optional location; // // The call stack leading to this location. // - stack_struct stack; + std::optional stack; // // A set of distinct strings that categorize the thread flow location. Well-known kinds include 'acquire', 'release', 'enter', 'exit', 'call', 'return', 'branch', 'implicit', 'false', 'true', 'caution', 'danger', 'unknown', 'unreachable', 'taint', 'function', 'handler', 'lock', 'memory', 'resource', 'scope' and 'value'. // - std::vector kinds; + std::optional> kinds; // // An array of references to rule or taxonomy reporting descriptors that are applicable to the thread flow location. // - std::vector taxa; + std::optional> taxa; // // The name of the module that contains the code that is executing. // - std::string module; + std::optional module; // // A dictionary, each of whose keys specifies a variable or expression, the associated value of which represents the variable or expression value. For an annotation of kind 'continuation', for example, this dictionary might hold the current assumed values of a set of global variables. // - std::unordered_map state; + std::optional state; // // An integer representing a containment hierarchy within the thread flow. // - int64_t nestingLevel; + std::optional nestingLevel; // // An integer representing the temporal order in which execution reached this location. // - int64_t executionOrder; + std::optional executionOrder; // // The Coordinated Universal Time (UTC) date and time at which this location was executed. // - std::string executionTimeUtc; + std::optional executionTimeUtc; // // Specifies the importance of this location in understanding the code flow in which it occurs. The order from most to least important is "essential", "important", "unimportant". Default: "important". // - importance_enum importance; + std::optional importance; // // A web request associated with this thread flow location. // - web_request_struct webRequest; + std::optional webRequest; // // A web response associated with this thread flow location. // - web_response_struct webResponse; + std::optional webResponse; // // Key/value pairs that provide additional information about the threadflow location. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const thread_flow_location_struct &); @@ -2657,87 +2833,34 @@ namespace gap::sarif::definitions // // A string that uniquely and permanently identifies the revision within the repository. // - std::string revisionId; + std::optional revisionId; // // The name of a branch containing the revision. // - std::string branch; + std::optional branch; // // A tag that has been applied to the revision. // - std::string revisionTag; + std::optional revisionTag; // // A Coordinated Universal Time (UTC) date and time that can be used to synchronize an enlistment to the state of the repository at that time. // - std::string asOfTimeUtc; + std::optional asOfTimeUtc; // // The location in the local file system to which the root of the repository was mapped at the time of the analysis. // - artifact_location_struct mappedTo; + std::optional mappedTo; // // Key/value pairs that provide additional information about the version control details. // - std::unordered_map properties; + std::optional properties; }; void to_json(nlohmann::json &, const version_control_details_struct &); void from_json(const nlohmann::json &, version_control_details_struct &); - - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(root_struct, version, runs, inlineExternalProperties, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(address_struct, absoluteAddress, relativeAddress, length, kind, name, fullyQualifiedName, offsetFromParent, index, parentIndex, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(message_struct, text, markdown, id, arguments, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(artifact_location_struct, uri, uriBaseId, index, description, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(multiformat_message_string_struct, text, markdown, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(artifact_content_struct, text, binary, rendered, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(artifact_struct, description, location, parentIndex, offset, length, roles, mimeType, contents, encoding, sourceLanguage, hashes, lastModifiedTimeUtc, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(artifact_change_struct, artifactLocation, replacements, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(attachment_struct, description, artifactLocation, regions, rectangles, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(code_flow_struct, message, threadFlows, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(reporting_configuration_struct, enabled, level, rank, parameters, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(tool_component_reference_struct, name, index, guid, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(reporting_descriptor_reference_struct, id, index, guid, toolComponent, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(configuration_override_struct, configuration, descriptor, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(translation_metadata_struct, name, fullName, shortDescription, fullDescription, downloadUri, informationUri, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(tool_component_struct, guid, name, organization, product, productSuite, shortDescription, fullDescription, fullName, version, semanticVersion, dottedQuadFileVersion, releaseDateUtc, downloadUri, informationUri, globalMessageStrings, notifications, rules, taxa, locations, language, contents, isComprehensive, localizedDataSemanticVersion, minimumRequiredLocalizedDataSemanticVersion, associatedComponent, translationMetadata, supportedTaxonomies, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(tool_struct, driver, extensions, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(invocation_struct, commandLine, arguments, responseFiles, startTimeUtc, endTimeUtc, exitCode, ruleConfigurationOverrides, notificationConfigurationOverrides, toolExecutionNotifications, toolConfigurationNotifications, exitCodeDescription, exitSignalName, exitSignalNumber, processStartFailureMessage, executionSuccessful, machine, account, processId, executableLocation, workingDirectory, environmentVariables, stdin, stdout, stderr, stdoutStderr, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(conversion_struct, tool, invocation, analysisToolLogFiles, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(edge_struct, id, label, sourceNodeId, targetNodeId, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(edge_traversal_struct, edgeId, message, finalState, stepOverEdgeCount, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(stack_struct, message, frames, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(exception_struct, kind, message, stack, innerExceptions, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(external_properties_struct, schema, version, guid, runGuid, conversion, graphs, externalizedProperties, artifacts, invocations, logicalLocations, threadFlowLocations, results, taxonomies, driver, extensions, policies, translations, addresses, webRequests, webResponses, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(external_property_file_reference_struct, location, guid, itemCount, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(external_property_file_references_struct, conversion, graphs, externalizedProperties, artifacts, invocations, logicalLocations, threadFlowLocations, results, taxonomies, addresses, driver, extensions, policies, translations, webRequests, webResponses, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(fix_struct, description, artifactChanges, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(graph_struct, description, nodes, edges, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(graph_traversal_struct, runGraphIndex, resultGraphIndex, description, initialState, immutableState, edgeTraversals, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(region_struct, startLine, startColumn, endLine, endColumn, charOffset, charLength, byteOffset, byteLength, snippet, message, sourceLanguage, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(physical_location_struct, address, artifactLocation, region, contextRegion, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(location_struct, id, physicalLocation, logicalLocations, message, annotations, relationships, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(location_relationship_struct, target, kinds, description, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(logical_location_struct, name, index, fullyQualifiedName, decoratedName, parentIndex, kind, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(node_struct, id, label, location, children, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(notification_struct, locations, message, level, threadId, timeUtc, exception, descriptor, associatedRule, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(rectangle_struct, top, left, bottom, right, message, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(replacement_struct, deletedRegion, insertedContent, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(reporting_descriptor_struct, id, deprecatedIds, guid, deprecatedGuids, name, deprecatedNames, shortDescription, fullDescription, messageStrings, defaultConfiguration, helpUri, help, relationships, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(reporting_descriptor_relationship_struct, target, kinds, description, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(result_provenance_struct, firstDetectionTimeUtc, lastDetectionTimeUtc, firstDetectionRunGuid, lastDetectionRunGuid, invocationIndex, conversionSources, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(web_request_struct, index, protocol, version, target, method, headers, parameters, body, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(web_response_struct, index, protocol, version, statusCode, reasonPhrase, headers, body, noResponseReceived, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(result_struct, ruleId, ruleIndex, rule, kind, level, message, analysisTarget, locations, guid, correlationGuid, occurrenceCount, partialFingerprints, fingerprints, stacks, codeFlows, graphs, graphTraversals, relatedLocations, suppressions, baselineState, rank, attachments, hostedViewerUri, workItemUris, provenance, fixes, taxa, webRequest, webResponse, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(run_automation_details_struct, description, id, guid, correlationGuid, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(special_locations_struct, displayBase, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(run_struct, tool, invocations, conversion, language, versionControlProvenance, originalUriBaseIds, artifacts, logicalLocations, graphs, results, automationDetails, runAggregates, baselineGuid, redactionTokens, defaultEncoding, defaultSourceLanguage, newlineSequences, columnKind, externalPropertyFileReferences, threadFlowLocations, taxonomies, addresses, translations, policies, webRequests, webResponses, specialLocations, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(stack_frame_struct, location, module, threadId, parameters, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(suppression_struct, guid, kind, state, justification, location, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(thread_flow_struct, id, message, initialState, immutableState, locations, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(thread_flow_location_struct, index, location, stack, kinds, taxa, module, state, nestingLevel, executionOrder, executionTimeUtc, importance, webRequest, webResponse, properties) - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(version_control_details_struct, repositoryUri, revisionId, branch, revisionTag, asOfTimeUtc, mappedTo, properties) } // namespace gap::sarif::definitions \ No newline at end of file diff --git a/sarif/src/definitions.cpp b/sarif/src/definitions.cpp new file mode 100644 index 0000000..277cec0 --- /dev/null +++ b/sarif/src/definitions.cpp @@ -0,0 +1,4135 @@ +// Copyright (c) 2024-present, Trail of Bits, Inc. + +#include + +namespace gap::sarif::definitions { + void from_json(const nlohmann::json &j, property_bag_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "tags" ) { + std::vector field; + val.get_to(field); + o.tags = field; + continue; + } + val.get_to(o.additional_properties[key]); + } + } + void to_json(nlohmann::json &j, const property_bag_struct &o) { + if ( o.tags.has_value() ) { + j["tags"] = *o.tags; + } + for ( auto &[key, val] : o.additional_properties ) { + j[key] = val; + } + } + void from_json(const nlohmann::json &j, root_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "version" ) { + val.get_to(o.version); + continue; + } + if ( key == "runs" ) { + val.get_to(o.runs); + continue; + } + if ( key == "inlineExternalProperties" ) { + std::vector field; + val.get_to(field); + o.inlineExternalProperties = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const root_struct &o) { + j["version"] = o.version; + j["runs"] = o.runs; + if ( o.inlineExternalProperties.has_value() ) { + j["inlineExternalProperties"] = *o.inlineExternalProperties; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, address_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "absoluteAddress" ) { + int64_t field; + val.get_to(field); + o.absoluteAddress = field; + continue; + } + if ( key == "relativeAddress" ) { + int64_t field; + val.get_to(field); + o.relativeAddress = field; + continue; + } + if ( key == "length" ) { + int64_t field; + val.get_to(field); + o.length = field; + continue; + } + if ( key == "kind" ) { + std::string field; + val.get_to(field); + o.kind = field; + continue; + } + if ( key == "name" ) { + std::string field; + val.get_to(field); + o.name = field; + continue; + } + if ( key == "fullyQualifiedName" ) { + std::string field; + val.get_to(field); + o.fullyQualifiedName = field; + continue; + } + if ( key == "offsetFromParent" ) { + int64_t field; + val.get_to(field); + o.offsetFromParent = field; + continue; + } + if ( key == "index" ) { + int64_t field; + val.get_to(field); + o.index = field; + continue; + } + if ( key == "parentIndex" ) { + int64_t field; + val.get_to(field); + o.parentIndex = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const address_struct &o) { + if ( o.absoluteAddress.has_value() ) { + j["absoluteAddress"] = *o.absoluteAddress; + } + if ( o.relativeAddress.has_value() ) { + j["relativeAddress"] = *o.relativeAddress; + } + if ( o.length.has_value() ) { + j["length"] = *o.length; + } + if ( o.kind.has_value() ) { + j["kind"] = *o.kind; + } + if ( o.name.has_value() ) { + j["name"] = *o.name; + } + if ( o.fullyQualifiedName.has_value() ) { + j["fullyQualifiedName"] = *o.fullyQualifiedName; + } + if ( o.offsetFromParent.has_value() ) { + j["offsetFromParent"] = *o.offsetFromParent; + } + if ( o.index.has_value() ) { + j["index"] = *o.index; + } + if ( o.parentIndex.has_value() ) { + j["parentIndex"] = *o.parentIndex; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, message_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "text" ) { + std::string field; + val.get_to(field); + o.text = field; + continue; + } + if ( key == "markdown" ) { + std::string field; + val.get_to(field); + o.markdown = field; + continue; + } + if ( key == "id" ) { + std::string field; + val.get_to(field); + o.id = field; + continue; + } + if ( key == "arguments" ) { + std::vector field; + val.get_to(field); + o.arguments = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const message_struct &o) { + if ( o.text.has_value() ) { + j["text"] = *o.text; + } + if ( o.markdown.has_value() ) { + j["markdown"] = *o.markdown; + } + if ( o.id.has_value() ) { + j["id"] = *o.id; + } + if ( o.arguments.has_value() ) { + j["arguments"] = *o.arguments; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, artifact_location_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "uri" ) { + std::string field; + val.get_to(field); + o.uri = field; + continue; + } + if ( key == "uriBaseId" ) { + std::string field; + val.get_to(field); + o.uriBaseId = field; + continue; + } + if ( key == "index" ) { + int64_t field; + val.get_to(field); + o.index = field; + continue; + } + if ( key == "description" ) { + message_struct field; + val.get_to(field); + o.description = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const artifact_location_struct &o) { + if ( o.uri.has_value() ) { + j["uri"] = *o.uri; + } + if ( o.uriBaseId.has_value() ) { + j["uriBaseId"] = *o.uriBaseId; + } + if ( o.index.has_value() ) { + j["index"] = *o.index; + } + if ( o.description.has_value() ) { + j["description"] = *o.description; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, multiformat_message_string_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "text" ) { + val.get_to(o.text); + continue; + } + if ( key == "markdown" ) { + std::string field; + val.get_to(field); + o.markdown = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const multiformat_message_string_struct &o) { + j["text"] = o.text; + if ( o.markdown.has_value() ) { + j["markdown"] = *o.markdown; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, artifact_content_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "text" ) { + std::string field; + val.get_to(field); + o.text = field; + continue; + } + if ( key == "binary" ) { + std::string field; + val.get_to(field); + o.binary = field; + continue; + } + if ( key == "rendered" ) { + multiformat_message_string_struct field; + val.get_to(field); + o.rendered = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const artifact_content_struct &o) { + if ( o.text.has_value() ) { + j["text"] = *o.text; + } + if ( o.binary.has_value() ) { + j["binary"] = *o.binary; + } + if ( o.rendered.has_value() ) { + j["rendered"] = *o.rendered; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, artifact_hashes_struct &o) { + for( auto &[key, val] : j.items() ) { + val.get_to(o.additional_properties[key]); + } + } + void to_json(nlohmann::json &j, const artifact_hashes_struct &o) { + for ( auto &[key, val] : o.additional_properties ) { + j[key] = val; + } + } + void from_json(const nlohmann::json &j, artifact_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "description" ) { + message_struct field; + val.get_to(field); + o.description = field; + continue; + } + if ( key == "location" ) { + artifact_location_struct field; + val.get_to(field); + o.location = field; + continue; + } + if ( key == "parentIndex" ) { + int64_t field; + val.get_to(field); + o.parentIndex = field; + continue; + } + if ( key == "offset" ) { + int64_t field; + val.get_to(field); + o.offset = field; + continue; + } + if ( key == "length" ) { + int64_t field; + val.get_to(field); + o.length = field; + continue; + } + if ( key == "roles" ) { + std::vector field; + val.get_to(field); + o.roles = field; + continue; + } + if ( key == "mimeType" ) { + std::string field; + val.get_to(field); + o.mimeType = field; + continue; + } + if ( key == "contents" ) { + artifact_content_struct field; + val.get_to(field); + o.contents = field; + continue; + } + if ( key == "encoding" ) { + std::string field; + val.get_to(field); + o.encoding = field; + continue; + } + if ( key == "sourceLanguage" ) { + std::string field; + val.get_to(field); + o.sourceLanguage = field; + continue; + } + if ( key == "hashes" ) { + artifact_hashes_struct field; + val.get_to(field); + o.hashes = field; + continue; + } + if ( key == "lastModifiedTimeUtc" ) { + std::string field; + val.get_to(field); + o.lastModifiedTimeUtc = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const artifact_struct &o) { + if ( o.description.has_value() ) { + j["description"] = *o.description; + } + if ( o.location.has_value() ) { + j["location"] = *o.location; + } + if ( o.parentIndex.has_value() ) { + j["parentIndex"] = *o.parentIndex; + } + if ( o.offset.has_value() ) { + j["offset"] = *o.offset; + } + if ( o.length.has_value() ) { + j["length"] = *o.length; + } + if ( o.roles.has_value() ) { + j["roles"] = *o.roles; + } + if ( o.mimeType.has_value() ) { + j["mimeType"] = *o.mimeType; + } + if ( o.contents.has_value() ) { + j["contents"] = *o.contents; + } + if ( o.encoding.has_value() ) { + j["encoding"] = *o.encoding; + } + if ( o.sourceLanguage.has_value() ) { + j["sourceLanguage"] = *o.sourceLanguage; + } + if ( o.hashes.has_value() ) { + j["hashes"] = *o.hashes; + } + if ( o.lastModifiedTimeUtc.has_value() ) { + j["lastModifiedTimeUtc"] = *o.lastModifiedTimeUtc; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, artifact_change_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "artifactLocation" ) { + val.get_to(o.artifactLocation); + continue; + } + if ( key == "replacements" ) { + val.get_to(o.replacements); + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const artifact_change_struct &o) { + j["artifactLocation"] = o.artifactLocation; + j["replacements"] = o.replacements; + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, attachment_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "description" ) { + message_struct field; + val.get_to(field); + o.description = field; + continue; + } + if ( key == "artifactLocation" ) { + val.get_to(o.artifactLocation); + continue; + } + if ( key == "regions" ) { + std::vector field; + val.get_to(field); + o.regions = field; + continue; + } + if ( key == "rectangles" ) { + std::vector field; + val.get_to(field); + o.rectangles = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const attachment_struct &o) { + if ( o.description.has_value() ) { + j["description"] = *o.description; + } + j["artifactLocation"] = o.artifactLocation; + if ( o.regions.has_value() ) { + j["regions"] = *o.regions; + } + if ( o.rectangles.has_value() ) { + j["rectangles"] = *o.rectangles; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, code_flow_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "message" ) { + message_struct field; + val.get_to(field); + o.message = field; + continue; + } + if ( key == "threadFlows" ) { + val.get_to(o.threadFlows); + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const code_flow_struct &o) { + if ( o.message.has_value() ) { + j["message"] = *o.message; + } + j["threadFlows"] = o.threadFlows; + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, reporting_configuration_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "enabled" ) { + bool field; + val.get_to(field); + o.enabled = field; + continue; + } + if ( key == "level" ) { + level_enum field; + val.get_to(field); + o.level = field; + continue; + } + if ( key == "rank" ) { + double field; + val.get_to(field); + o.rank = field; + continue; + } + if ( key == "parameters" ) { + property_bag_struct field; + val.get_to(field); + o.parameters = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const reporting_configuration_struct &o) { + if ( o.enabled.has_value() ) { + j["enabled"] = *o.enabled; + } + if ( o.level.has_value() ) { + j["level"] = *o.level; + } + if ( o.rank.has_value() ) { + j["rank"] = *o.rank; + } + if ( o.parameters.has_value() ) { + j["parameters"] = *o.parameters; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, tool_component_reference_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "name" ) { + std::string field; + val.get_to(field); + o.name = field; + continue; + } + if ( key == "index" ) { + int64_t field; + val.get_to(field); + o.index = field; + continue; + } + if ( key == "guid" ) { + std::string field; + val.get_to(field); + o.guid = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const tool_component_reference_struct &o) { + if ( o.name.has_value() ) { + j["name"] = *o.name; + } + if ( o.index.has_value() ) { + j["index"] = *o.index; + } + if ( o.guid.has_value() ) { + j["guid"] = *o.guid; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, reporting_descriptor_reference_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "id" ) { + std::string field; + val.get_to(field); + o.id = field; + continue; + } + if ( key == "index" ) { + int64_t field; + val.get_to(field); + o.index = field; + continue; + } + if ( key == "guid" ) { + std::string field; + val.get_to(field); + o.guid = field; + continue; + } + if ( key == "toolComponent" ) { + tool_component_reference_struct field; + val.get_to(field); + o.toolComponent = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const reporting_descriptor_reference_struct &o) { + if ( o.id.has_value() ) { + j["id"] = *o.id; + } + if ( o.index.has_value() ) { + j["index"] = *o.index; + } + if ( o.guid.has_value() ) { + j["guid"] = *o.guid; + } + if ( o.toolComponent.has_value() ) { + j["toolComponent"] = *o.toolComponent; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, configuration_override_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "configuration" ) { + val.get_to(o.configuration); + continue; + } + if ( key == "descriptor" ) { + val.get_to(o.descriptor); + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const configuration_override_struct &o) { + j["configuration"] = o.configuration; + j["descriptor"] = o.descriptor; + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, tool_component_global_message_strings_struct &o) { + for( auto &[key, val] : j.items() ) { + val.get_to(o.additional_properties[key]); + } + } + void to_json(nlohmann::json &j, const tool_component_global_message_strings_struct &o) { + for ( auto &[key, val] : o.additional_properties ) { + j[key] = val; + } + } + void from_json(const nlohmann::json &j, translation_metadata_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "name" ) { + val.get_to(o.name); + continue; + } + if ( key == "fullName" ) { + std::string field; + val.get_to(field); + o.fullName = field; + continue; + } + if ( key == "shortDescription" ) { + multiformat_message_string_struct field; + val.get_to(field); + o.shortDescription = field; + continue; + } + if ( key == "fullDescription" ) { + multiformat_message_string_struct field; + val.get_to(field); + o.fullDescription = field; + continue; + } + if ( key == "downloadUri" ) { + std::string field; + val.get_to(field); + o.downloadUri = field; + continue; + } + if ( key == "informationUri" ) { + std::string field; + val.get_to(field); + o.informationUri = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const translation_metadata_struct &o) { + j["name"] = o.name; + if ( o.fullName.has_value() ) { + j["fullName"] = *o.fullName; + } + if ( o.shortDescription.has_value() ) { + j["shortDescription"] = *o.shortDescription; + } + if ( o.fullDescription.has_value() ) { + j["fullDescription"] = *o.fullDescription; + } + if ( o.downloadUri.has_value() ) { + j["downloadUri"] = *o.downloadUri; + } + if ( o.informationUri.has_value() ) { + j["informationUri"] = *o.informationUri; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, tool_component_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "guid" ) { + std::string field; + val.get_to(field); + o.guid = field; + continue; + } + if ( key == "name" ) { + val.get_to(o.name); + continue; + } + if ( key == "organization" ) { + std::string field; + val.get_to(field); + o.organization = field; + continue; + } + if ( key == "product" ) { + std::string field; + val.get_to(field); + o.product = field; + continue; + } + if ( key == "productSuite" ) { + std::string field; + val.get_to(field); + o.productSuite = field; + continue; + } + if ( key == "shortDescription" ) { + multiformat_message_string_struct field; + val.get_to(field); + o.shortDescription = field; + continue; + } + if ( key == "fullDescription" ) { + multiformat_message_string_struct field; + val.get_to(field); + o.fullDescription = field; + continue; + } + if ( key == "fullName" ) { + std::string field; + val.get_to(field); + o.fullName = field; + continue; + } + if ( key == "version" ) { + std::string field; + val.get_to(field); + o.version = field; + continue; + } + if ( key == "semanticVersion" ) { + std::string field; + val.get_to(field); + o.semanticVersion = field; + continue; + } + if ( key == "dottedQuadFileVersion" ) { + std::string field; + val.get_to(field); + o.dottedQuadFileVersion = field; + continue; + } + if ( key == "releaseDateUtc" ) { + std::string field; + val.get_to(field); + o.releaseDateUtc = field; + continue; + } + if ( key == "downloadUri" ) { + std::string field; + val.get_to(field); + o.downloadUri = field; + continue; + } + if ( key == "informationUri" ) { + std::string field; + val.get_to(field); + o.informationUri = field; + continue; + } + if ( key == "globalMessageStrings" ) { + tool_component_global_message_strings_struct field; + val.get_to(field); + o.globalMessageStrings = field; + continue; + } + if ( key == "notifications" ) { + std::vector field; + val.get_to(field); + o.notifications = field; + continue; + } + if ( key == "rules" ) { + std::vector field; + val.get_to(field); + o.rules = field; + continue; + } + if ( key == "taxa" ) { + std::vector field; + val.get_to(field); + o.taxa = field; + continue; + } + if ( key == "locations" ) { + std::vector field; + val.get_to(field); + o.locations = field; + continue; + } + if ( key == "language" ) { + std::string field; + val.get_to(field); + o.language = field; + continue; + } + if ( key == "contents" ) { + std::vector field; + val.get_to(field); + o.contents = field; + continue; + } + if ( key == "isComprehensive" ) { + bool field; + val.get_to(field); + o.isComprehensive = field; + continue; + } + if ( key == "localizedDataSemanticVersion" ) { + std::string field; + val.get_to(field); + o.localizedDataSemanticVersion = field; + continue; + } + if ( key == "minimumRequiredLocalizedDataSemanticVersion" ) { + std::string field; + val.get_to(field); + o.minimumRequiredLocalizedDataSemanticVersion = field; + continue; + } + if ( key == "associatedComponent" ) { + tool_component_reference_struct field; + val.get_to(field); + o.associatedComponent = field; + continue; + } + if ( key == "translationMetadata" ) { + translation_metadata_struct field; + val.get_to(field); + o.translationMetadata = field; + continue; + } + if ( key == "supportedTaxonomies" ) { + std::vector field; + val.get_to(field); + o.supportedTaxonomies = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const tool_component_struct &o) { + if ( o.guid.has_value() ) { + j["guid"] = *o.guid; + } + j["name"] = o.name; + if ( o.organization.has_value() ) { + j["organization"] = *o.organization; + } + if ( o.product.has_value() ) { + j["product"] = *o.product; + } + if ( o.productSuite.has_value() ) { + j["productSuite"] = *o.productSuite; + } + if ( o.shortDescription.has_value() ) { + j["shortDescription"] = *o.shortDescription; + } + if ( o.fullDescription.has_value() ) { + j["fullDescription"] = *o.fullDescription; + } + if ( o.fullName.has_value() ) { + j["fullName"] = *o.fullName; + } + if ( o.version.has_value() ) { + j["version"] = *o.version; + } + if ( o.semanticVersion.has_value() ) { + j["semanticVersion"] = *o.semanticVersion; + } + if ( o.dottedQuadFileVersion.has_value() ) { + j["dottedQuadFileVersion"] = *o.dottedQuadFileVersion; + } + if ( o.releaseDateUtc.has_value() ) { + j["releaseDateUtc"] = *o.releaseDateUtc; + } + if ( o.downloadUri.has_value() ) { + j["downloadUri"] = *o.downloadUri; + } + if ( o.informationUri.has_value() ) { + j["informationUri"] = *o.informationUri; + } + if ( o.globalMessageStrings.has_value() ) { + j["globalMessageStrings"] = *o.globalMessageStrings; + } + if ( o.notifications.has_value() ) { + j["notifications"] = *o.notifications; + } + if ( o.rules.has_value() ) { + j["rules"] = *o.rules; + } + if ( o.taxa.has_value() ) { + j["taxa"] = *o.taxa; + } + if ( o.locations.has_value() ) { + j["locations"] = *o.locations; + } + if ( o.language.has_value() ) { + j["language"] = *o.language; + } + if ( o.contents.has_value() ) { + j["contents"] = *o.contents; + } + if ( o.isComprehensive.has_value() ) { + j["isComprehensive"] = *o.isComprehensive; + } + if ( o.localizedDataSemanticVersion.has_value() ) { + j["localizedDataSemanticVersion"] = *o.localizedDataSemanticVersion; + } + if ( o.minimumRequiredLocalizedDataSemanticVersion.has_value() ) { + j["minimumRequiredLocalizedDataSemanticVersion"] = *o.minimumRequiredLocalizedDataSemanticVersion; + } + if ( o.associatedComponent.has_value() ) { + j["associatedComponent"] = *o.associatedComponent; + } + if ( o.translationMetadata.has_value() ) { + j["translationMetadata"] = *o.translationMetadata; + } + if ( o.supportedTaxonomies.has_value() ) { + j["supportedTaxonomies"] = *o.supportedTaxonomies; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, tool_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "driver" ) { + val.get_to(o.driver); + continue; + } + if ( key == "extensions" ) { + std::vector field; + val.get_to(field); + o.extensions = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const tool_struct &o) { + j["driver"] = o.driver; + if ( o.extensions.has_value() ) { + j["extensions"] = *o.extensions; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, invocation_environment_variables_struct &o) { + for( auto &[key, val] : j.items() ) { + val.get_to(o.additional_properties[key]); + } + } + void to_json(nlohmann::json &j, const invocation_environment_variables_struct &o) { + for ( auto &[key, val] : o.additional_properties ) { + j[key] = val; + } + } + void from_json(const nlohmann::json &j, invocation_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "commandLine" ) { + std::string field; + val.get_to(field); + o.commandLine = field; + continue; + } + if ( key == "arguments" ) { + std::vector field; + val.get_to(field); + o.arguments = field; + continue; + } + if ( key == "responseFiles" ) { + std::vector field; + val.get_to(field); + o.responseFiles = field; + continue; + } + if ( key == "startTimeUtc" ) { + std::string field; + val.get_to(field); + o.startTimeUtc = field; + continue; + } + if ( key == "endTimeUtc" ) { + std::string field; + val.get_to(field); + o.endTimeUtc = field; + continue; + } + if ( key == "exitCode" ) { + int64_t field; + val.get_to(field); + o.exitCode = field; + continue; + } + if ( key == "ruleConfigurationOverrides" ) { + std::vector field; + val.get_to(field); + o.ruleConfigurationOverrides = field; + continue; + } + if ( key == "notificationConfigurationOverrides" ) { + std::vector field; + val.get_to(field); + o.notificationConfigurationOverrides = field; + continue; + } + if ( key == "toolExecutionNotifications" ) { + std::vector field; + val.get_to(field); + o.toolExecutionNotifications = field; + continue; + } + if ( key == "toolConfigurationNotifications" ) { + std::vector field; + val.get_to(field); + o.toolConfigurationNotifications = field; + continue; + } + if ( key == "exitCodeDescription" ) { + std::string field; + val.get_to(field); + o.exitCodeDescription = field; + continue; + } + if ( key == "exitSignalName" ) { + std::string field; + val.get_to(field); + o.exitSignalName = field; + continue; + } + if ( key == "exitSignalNumber" ) { + int64_t field; + val.get_to(field); + o.exitSignalNumber = field; + continue; + } + if ( key == "processStartFailureMessage" ) { + std::string field; + val.get_to(field); + o.processStartFailureMessage = field; + continue; + } + if ( key == "executionSuccessful" ) { + val.get_to(o.executionSuccessful); + continue; + } + if ( key == "machine" ) { + std::string field; + val.get_to(field); + o.machine = field; + continue; + } + if ( key == "account" ) { + std::string field; + val.get_to(field); + o.account = field; + continue; + } + if ( key == "processId" ) { + int64_t field; + val.get_to(field); + o.processId = field; + continue; + } + if ( key == "executableLocation" ) { + artifact_location_struct field; + val.get_to(field); + o.executableLocation = field; + continue; + } + if ( key == "workingDirectory" ) { + artifact_location_struct field; + val.get_to(field); + o.workingDirectory = field; + continue; + } + if ( key == "environmentVariables" ) { + invocation_environment_variables_struct field; + val.get_to(field); + o.environmentVariables = field; + continue; + } + if ( key == "stdin" ) { + artifact_location_struct field; + val.get_to(field); + o.stdin = field; + continue; + } + if ( key == "stdout" ) { + artifact_location_struct field; + val.get_to(field); + o.stdout = field; + continue; + } + if ( key == "stderr" ) { + artifact_location_struct field; + val.get_to(field); + o.stderr = field; + continue; + } + if ( key == "stdoutStderr" ) { + artifact_location_struct field; + val.get_to(field); + o.stdoutStderr = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const invocation_struct &o) { + if ( o.commandLine.has_value() ) { + j["commandLine"] = *o.commandLine; + } + if ( o.arguments.has_value() ) { + j["arguments"] = *o.arguments; + } + if ( o.responseFiles.has_value() ) { + j["responseFiles"] = *o.responseFiles; + } + if ( o.startTimeUtc.has_value() ) { + j["startTimeUtc"] = *o.startTimeUtc; + } + if ( o.endTimeUtc.has_value() ) { + j["endTimeUtc"] = *o.endTimeUtc; + } + if ( o.exitCode.has_value() ) { + j["exitCode"] = *o.exitCode; + } + if ( o.ruleConfigurationOverrides.has_value() ) { + j["ruleConfigurationOverrides"] = *o.ruleConfigurationOverrides; + } + if ( o.notificationConfigurationOverrides.has_value() ) { + j["notificationConfigurationOverrides"] = *o.notificationConfigurationOverrides; + } + if ( o.toolExecutionNotifications.has_value() ) { + j["toolExecutionNotifications"] = *o.toolExecutionNotifications; + } + if ( o.toolConfigurationNotifications.has_value() ) { + j["toolConfigurationNotifications"] = *o.toolConfigurationNotifications; + } + if ( o.exitCodeDescription.has_value() ) { + j["exitCodeDescription"] = *o.exitCodeDescription; + } + if ( o.exitSignalName.has_value() ) { + j["exitSignalName"] = *o.exitSignalName; + } + if ( o.exitSignalNumber.has_value() ) { + j["exitSignalNumber"] = *o.exitSignalNumber; + } + if ( o.processStartFailureMessage.has_value() ) { + j["processStartFailureMessage"] = *o.processStartFailureMessage; + } + j["executionSuccessful"] = o.executionSuccessful; + if ( o.machine.has_value() ) { + j["machine"] = *o.machine; + } + if ( o.account.has_value() ) { + j["account"] = *o.account; + } + if ( o.processId.has_value() ) { + j["processId"] = *o.processId; + } + if ( o.executableLocation.has_value() ) { + j["executableLocation"] = *o.executableLocation; + } + if ( o.workingDirectory.has_value() ) { + j["workingDirectory"] = *o.workingDirectory; + } + if ( o.environmentVariables.has_value() ) { + j["environmentVariables"] = *o.environmentVariables; + } + if ( o.stdin.has_value() ) { + j["stdin"] = *o.stdin; + } + if ( o.stdout.has_value() ) { + j["stdout"] = *o.stdout; + } + if ( o.stderr.has_value() ) { + j["stderr"] = *o.stderr; + } + if ( o.stdoutStderr.has_value() ) { + j["stdoutStderr"] = *o.stdoutStderr; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, conversion_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "tool" ) { + val.get_to(o.tool); + continue; + } + if ( key == "invocation" ) { + invocation_struct field; + val.get_to(field); + o.invocation = field; + continue; + } + if ( key == "analysisToolLogFiles" ) { + std::vector field; + val.get_to(field); + o.analysisToolLogFiles = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const conversion_struct &o) { + j["tool"] = o.tool; + if ( o.invocation.has_value() ) { + j["invocation"] = *o.invocation; + } + if ( o.analysisToolLogFiles.has_value() ) { + j["analysisToolLogFiles"] = *o.analysisToolLogFiles; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, edge_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "id" ) { + val.get_to(o.id); + continue; + } + if ( key == "label" ) { + message_struct field; + val.get_to(field); + o.label = field; + continue; + } + if ( key == "sourceNodeId" ) { + val.get_to(o.sourceNodeId); + continue; + } + if ( key == "targetNodeId" ) { + val.get_to(o.targetNodeId); + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const edge_struct &o) { + j["id"] = o.id; + if ( o.label.has_value() ) { + j["label"] = *o.label; + } + j["sourceNodeId"] = o.sourceNodeId; + j["targetNodeId"] = o.targetNodeId; + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, edge_traversal_final_state_struct &o) { + for( auto &[key, val] : j.items() ) { + val.get_to(o.additional_properties[key]); + } + } + void to_json(nlohmann::json &j, const edge_traversal_final_state_struct &o) { + for ( auto &[key, val] : o.additional_properties ) { + j[key] = val; + } + } + void from_json(const nlohmann::json &j, edge_traversal_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "edgeId" ) { + val.get_to(o.edgeId); + continue; + } + if ( key == "message" ) { + message_struct field; + val.get_to(field); + o.message = field; + continue; + } + if ( key == "finalState" ) { + edge_traversal_final_state_struct field; + val.get_to(field); + o.finalState = field; + continue; + } + if ( key == "stepOverEdgeCount" ) { + int64_t field; + val.get_to(field); + o.stepOverEdgeCount = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const edge_traversal_struct &o) { + j["edgeId"] = o.edgeId; + if ( o.message.has_value() ) { + j["message"] = *o.message; + } + if ( o.finalState.has_value() ) { + j["finalState"] = *o.finalState; + } + if ( o.stepOverEdgeCount.has_value() ) { + j["stepOverEdgeCount"] = *o.stepOverEdgeCount; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, stack_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "message" ) { + message_struct field; + val.get_to(field); + o.message = field; + continue; + } + if ( key == "frames" ) { + val.get_to(o.frames); + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const stack_struct &o) { + if ( o.message.has_value() ) { + j["message"] = *o.message; + } + j["frames"] = o.frames; + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, exception_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "kind" ) { + std::string field; + val.get_to(field); + o.kind = field; + continue; + } + if ( key == "message" ) { + std::string field; + val.get_to(field); + o.message = field; + continue; + } + if ( key == "stack" ) { + stack_struct field; + val.get_to(field); + o.stack = field; + continue; + } + if ( key == "innerExceptions" ) { + std::vector field; + val.get_to(field); + o.innerExceptions = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const exception_struct &o) { + if ( o.kind.has_value() ) { + j["kind"] = *o.kind; + } + if ( o.message.has_value() ) { + j["message"] = *o.message; + } + if ( o.stack.has_value() ) { + j["stack"] = *o.stack; + } + if ( o.innerExceptions.has_value() ) { + j["innerExceptions"] = *o.innerExceptions; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, external_properties_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "schema" ) { + std::string field; + val.get_to(field); + o.schema = field; + continue; + } + if ( key == "version" ) { + version_enum field; + val.get_to(field); + o.version = field; + continue; + } + if ( key == "guid" ) { + std::string field; + val.get_to(field); + o.guid = field; + continue; + } + if ( key == "runGuid" ) { + std::string field; + val.get_to(field); + o.runGuid = field; + continue; + } + if ( key == "conversion" ) { + conversion_struct field; + val.get_to(field); + o.conversion = field; + continue; + } + if ( key == "graphs" ) { + std::vector field; + val.get_to(field); + o.graphs = field; + continue; + } + if ( key == "externalizedProperties" ) { + property_bag_struct field; + val.get_to(field); + o.externalizedProperties = field; + continue; + } + if ( key == "artifacts" ) { + std::vector field; + val.get_to(field); + o.artifacts = field; + continue; + } + if ( key == "invocations" ) { + std::vector field; + val.get_to(field); + o.invocations = field; + continue; + } + if ( key == "logicalLocations" ) { + std::vector field; + val.get_to(field); + o.logicalLocations = field; + continue; + } + if ( key == "threadFlowLocations" ) { + std::vector field; + val.get_to(field); + o.threadFlowLocations = field; + continue; + } + if ( key == "results" ) { + std::vector field; + val.get_to(field); + o.results = field; + continue; + } + if ( key == "taxonomies" ) { + std::vector field; + val.get_to(field); + o.taxonomies = field; + continue; + } + if ( key == "driver" ) { + tool_component_struct field; + val.get_to(field); + o.driver = field; + continue; + } + if ( key == "extensions" ) { + std::vector field; + val.get_to(field); + o.extensions = field; + continue; + } + if ( key == "policies" ) { + std::vector field; + val.get_to(field); + o.policies = field; + continue; + } + if ( key == "translations" ) { + std::vector field; + val.get_to(field); + o.translations = field; + continue; + } + if ( key == "addresses" ) { + std::vector field; + val.get_to(field); + o.addresses = field; + continue; + } + if ( key == "webRequests" ) { + std::vector field; + val.get_to(field); + o.webRequests = field; + continue; + } + if ( key == "webResponses" ) { + std::vector field; + val.get_to(field); + o.webResponses = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const external_properties_struct &o) { + if ( o.schema.has_value() ) { + j["schema"] = *o.schema; + } + if ( o.version.has_value() ) { + j["version"] = *o.version; + } + if ( o.guid.has_value() ) { + j["guid"] = *o.guid; + } + if ( o.runGuid.has_value() ) { + j["runGuid"] = *o.runGuid; + } + if ( o.conversion.has_value() ) { + j["conversion"] = *o.conversion; + } + if ( o.graphs.has_value() ) { + j["graphs"] = *o.graphs; + } + if ( o.externalizedProperties.has_value() ) { + j["externalizedProperties"] = *o.externalizedProperties; + } + if ( o.artifacts.has_value() ) { + j["artifacts"] = *o.artifacts; + } + if ( o.invocations.has_value() ) { + j["invocations"] = *o.invocations; + } + if ( o.logicalLocations.has_value() ) { + j["logicalLocations"] = *o.logicalLocations; + } + if ( o.threadFlowLocations.has_value() ) { + j["threadFlowLocations"] = *o.threadFlowLocations; + } + if ( o.results.has_value() ) { + j["results"] = *o.results; + } + if ( o.taxonomies.has_value() ) { + j["taxonomies"] = *o.taxonomies; + } + if ( o.driver.has_value() ) { + j["driver"] = *o.driver; + } + if ( o.extensions.has_value() ) { + j["extensions"] = *o.extensions; + } + if ( o.policies.has_value() ) { + j["policies"] = *o.policies; + } + if ( o.translations.has_value() ) { + j["translations"] = *o.translations; + } + if ( o.addresses.has_value() ) { + j["addresses"] = *o.addresses; + } + if ( o.webRequests.has_value() ) { + j["webRequests"] = *o.webRequests; + } + if ( o.webResponses.has_value() ) { + j["webResponses"] = *o.webResponses; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, external_property_file_reference_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "location" ) { + artifact_location_struct field; + val.get_to(field); + o.location = field; + continue; + } + if ( key == "guid" ) { + std::string field; + val.get_to(field); + o.guid = field; + continue; + } + if ( key == "itemCount" ) { + int64_t field; + val.get_to(field); + o.itemCount = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const external_property_file_reference_struct &o) { + if ( o.location.has_value() ) { + j["location"] = *o.location; + } + if ( o.guid.has_value() ) { + j["guid"] = *o.guid; + } + if ( o.itemCount.has_value() ) { + j["itemCount"] = *o.itemCount; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, external_property_file_references_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "conversion" ) { + external_property_file_reference_struct field; + val.get_to(field); + o.conversion = field; + continue; + } + if ( key == "graphs" ) { + std::vector field; + val.get_to(field); + o.graphs = field; + continue; + } + if ( key == "externalizedProperties" ) { + external_property_file_reference_struct field; + val.get_to(field); + o.externalizedProperties = field; + continue; + } + if ( key == "artifacts" ) { + std::vector field; + val.get_to(field); + o.artifacts = field; + continue; + } + if ( key == "invocations" ) { + std::vector field; + val.get_to(field); + o.invocations = field; + continue; + } + if ( key == "logicalLocations" ) { + std::vector field; + val.get_to(field); + o.logicalLocations = field; + continue; + } + if ( key == "threadFlowLocations" ) { + std::vector field; + val.get_to(field); + o.threadFlowLocations = field; + continue; + } + if ( key == "results" ) { + std::vector field; + val.get_to(field); + o.results = field; + continue; + } + if ( key == "taxonomies" ) { + std::vector field; + val.get_to(field); + o.taxonomies = field; + continue; + } + if ( key == "addresses" ) { + std::vector field; + val.get_to(field); + o.addresses = field; + continue; + } + if ( key == "driver" ) { + external_property_file_reference_struct field; + val.get_to(field); + o.driver = field; + continue; + } + if ( key == "extensions" ) { + std::vector field; + val.get_to(field); + o.extensions = field; + continue; + } + if ( key == "policies" ) { + std::vector field; + val.get_to(field); + o.policies = field; + continue; + } + if ( key == "translations" ) { + std::vector field; + val.get_to(field); + o.translations = field; + continue; + } + if ( key == "webRequests" ) { + std::vector field; + val.get_to(field); + o.webRequests = field; + continue; + } + if ( key == "webResponses" ) { + std::vector field; + val.get_to(field); + o.webResponses = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const external_property_file_references_struct &o) { + if ( o.conversion.has_value() ) { + j["conversion"] = *o.conversion; + } + if ( o.graphs.has_value() ) { + j["graphs"] = *o.graphs; + } + if ( o.externalizedProperties.has_value() ) { + j["externalizedProperties"] = *o.externalizedProperties; + } + if ( o.artifacts.has_value() ) { + j["artifacts"] = *o.artifacts; + } + if ( o.invocations.has_value() ) { + j["invocations"] = *o.invocations; + } + if ( o.logicalLocations.has_value() ) { + j["logicalLocations"] = *o.logicalLocations; + } + if ( o.threadFlowLocations.has_value() ) { + j["threadFlowLocations"] = *o.threadFlowLocations; + } + if ( o.results.has_value() ) { + j["results"] = *o.results; + } + if ( o.taxonomies.has_value() ) { + j["taxonomies"] = *o.taxonomies; + } + if ( o.addresses.has_value() ) { + j["addresses"] = *o.addresses; + } + if ( o.driver.has_value() ) { + j["driver"] = *o.driver; + } + if ( o.extensions.has_value() ) { + j["extensions"] = *o.extensions; + } + if ( o.policies.has_value() ) { + j["policies"] = *o.policies; + } + if ( o.translations.has_value() ) { + j["translations"] = *o.translations; + } + if ( o.webRequests.has_value() ) { + j["webRequests"] = *o.webRequests; + } + if ( o.webResponses.has_value() ) { + j["webResponses"] = *o.webResponses; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, fix_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "description" ) { + message_struct field; + val.get_to(field); + o.description = field; + continue; + } + if ( key == "artifactChanges" ) { + val.get_to(o.artifactChanges); + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const fix_struct &o) { + if ( o.description.has_value() ) { + j["description"] = *o.description; + } + j["artifactChanges"] = o.artifactChanges; + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, graph_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "description" ) { + message_struct field; + val.get_to(field); + o.description = field; + continue; + } + if ( key == "nodes" ) { + std::vector field; + val.get_to(field); + o.nodes = field; + continue; + } + if ( key == "edges" ) { + std::vector field; + val.get_to(field); + o.edges = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const graph_struct &o) { + if ( o.description.has_value() ) { + j["description"] = *o.description; + } + if ( o.nodes.has_value() ) { + j["nodes"] = *o.nodes; + } + if ( o.edges.has_value() ) { + j["edges"] = *o.edges; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, graph_traversal_initial_state_struct &o) { + for( auto &[key, val] : j.items() ) { + val.get_to(o.additional_properties[key]); + } + } + void to_json(nlohmann::json &j, const graph_traversal_initial_state_struct &o) { + for ( auto &[key, val] : o.additional_properties ) { + j[key] = val; + } + } + void from_json(const nlohmann::json &j, graph_traversal_immutable_state_struct &o) { + for( auto &[key, val] : j.items() ) { + val.get_to(o.additional_properties[key]); + } + } + void to_json(nlohmann::json &j, const graph_traversal_immutable_state_struct &o) { + for ( auto &[key, val] : o.additional_properties ) { + j[key] = val; + } + } + void from_json(const nlohmann::json &j, graph_traversal_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "runGraphIndex" ) { + int64_t field; + val.get_to(field); + o.runGraphIndex = field; + continue; + } + if ( key == "resultGraphIndex" ) { + int64_t field; + val.get_to(field); + o.resultGraphIndex = field; + continue; + } + if ( key == "description" ) { + message_struct field; + val.get_to(field); + o.description = field; + continue; + } + if ( key == "initialState" ) { + graph_traversal_initial_state_struct field; + val.get_to(field); + o.initialState = field; + continue; + } + if ( key == "immutableState" ) { + graph_traversal_immutable_state_struct field; + val.get_to(field); + o.immutableState = field; + continue; + } + if ( key == "edgeTraversals" ) { + std::vector field; + val.get_to(field); + o.edgeTraversals = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const graph_traversal_struct &o) { + if ( o.runGraphIndex.has_value() ) { + j["runGraphIndex"] = *o.runGraphIndex; + } + if ( o.resultGraphIndex.has_value() ) { + j["resultGraphIndex"] = *o.resultGraphIndex; + } + if ( o.description.has_value() ) { + j["description"] = *o.description; + } + if ( o.initialState.has_value() ) { + j["initialState"] = *o.initialState; + } + if ( o.immutableState.has_value() ) { + j["immutableState"] = *o.immutableState; + } + if ( o.edgeTraversals.has_value() ) { + j["edgeTraversals"] = *o.edgeTraversals; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, region_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "startLine" ) { + int64_t field; + val.get_to(field); + o.startLine = field; + continue; + } + if ( key == "startColumn" ) { + int64_t field; + val.get_to(field); + o.startColumn = field; + continue; + } + if ( key == "endLine" ) { + int64_t field; + val.get_to(field); + o.endLine = field; + continue; + } + if ( key == "endColumn" ) { + int64_t field; + val.get_to(field); + o.endColumn = field; + continue; + } + if ( key == "charOffset" ) { + int64_t field; + val.get_to(field); + o.charOffset = field; + continue; + } + if ( key == "charLength" ) { + int64_t field; + val.get_to(field); + o.charLength = field; + continue; + } + if ( key == "byteOffset" ) { + int64_t field; + val.get_to(field); + o.byteOffset = field; + continue; + } + if ( key == "byteLength" ) { + int64_t field; + val.get_to(field); + o.byteLength = field; + continue; + } + if ( key == "snippet" ) { + artifact_content_struct field; + val.get_to(field); + o.snippet = field; + continue; + } + if ( key == "message" ) { + message_struct field; + val.get_to(field); + o.message = field; + continue; + } + if ( key == "sourceLanguage" ) { + std::string field; + val.get_to(field); + o.sourceLanguage = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const region_struct &o) { + if ( o.startLine.has_value() ) { + j["startLine"] = *o.startLine; + } + if ( o.startColumn.has_value() ) { + j["startColumn"] = *o.startColumn; + } + if ( o.endLine.has_value() ) { + j["endLine"] = *o.endLine; + } + if ( o.endColumn.has_value() ) { + j["endColumn"] = *o.endColumn; + } + if ( o.charOffset.has_value() ) { + j["charOffset"] = *o.charOffset; + } + if ( o.charLength.has_value() ) { + j["charLength"] = *o.charLength; + } + if ( o.byteOffset.has_value() ) { + j["byteOffset"] = *o.byteOffset; + } + if ( o.byteLength.has_value() ) { + j["byteLength"] = *o.byteLength; + } + if ( o.snippet.has_value() ) { + j["snippet"] = *o.snippet; + } + if ( o.message.has_value() ) { + j["message"] = *o.message; + } + if ( o.sourceLanguage.has_value() ) { + j["sourceLanguage"] = *o.sourceLanguage; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, physical_location_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "address" ) { + address_struct field; + val.get_to(field); + o.address = field; + continue; + } + if ( key == "artifactLocation" ) { + artifact_location_struct field; + val.get_to(field); + o.artifactLocation = field; + continue; + } + if ( key == "region" ) { + region_struct field; + val.get_to(field); + o.region = field; + continue; + } + if ( key == "contextRegion" ) { + region_struct field; + val.get_to(field); + o.contextRegion = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const physical_location_struct &o) { + if ( o.address.has_value() ) { + j["address"] = *o.address; + } + if ( o.artifactLocation.has_value() ) { + j["artifactLocation"] = *o.artifactLocation; + } + if ( o.region.has_value() ) { + j["region"] = *o.region; + } + if ( o.contextRegion.has_value() ) { + j["contextRegion"] = *o.contextRegion; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, location_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "id" ) { + int64_t field; + val.get_to(field); + o.id = field; + continue; + } + if ( key == "physicalLocation" ) { + physical_location_struct field; + val.get_to(field); + o.physicalLocation = field; + continue; + } + if ( key == "logicalLocations" ) { + std::vector field; + val.get_to(field); + o.logicalLocations = field; + continue; + } + if ( key == "message" ) { + message_struct field; + val.get_to(field); + o.message = field; + continue; + } + if ( key == "annotations" ) { + std::vector field; + val.get_to(field); + o.annotations = field; + continue; + } + if ( key == "relationships" ) { + std::vector field; + val.get_to(field); + o.relationships = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const location_struct &o) { + if ( o.id.has_value() ) { + j["id"] = *o.id; + } + if ( o.physicalLocation.has_value() ) { + j["physicalLocation"] = *o.physicalLocation; + } + if ( o.logicalLocations.has_value() ) { + j["logicalLocations"] = *o.logicalLocations; + } + if ( o.message.has_value() ) { + j["message"] = *o.message; + } + if ( o.annotations.has_value() ) { + j["annotations"] = *o.annotations; + } + if ( o.relationships.has_value() ) { + j["relationships"] = *o.relationships; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, location_relationship_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "target" ) { + val.get_to(o.target); + continue; + } + if ( key == "kinds" ) { + std::vector field; + val.get_to(field); + o.kinds = field; + continue; + } + if ( key == "description" ) { + message_struct field; + val.get_to(field); + o.description = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const location_relationship_struct &o) { + j["target"] = o.target; + if ( o.kinds.has_value() ) { + j["kinds"] = *o.kinds; + } + if ( o.description.has_value() ) { + j["description"] = *o.description; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, logical_location_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "name" ) { + std::string field; + val.get_to(field); + o.name = field; + continue; + } + if ( key == "index" ) { + int64_t field; + val.get_to(field); + o.index = field; + continue; + } + if ( key == "fullyQualifiedName" ) { + std::string field; + val.get_to(field); + o.fullyQualifiedName = field; + continue; + } + if ( key == "decoratedName" ) { + std::string field; + val.get_to(field); + o.decoratedName = field; + continue; + } + if ( key == "parentIndex" ) { + int64_t field; + val.get_to(field); + o.parentIndex = field; + continue; + } + if ( key == "kind" ) { + std::string field; + val.get_to(field); + o.kind = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const logical_location_struct &o) { + if ( o.name.has_value() ) { + j["name"] = *o.name; + } + if ( o.index.has_value() ) { + j["index"] = *o.index; + } + if ( o.fullyQualifiedName.has_value() ) { + j["fullyQualifiedName"] = *o.fullyQualifiedName; + } + if ( o.decoratedName.has_value() ) { + j["decoratedName"] = *o.decoratedName; + } + if ( o.parentIndex.has_value() ) { + j["parentIndex"] = *o.parentIndex; + } + if ( o.kind.has_value() ) { + j["kind"] = *o.kind; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, node_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "id" ) { + val.get_to(o.id); + continue; + } + if ( key == "label" ) { + message_struct field; + val.get_to(field); + o.label = field; + continue; + } + if ( key == "location" ) { + location_struct field; + val.get_to(field); + o.location = field; + continue; + } + if ( key == "children" ) { + std::vector field; + val.get_to(field); + o.children = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const node_struct &o) { + j["id"] = o.id; + if ( o.label.has_value() ) { + j["label"] = *o.label; + } + if ( o.location.has_value() ) { + j["location"] = *o.location; + } + if ( o.children.has_value() ) { + j["children"] = *o.children; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, notification_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "locations" ) { + std::vector field; + val.get_to(field); + o.locations = field; + continue; + } + if ( key == "message" ) { + val.get_to(o.message); + continue; + } + if ( key == "level" ) { + level_enum field; + val.get_to(field); + o.level = field; + continue; + } + if ( key == "threadId" ) { + int64_t field; + val.get_to(field); + o.threadId = field; + continue; + } + if ( key == "timeUtc" ) { + std::string field; + val.get_to(field); + o.timeUtc = field; + continue; + } + if ( key == "exception" ) { + exception_struct field; + val.get_to(field); + o.exception = field; + continue; + } + if ( key == "descriptor" ) { + reporting_descriptor_reference_struct field; + val.get_to(field); + o.descriptor = field; + continue; + } + if ( key == "associatedRule" ) { + reporting_descriptor_reference_struct field; + val.get_to(field); + o.associatedRule = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const notification_struct &o) { + if ( o.locations.has_value() ) { + j["locations"] = *o.locations; + } + j["message"] = o.message; + if ( o.level.has_value() ) { + j["level"] = *o.level; + } + if ( o.threadId.has_value() ) { + j["threadId"] = *o.threadId; + } + if ( o.timeUtc.has_value() ) { + j["timeUtc"] = *o.timeUtc; + } + if ( o.exception.has_value() ) { + j["exception"] = *o.exception; + } + if ( o.descriptor.has_value() ) { + j["descriptor"] = *o.descriptor; + } + if ( o.associatedRule.has_value() ) { + j["associatedRule"] = *o.associatedRule; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, rectangle_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "top" ) { + double field; + val.get_to(field); + o.top = field; + continue; + } + if ( key == "left" ) { + double field; + val.get_to(field); + o.left = field; + continue; + } + if ( key == "bottom" ) { + double field; + val.get_to(field); + o.bottom = field; + continue; + } + if ( key == "right" ) { + double field; + val.get_to(field); + o.right = field; + continue; + } + if ( key == "message" ) { + message_struct field; + val.get_to(field); + o.message = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const rectangle_struct &o) { + if ( o.top.has_value() ) { + j["top"] = *o.top; + } + if ( o.left.has_value() ) { + j["left"] = *o.left; + } + if ( o.bottom.has_value() ) { + j["bottom"] = *o.bottom; + } + if ( o.right.has_value() ) { + j["right"] = *o.right; + } + if ( o.message.has_value() ) { + j["message"] = *o.message; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, replacement_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "deletedRegion" ) { + val.get_to(o.deletedRegion); + continue; + } + if ( key == "insertedContent" ) { + artifact_content_struct field; + val.get_to(field); + o.insertedContent = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const replacement_struct &o) { + j["deletedRegion"] = o.deletedRegion; + if ( o.insertedContent.has_value() ) { + j["insertedContent"] = *o.insertedContent; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, reporting_descriptor_message_strings_struct &o) { + for( auto &[key, val] : j.items() ) { + val.get_to(o.additional_properties[key]); + } + } + void to_json(nlohmann::json &j, const reporting_descriptor_message_strings_struct &o) { + for ( auto &[key, val] : o.additional_properties ) { + j[key] = val; + } + } + void from_json(const nlohmann::json &j, reporting_descriptor_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "id" ) { + val.get_to(o.id); + continue; + } + if ( key == "deprecatedIds" ) { + std::vector field; + val.get_to(field); + o.deprecatedIds = field; + continue; + } + if ( key == "guid" ) { + std::string field; + val.get_to(field); + o.guid = field; + continue; + } + if ( key == "deprecatedGuids" ) { + std::vector field; + val.get_to(field); + o.deprecatedGuids = field; + continue; + } + if ( key == "name" ) { + std::string field; + val.get_to(field); + o.name = field; + continue; + } + if ( key == "deprecatedNames" ) { + std::vector field; + val.get_to(field); + o.deprecatedNames = field; + continue; + } + if ( key == "shortDescription" ) { + multiformat_message_string_struct field; + val.get_to(field); + o.shortDescription = field; + continue; + } + if ( key == "fullDescription" ) { + multiformat_message_string_struct field; + val.get_to(field); + o.fullDescription = field; + continue; + } + if ( key == "messageStrings" ) { + reporting_descriptor_message_strings_struct field; + val.get_to(field); + o.messageStrings = field; + continue; + } + if ( key == "defaultConfiguration" ) { + reporting_configuration_struct field; + val.get_to(field); + o.defaultConfiguration = field; + continue; + } + if ( key == "helpUri" ) { + std::string field; + val.get_to(field); + o.helpUri = field; + continue; + } + if ( key == "help" ) { + multiformat_message_string_struct field; + val.get_to(field); + o.help = field; + continue; + } + if ( key == "relationships" ) { + std::vector field; + val.get_to(field); + o.relationships = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const reporting_descriptor_struct &o) { + j["id"] = o.id; + if ( o.deprecatedIds.has_value() ) { + j["deprecatedIds"] = *o.deprecatedIds; + } + if ( o.guid.has_value() ) { + j["guid"] = *o.guid; + } + if ( o.deprecatedGuids.has_value() ) { + j["deprecatedGuids"] = *o.deprecatedGuids; + } + if ( o.name.has_value() ) { + j["name"] = *o.name; + } + if ( o.deprecatedNames.has_value() ) { + j["deprecatedNames"] = *o.deprecatedNames; + } + if ( o.shortDescription.has_value() ) { + j["shortDescription"] = *o.shortDescription; + } + if ( o.fullDescription.has_value() ) { + j["fullDescription"] = *o.fullDescription; + } + if ( o.messageStrings.has_value() ) { + j["messageStrings"] = *o.messageStrings; + } + if ( o.defaultConfiguration.has_value() ) { + j["defaultConfiguration"] = *o.defaultConfiguration; + } + if ( o.helpUri.has_value() ) { + j["helpUri"] = *o.helpUri; + } + if ( o.help.has_value() ) { + j["help"] = *o.help; + } + if ( o.relationships.has_value() ) { + j["relationships"] = *o.relationships; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, reporting_descriptor_relationship_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "target" ) { + val.get_to(o.target); + continue; + } + if ( key == "kinds" ) { + std::vector field; + val.get_to(field); + o.kinds = field; + continue; + } + if ( key == "description" ) { + message_struct field; + val.get_to(field); + o.description = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const reporting_descriptor_relationship_struct &o) { + j["target"] = o.target; + if ( o.kinds.has_value() ) { + j["kinds"] = *o.kinds; + } + if ( o.description.has_value() ) { + j["description"] = *o.description; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, result_partial_fingerprints_struct &o) { + for( auto &[key, val] : j.items() ) { + val.get_to(o.additional_properties[key]); + } + } + void to_json(nlohmann::json &j, const result_partial_fingerprints_struct &o) { + for ( auto &[key, val] : o.additional_properties ) { + j[key] = val; + } + } + void from_json(const nlohmann::json &j, result_fingerprints_struct &o) { + for( auto &[key, val] : j.items() ) { + val.get_to(o.additional_properties[key]); + } + } + void to_json(nlohmann::json &j, const result_fingerprints_struct &o) { + for ( auto &[key, val] : o.additional_properties ) { + j[key] = val; + } + } + void from_json(const nlohmann::json &j, result_provenance_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "firstDetectionTimeUtc" ) { + std::string field; + val.get_to(field); + o.firstDetectionTimeUtc = field; + continue; + } + if ( key == "lastDetectionTimeUtc" ) { + std::string field; + val.get_to(field); + o.lastDetectionTimeUtc = field; + continue; + } + if ( key == "firstDetectionRunGuid" ) { + std::string field; + val.get_to(field); + o.firstDetectionRunGuid = field; + continue; + } + if ( key == "lastDetectionRunGuid" ) { + std::string field; + val.get_to(field); + o.lastDetectionRunGuid = field; + continue; + } + if ( key == "invocationIndex" ) { + int64_t field; + val.get_to(field); + o.invocationIndex = field; + continue; + } + if ( key == "conversionSources" ) { + std::vector field; + val.get_to(field); + o.conversionSources = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const result_provenance_struct &o) { + if ( o.firstDetectionTimeUtc.has_value() ) { + j["firstDetectionTimeUtc"] = *o.firstDetectionTimeUtc; + } + if ( o.lastDetectionTimeUtc.has_value() ) { + j["lastDetectionTimeUtc"] = *o.lastDetectionTimeUtc; + } + if ( o.firstDetectionRunGuid.has_value() ) { + j["firstDetectionRunGuid"] = *o.firstDetectionRunGuid; + } + if ( o.lastDetectionRunGuid.has_value() ) { + j["lastDetectionRunGuid"] = *o.lastDetectionRunGuid; + } + if ( o.invocationIndex.has_value() ) { + j["invocationIndex"] = *o.invocationIndex; + } + if ( o.conversionSources.has_value() ) { + j["conversionSources"] = *o.conversionSources; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, web_request_headers_struct &o) { + for( auto &[key, val] : j.items() ) { + val.get_to(o.additional_properties[key]); + } + } + void to_json(nlohmann::json &j, const web_request_headers_struct &o) { + for ( auto &[key, val] : o.additional_properties ) { + j[key] = val; + } + } + void from_json(const nlohmann::json &j, web_request_parameters_struct &o) { + for( auto &[key, val] : j.items() ) { + val.get_to(o.additional_properties[key]); + } + } + void to_json(nlohmann::json &j, const web_request_parameters_struct &o) { + for ( auto &[key, val] : o.additional_properties ) { + j[key] = val; + } + } + void from_json(const nlohmann::json &j, web_request_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "index" ) { + int64_t field; + val.get_to(field); + o.index = field; + continue; + } + if ( key == "protocol" ) { + std::string field; + val.get_to(field); + o.protocol = field; + continue; + } + if ( key == "version" ) { + std::string field; + val.get_to(field); + o.version = field; + continue; + } + if ( key == "target" ) { + std::string field; + val.get_to(field); + o.target = field; + continue; + } + if ( key == "method" ) { + std::string field; + val.get_to(field); + o.method = field; + continue; + } + if ( key == "headers" ) { + web_request_headers_struct field; + val.get_to(field); + o.headers = field; + continue; + } + if ( key == "parameters" ) { + web_request_parameters_struct field; + val.get_to(field); + o.parameters = field; + continue; + } + if ( key == "body" ) { + artifact_content_struct field; + val.get_to(field); + o.body = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const web_request_struct &o) { + if ( o.index.has_value() ) { + j["index"] = *o.index; + } + if ( o.protocol.has_value() ) { + j["protocol"] = *o.protocol; + } + if ( o.version.has_value() ) { + j["version"] = *o.version; + } + if ( o.target.has_value() ) { + j["target"] = *o.target; + } + if ( o.method.has_value() ) { + j["method"] = *o.method; + } + if ( o.headers.has_value() ) { + j["headers"] = *o.headers; + } + if ( o.parameters.has_value() ) { + j["parameters"] = *o.parameters; + } + if ( o.body.has_value() ) { + j["body"] = *o.body; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, web_response_headers_struct &o) { + for( auto &[key, val] : j.items() ) { + val.get_to(o.additional_properties[key]); + } + } + void to_json(nlohmann::json &j, const web_response_headers_struct &o) { + for ( auto &[key, val] : o.additional_properties ) { + j[key] = val; + } + } + void from_json(const nlohmann::json &j, web_response_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "index" ) { + int64_t field; + val.get_to(field); + o.index = field; + continue; + } + if ( key == "protocol" ) { + std::string field; + val.get_to(field); + o.protocol = field; + continue; + } + if ( key == "version" ) { + std::string field; + val.get_to(field); + o.version = field; + continue; + } + if ( key == "statusCode" ) { + int64_t field; + val.get_to(field); + o.statusCode = field; + continue; + } + if ( key == "reasonPhrase" ) { + std::string field; + val.get_to(field); + o.reasonPhrase = field; + continue; + } + if ( key == "headers" ) { + web_response_headers_struct field; + val.get_to(field); + o.headers = field; + continue; + } + if ( key == "body" ) { + artifact_content_struct field; + val.get_to(field); + o.body = field; + continue; + } + if ( key == "noResponseReceived" ) { + bool field; + val.get_to(field); + o.noResponseReceived = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const web_response_struct &o) { + if ( o.index.has_value() ) { + j["index"] = *o.index; + } + if ( o.protocol.has_value() ) { + j["protocol"] = *o.protocol; + } + if ( o.version.has_value() ) { + j["version"] = *o.version; + } + if ( o.statusCode.has_value() ) { + j["statusCode"] = *o.statusCode; + } + if ( o.reasonPhrase.has_value() ) { + j["reasonPhrase"] = *o.reasonPhrase; + } + if ( o.headers.has_value() ) { + j["headers"] = *o.headers; + } + if ( o.body.has_value() ) { + j["body"] = *o.body; + } + if ( o.noResponseReceived.has_value() ) { + j["noResponseReceived"] = *o.noResponseReceived; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, result_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "ruleId" ) { + std::string field; + val.get_to(field); + o.ruleId = field; + continue; + } + if ( key == "ruleIndex" ) { + int64_t field; + val.get_to(field); + o.ruleIndex = field; + continue; + } + if ( key == "rule" ) { + reporting_descriptor_reference_struct field; + val.get_to(field); + o.rule = field; + continue; + } + if ( key == "kind" ) { + kind_enum field; + val.get_to(field); + o.kind = field; + continue; + } + if ( key == "level" ) { + level_enum field; + val.get_to(field); + o.level = field; + continue; + } + if ( key == "message" ) { + val.get_to(o.message); + continue; + } + if ( key == "analysisTarget" ) { + artifact_location_struct field; + val.get_to(field); + o.analysisTarget = field; + continue; + } + if ( key == "locations" ) { + std::vector field; + val.get_to(field); + o.locations = field; + continue; + } + if ( key == "guid" ) { + std::string field; + val.get_to(field); + o.guid = field; + continue; + } + if ( key == "correlationGuid" ) { + std::string field; + val.get_to(field); + o.correlationGuid = field; + continue; + } + if ( key == "occurrenceCount" ) { + int64_t field; + val.get_to(field); + o.occurrenceCount = field; + continue; + } + if ( key == "partialFingerprints" ) { + result_partial_fingerprints_struct field; + val.get_to(field); + o.partialFingerprints = field; + continue; + } + if ( key == "fingerprints" ) { + result_fingerprints_struct field; + val.get_to(field); + o.fingerprints = field; + continue; + } + if ( key == "stacks" ) { + std::vector field; + val.get_to(field); + o.stacks = field; + continue; + } + if ( key == "codeFlows" ) { + std::vector field; + val.get_to(field); + o.codeFlows = field; + continue; + } + if ( key == "graphs" ) { + std::vector field; + val.get_to(field); + o.graphs = field; + continue; + } + if ( key == "graphTraversals" ) { + std::vector field; + val.get_to(field); + o.graphTraversals = field; + continue; + } + if ( key == "relatedLocations" ) { + std::vector field; + val.get_to(field); + o.relatedLocations = field; + continue; + } + if ( key == "suppressions" ) { + std::vector field; + val.get_to(field); + o.suppressions = field; + continue; + } + if ( key == "baselineState" ) { + baseline_state_enum field; + val.get_to(field); + o.baselineState = field; + continue; + } + if ( key == "rank" ) { + double field; + val.get_to(field); + o.rank = field; + continue; + } + if ( key == "attachments" ) { + std::vector field; + val.get_to(field); + o.attachments = field; + continue; + } + if ( key == "hostedViewerUri" ) { + std::string field; + val.get_to(field); + o.hostedViewerUri = field; + continue; + } + if ( key == "workItemUris" ) { + std::vector field; + val.get_to(field); + o.workItemUris = field; + continue; + } + if ( key == "provenance" ) { + result_provenance_struct field; + val.get_to(field); + o.provenance = field; + continue; + } + if ( key == "fixes" ) { + std::vector field; + val.get_to(field); + o.fixes = field; + continue; + } + if ( key == "taxa" ) { + std::vector field; + val.get_to(field); + o.taxa = field; + continue; + } + if ( key == "webRequest" ) { + web_request_struct field; + val.get_to(field); + o.webRequest = field; + continue; + } + if ( key == "webResponse" ) { + web_response_struct field; + val.get_to(field); + o.webResponse = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const result_struct &o) { + if ( o.ruleId.has_value() ) { + j["ruleId"] = *o.ruleId; + } + if ( o.ruleIndex.has_value() ) { + j["ruleIndex"] = *o.ruleIndex; + } + if ( o.rule.has_value() ) { + j["rule"] = *o.rule; + } + if ( o.kind.has_value() ) { + j["kind"] = *o.kind; + } + if ( o.level.has_value() ) { + j["level"] = *o.level; + } + j["message"] = o.message; + if ( o.analysisTarget.has_value() ) { + j["analysisTarget"] = *o.analysisTarget; + } + if ( o.locations.has_value() ) { + j["locations"] = *o.locations; + } + if ( o.guid.has_value() ) { + j["guid"] = *o.guid; + } + if ( o.correlationGuid.has_value() ) { + j["correlationGuid"] = *o.correlationGuid; + } + if ( o.occurrenceCount.has_value() ) { + j["occurrenceCount"] = *o.occurrenceCount; + } + if ( o.partialFingerprints.has_value() ) { + j["partialFingerprints"] = *o.partialFingerprints; + } + if ( o.fingerprints.has_value() ) { + j["fingerprints"] = *o.fingerprints; + } + if ( o.stacks.has_value() ) { + j["stacks"] = *o.stacks; + } + if ( o.codeFlows.has_value() ) { + j["codeFlows"] = *o.codeFlows; + } + if ( o.graphs.has_value() ) { + j["graphs"] = *o.graphs; + } + if ( o.graphTraversals.has_value() ) { + j["graphTraversals"] = *o.graphTraversals; + } + if ( o.relatedLocations.has_value() ) { + j["relatedLocations"] = *o.relatedLocations; + } + if ( o.suppressions.has_value() ) { + j["suppressions"] = *o.suppressions; + } + if ( o.baselineState.has_value() ) { + j["baselineState"] = *o.baselineState; + } + if ( o.rank.has_value() ) { + j["rank"] = *o.rank; + } + if ( o.attachments.has_value() ) { + j["attachments"] = *o.attachments; + } + if ( o.hostedViewerUri.has_value() ) { + j["hostedViewerUri"] = *o.hostedViewerUri; + } + if ( o.workItemUris.has_value() ) { + j["workItemUris"] = *o.workItemUris; + } + if ( o.provenance.has_value() ) { + j["provenance"] = *o.provenance; + } + if ( o.fixes.has_value() ) { + j["fixes"] = *o.fixes; + } + if ( o.taxa.has_value() ) { + j["taxa"] = *o.taxa; + } + if ( o.webRequest.has_value() ) { + j["webRequest"] = *o.webRequest; + } + if ( o.webResponse.has_value() ) { + j["webResponse"] = *o.webResponse; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, run_original_uri_base_ids_struct &o) { + for( auto &[key, val] : j.items() ) { + val.get_to(o.additional_properties[key]); + } + } + void to_json(nlohmann::json &j, const run_original_uri_base_ids_struct &o) { + for ( auto &[key, val] : o.additional_properties ) { + j[key] = val; + } + } + void from_json(const nlohmann::json &j, run_automation_details_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "description" ) { + message_struct field; + val.get_to(field); + o.description = field; + continue; + } + if ( key == "id" ) { + std::string field; + val.get_to(field); + o.id = field; + continue; + } + if ( key == "guid" ) { + std::string field; + val.get_to(field); + o.guid = field; + continue; + } + if ( key == "correlationGuid" ) { + std::string field; + val.get_to(field); + o.correlationGuid = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const run_automation_details_struct &o) { + if ( o.description.has_value() ) { + j["description"] = *o.description; + } + if ( o.id.has_value() ) { + j["id"] = *o.id; + } + if ( o.guid.has_value() ) { + j["guid"] = *o.guid; + } + if ( o.correlationGuid.has_value() ) { + j["correlationGuid"] = *o.correlationGuid; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, special_locations_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "displayBase" ) { + artifact_location_struct field; + val.get_to(field); + o.displayBase = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const special_locations_struct &o) { + if ( o.displayBase.has_value() ) { + j["displayBase"] = *o.displayBase; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, run_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "tool" ) { + val.get_to(o.tool); + continue; + } + if ( key == "invocations" ) { + std::vector field; + val.get_to(field); + o.invocations = field; + continue; + } + if ( key == "conversion" ) { + conversion_struct field; + val.get_to(field); + o.conversion = field; + continue; + } + if ( key == "language" ) { + std::string field; + val.get_to(field); + o.language = field; + continue; + } + if ( key == "versionControlProvenance" ) { + std::vector field; + val.get_to(field); + o.versionControlProvenance = field; + continue; + } + if ( key == "originalUriBaseIds" ) { + run_original_uri_base_ids_struct field; + val.get_to(field); + o.originalUriBaseIds = field; + continue; + } + if ( key == "artifacts" ) { + std::vector field; + val.get_to(field); + o.artifacts = field; + continue; + } + if ( key == "logicalLocations" ) { + std::vector field; + val.get_to(field); + o.logicalLocations = field; + continue; + } + if ( key == "graphs" ) { + std::vector field; + val.get_to(field); + o.graphs = field; + continue; + } + if ( key == "results" ) { + std::vector field; + val.get_to(field); + o.results = field; + continue; + } + if ( key == "automationDetails" ) { + run_automation_details_struct field; + val.get_to(field); + o.automationDetails = field; + continue; + } + if ( key == "runAggregates" ) { + std::vector field; + val.get_to(field); + o.runAggregates = field; + continue; + } + if ( key == "baselineGuid" ) { + std::string field; + val.get_to(field); + o.baselineGuid = field; + continue; + } + if ( key == "redactionTokens" ) { + std::vector field; + val.get_to(field); + o.redactionTokens = field; + continue; + } + if ( key == "defaultEncoding" ) { + std::string field; + val.get_to(field); + o.defaultEncoding = field; + continue; + } + if ( key == "defaultSourceLanguage" ) { + std::string field; + val.get_to(field); + o.defaultSourceLanguage = field; + continue; + } + if ( key == "newlineSequences" ) { + std::vector field; + val.get_to(field); + o.newlineSequences = field; + continue; + } + if ( key == "columnKind" ) { + column_kind_enum field; + val.get_to(field); + o.columnKind = field; + continue; + } + if ( key == "externalPropertyFileReferences" ) { + external_property_file_references_struct field; + val.get_to(field); + o.externalPropertyFileReferences = field; + continue; + } + if ( key == "threadFlowLocations" ) { + std::vector field; + val.get_to(field); + o.threadFlowLocations = field; + continue; + } + if ( key == "taxonomies" ) { + std::vector field; + val.get_to(field); + o.taxonomies = field; + continue; + } + if ( key == "addresses" ) { + std::vector field; + val.get_to(field); + o.addresses = field; + continue; + } + if ( key == "translations" ) { + std::vector field; + val.get_to(field); + o.translations = field; + continue; + } + if ( key == "policies" ) { + std::vector field; + val.get_to(field); + o.policies = field; + continue; + } + if ( key == "webRequests" ) { + std::vector field; + val.get_to(field); + o.webRequests = field; + continue; + } + if ( key == "webResponses" ) { + std::vector field; + val.get_to(field); + o.webResponses = field; + continue; + } + if ( key == "specialLocations" ) { + special_locations_struct field; + val.get_to(field); + o.specialLocations = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const run_struct &o) { + j["tool"] = o.tool; + if ( o.invocations.has_value() ) { + j["invocations"] = *o.invocations; + } + if ( o.conversion.has_value() ) { + j["conversion"] = *o.conversion; + } + if ( o.language.has_value() ) { + j["language"] = *o.language; + } + if ( o.versionControlProvenance.has_value() ) { + j["versionControlProvenance"] = *o.versionControlProvenance; + } + if ( o.originalUriBaseIds.has_value() ) { + j["originalUriBaseIds"] = *o.originalUriBaseIds; + } + if ( o.artifacts.has_value() ) { + j["artifacts"] = *o.artifacts; + } + if ( o.logicalLocations.has_value() ) { + j["logicalLocations"] = *o.logicalLocations; + } + if ( o.graphs.has_value() ) { + j["graphs"] = *o.graphs; + } + if ( o.results.has_value() ) { + j["results"] = *o.results; + } + if ( o.automationDetails.has_value() ) { + j["automationDetails"] = *o.automationDetails; + } + if ( o.runAggregates.has_value() ) { + j["runAggregates"] = *o.runAggregates; + } + if ( o.baselineGuid.has_value() ) { + j["baselineGuid"] = *o.baselineGuid; + } + if ( o.redactionTokens.has_value() ) { + j["redactionTokens"] = *o.redactionTokens; + } + if ( o.defaultEncoding.has_value() ) { + j["defaultEncoding"] = *o.defaultEncoding; + } + if ( o.defaultSourceLanguage.has_value() ) { + j["defaultSourceLanguage"] = *o.defaultSourceLanguage; + } + if ( o.newlineSequences.has_value() ) { + j["newlineSequences"] = *o.newlineSequences; + } + if ( o.columnKind.has_value() ) { + j["columnKind"] = *o.columnKind; + } + if ( o.externalPropertyFileReferences.has_value() ) { + j["externalPropertyFileReferences"] = *o.externalPropertyFileReferences; + } + if ( o.threadFlowLocations.has_value() ) { + j["threadFlowLocations"] = *o.threadFlowLocations; + } + if ( o.taxonomies.has_value() ) { + j["taxonomies"] = *o.taxonomies; + } + if ( o.addresses.has_value() ) { + j["addresses"] = *o.addresses; + } + if ( o.translations.has_value() ) { + j["translations"] = *o.translations; + } + if ( o.policies.has_value() ) { + j["policies"] = *o.policies; + } + if ( o.webRequests.has_value() ) { + j["webRequests"] = *o.webRequests; + } + if ( o.webResponses.has_value() ) { + j["webResponses"] = *o.webResponses; + } + if ( o.specialLocations.has_value() ) { + j["specialLocations"] = *o.specialLocations; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, stack_frame_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "location" ) { + location_struct field; + val.get_to(field); + o.location = field; + continue; + } + if ( key == "module" ) { + std::string field; + val.get_to(field); + o.module = field; + continue; + } + if ( key == "threadId" ) { + int64_t field; + val.get_to(field); + o.threadId = field; + continue; + } + if ( key == "parameters" ) { + std::vector field; + val.get_to(field); + o.parameters = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const stack_frame_struct &o) { + if ( o.location.has_value() ) { + j["location"] = *o.location; + } + if ( o.module.has_value() ) { + j["module"] = *o.module; + } + if ( o.threadId.has_value() ) { + j["threadId"] = *o.threadId; + } + if ( o.parameters.has_value() ) { + j["parameters"] = *o.parameters; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, suppression_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "guid" ) { + std::string field; + val.get_to(field); + o.guid = field; + continue; + } + if ( key == "kind" ) { + val.get_to(o.kind); + continue; + } + if ( key == "state" ) { + state_enum field; + val.get_to(field); + o.state = field; + continue; + } + if ( key == "justification" ) { + std::string field; + val.get_to(field); + o.justification = field; + continue; + } + if ( key == "location" ) { + location_struct field; + val.get_to(field); + o.location = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const suppression_struct &o) { + if ( o.guid.has_value() ) { + j["guid"] = *o.guid; + } + j["kind"] = o.kind; + if ( o.state.has_value() ) { + j["state"] = *o.state; + } + if ( o.justification.has_value() ) { + j["justification"] = *o.justification; + } + if ( o.location.has_value() ) { + j["location"] = *o.location; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, thread_flow_initial_state_struct &o) { + for( auto &[key, val] : j.items() ) { + val.get_to(o.additional_properties[key]); + } + } + void to_json(nlohmann::json &j, const thread_flow_initial_state_struct &o) { + for ( auto &[key, val] : o.additional_properties ) { + j[key] = val; + } + } + void from_json(const nlohmann::json &j, thread_flow_immutable_state_struct &o) { + for( auto &[key, val] : j.items() ) { + val.get_to(o.additional_properties[key]); + } + } + void to_json(nlohmann::json &j, const thread_flow_immutable_state_struct &o) { + for ( auto &[key, val] : o.additional_properties ) { + j[key] = val; + } + } + void from_json(const nlohmann::json &j, thread_flow_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "id" ) { + std::string field; + val.get_to(field); + o.id = field; + continue; + } + if ( key == "message" ) { + message_struct field; + val.get_to(field); + o.message = field; + continue; + } + if ( key == "initialState" ) { + thread_flow_initial_state_struct field; + val.get_to(field); + o.initialState = field; + continue; + } + if ( key == "immutableState" ) { + thread_flow_immutable_state_struct field; + val.get_to(field); + o.immutableState = field; + continue; + } + if ( key == "locations" ) { + val.get_to(o.locations); + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const thread_flow_struct &o) { + if ( o.id.has_value() ) { + j["id"] = *o.id; + } + if ( o.message.has_value() ) { + j["message"] = *o.message; + } + if ( o.initialState.has_value() ) { + j["initialState"] = *o.initialState; + } + if ( o.immutableState.has_value() ) { + j["immutableState"] = *o.immutableState; + } + j["locations"] = o.locations; + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, thread_flow_location_state_struct &o) { + for( auto &[key, val] : j.items() ) { + val.get_to(o.additional_properties[key]); + } + } + void to_json(nlohmann::json &j, const thread_flow_location_state_struct &o) { + for ( auto &[key, val] : o.additional_properties ) { + j[key] = val; + } + } + void from_json(const nlohmann::json &j, thread_flow_location_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "index" ) { + int64_t field; + val.get_to(field); + o.index = field; + continue; + } + if ( key == "location" ) { + location_struct field; + val.get_to(field); + o.location = field; + continue; + } + if ( key == "stack" ) { + stack_struct field; + val.get_to(field); + o.stack = field; + continue; + } + if ( key == "kinds" ) { + std::vector field; + val.get_to(field); + o.kinds = field; + continue; + } + if ( key == "taxa" ) { + std::vector field; + val.get_to(field); + o.taxa = field; + continue; + } + if ( key == "module" ) { + std::string field; + val.get_to(field); + o.module = field; + continue; + } + if ( key == "state" ) { + thread_flow_location_state_struct field; + val.get_to(field); + o.state = field; + continue; + } + if ( key == "nestingLevel" ) { + int64_t field; + val.get_to(field); + o.nestingLevel = field; + continue; + } + if ( key == "executionOrder" ) { + int64_t field; + val.get_to(field); + o.executionOrder = field; + continue; + } + if ( key == "executionTimeUtc" ) { + std::string field; + val.get_to(field); + o.executionTimeUtc = field; + continue; + } + if ( key == "importance" ) { + importance_enum field; + val.get_to(field); + o.importance = field; + continue; + } + if ( key == "webRequest" ) { + web_request_struct field; + val.get_to(field); + o.webRequest = field; + continue; + } + if ( key == "webResponse" ) { + web_response_struct field; + val.get_to(field); + o.webResponse = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const thread_flow_location_struct &o) { + if ( o.index.has_value() ) { + j["index"] = *o.index; + } + if ( o.location.has_value() ) { + j["location"] = *o.location; + } + if ( o.stack.has_value() ) { + j["stack"] = *o.stack; + } + if ( o.kinds.has_value() ) { + j["kinds"] = *o.kinds; + } + if ( o.taxa.has_value() ) { + j["taxa"] = *o.taxa; + } + if ( o.module.has_value() ) { + j["module"] = *o.module; + } + if ( o.state.has_value() ) { + j["state"] = *o.state; + } + if ( o.nestingLevel.has_value() ) { + j["nestingLevel"] = *o.nestingLevel; + } + if ( o.executionOrder.has_value() ) { + j["executionOrder"] = *o.executionOrder; + } + if ( o.executionTimeUtc.has_value() ) { + j["executionTimeUtc"] = *o.executionTimeUtc; + } + if ( o.importance.has_value() ) { + j["importance"] = *o.importance; + } + if ( o.webRequest.has_value() ) { + j["webRequest"] = *o.webRequest; + } + if ( o.webResponse.has_value() ) { + j["webResponse"] = *o.webResponse; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } + void from_json(const nlohmann::json &j, version_control_details_struct &o) { + for( auto &[key, val] : j.items() ) { + if ( key == "repositoryUri" ) { + val.get_to(o.repositoryUri); + continue; + } + if ( key == "revisionId" ) { + std::string field; + val.get_to(field); + o.revisionId = field; + continue; + } + if ( key == "branch" ) { + std::string field; + val.get_to(field); + o.branch = field; + continue; + } + if ( key == "revisionTag" ) { + std::string field; + val.get_to(field); + o.revisionTag = field; + continue; + } + if ( key == "asOfTimeUtc" ) { + std::string field; + val.get_to(field); + o.asOfTimeUtc = field; + continue; + } + if ( key == "mappedTo" ) { + artifact_location_struct field; + val.get_to(field); + o.mappedTo = field; + continue; + } + if ( key == "properties" ) { + property_bag_struct field; + val.get_to(field); + o.properties = field; + continue; + } + } + } + void to_json(nlohmann::json &j, const version_control_details_struct &o) { + j["repositoryUri"] = o.repositoryUri; + if ( o.revisionId.has_value() ) { + j["revisionId"] = *o.revisionId; + } + if ( o.branch.has_value() ) { + j["branch"] = *o.branch; + } + if ( o.revisionTag.has_value() ) { + j["revisionTag"] = *o.revisionTag; + } + if ( o.asOfTimeUtc.has_value() ) { + j["asOfTimeUtc"] = *o.asOfTimeUtc; + } + if ( o.mappedTo.has_value() ) { + j["mappedTo"] = *o.mappedTo; + } + if ( o.properties.has_value() ) { + j["properties"] = *o.properties; + } + } +} \ No newline at end of file diff --git a/test/sarif/definitions.cpp b/test/sarif/definitions.cpp index 2cccebe..5dbf5a2 100644 --- a/test/sarif/definitions.cpp +++ b/test/sarif/definitions.cpp @@ -2,8 +2,6 @@ #include #include -#include -#include namespace gap::sarif::definitions { TEST_CASE("Roundtrip") { @@ -14,65 +12,66 @@ namespace gap::sarif::definitions { { .tool = { .driver = { - .name="ESLint", - .informationUri="https://eslint.org", - .rules = { + .name = "ESLint", + .informationUri = "https://eslint.org", + .rules = {{ { .id = "no-unused-vars", - .shortDescription = { + .shortDescription = {{ .text = "disallow unused variables", - }, + }}, .helpUri = "https://eslint.org/docs/rules/no-unused-vars", - .properties = { - {"category", "Variables"}, - }, - }, - }, + .properties = {{ + .additional_properties = { + {"category", "Variable"}, + }, + }}, + } + }}, }, }, - .artifacts = { + .artifacts = {{ { - .location = { + .location = {{ .uri = "file:///C:/dev/sarif/sarif-tutorials/samples/Introduction/simple-example.js", - }, + }}, }, - }, - .results = { + }}, + .results = {{ { .level = level_enum::kError, .message = { .text = "'x' is assigned a value but never used.", }, - .locations = { + .locations = {{ { - .physicalLocation = { - .artifactLocation = { + .physicalLocation = {{ + .artifactLocation = {{ .uri = "file:///C:/dev/sarif/sarif-tutorials/samples/Introduction/simple-example.js", .index = 0, + }}, + }}, + .properties = {{ + .additional_properties = { + {"region", { + {"startLine", 1}, + {"startColumn", 5}, + }}, }, - .region = { - .startLine = 1, - .startColumn = 5, - }, - }, + }}, }, - }, + }}, .ruleId = "no-unused-vars", .ruleIndex = 0, }, - }, - }, + }}, + } }, }; - nlohmann::json root_json; - to_json(root_json, root); - - root_struct deser; - from_json(root_json, deser); - - nlohmann::json deser_json; - to_json(deser_json, deser); + nlohmann::json root_json = root; + root_struct deser = root; + nlohmann::json deser_json = deser; CHECK(root_json == deser_json); }