{"meta":{"title":"对代码扫描的 SARIF 支持","intro":"确保来自第三方工具的 SARIF 文件符合 GitHub的标准。","product":"安全性和代码质量","breadcrumbs":[{"href":"/zh/code-security","title":"安全性和代码质量"},{"href":"/zh/code-security/reference","title":"Reference"},{"href":"/zh/code-security/reference/code-scanning","title":"代码扫描"},{"href":"/zh/code-security/reference/code-scanning/sarif-files","title":"SARIF 文件"},{"href":"/zh/code-security/reference/code-scanning/sarif-files/sarif-support-for-code-scanning","title":"SARIF 支持"}],"documentType":"article"},"body":"# 对代码扫描的 SARIF 支持\n\n确保来自第三方工具的 SARIF 文件符合 GitHub的标准。\n\nGitHub 可以分析第三方工具生成的 SARIF 文件，来在存储库中显示 code scanning 警报。 有关详细信息，请参阅“[关于用于代码扫描的 SARIF 文件](/zh/code-security/concepts/code-scanning/sarif-files)”。\n\n本文重点介绍 SARIF 文件的关键属性，以帮助上传满足 GitHub要求的 SARIF 文件，并且可以转换为有用的警报。\n\n如果结合使用 GitHub Actions 和 CodeQL 分析工作流程，或者使用 CodeQL CLI，则 code scanning 结果将自动使用受支持的 SARIF 2.1.0 子集。\n\n## 用于防止重复警报的数据\n\n每次上传新代码扫描的结果时，都会处理结果并将警报添加到存储库中。 为防止出现针对同一问题的重复警报，code scanning 使用指纹匹配各个运行的结果，使它们只会出现在所选分支的最新运行中出现一次。 这样可以在编辑文件时将警报与正确的代码行匹配。 结果的 `ruleId` 必须在分析中相同。\n\n### 一致的文件路径\n\n文件路径必须在运行间保持一致，以实现稳定指纹的计算。 如果文件路径对于相同结果有所不同，则每次进行新分析时，都会创建新警报，并关闭旧警报。 这会导致相同结果具有多个警报。\n\n### 指纹生成\n\nGitHub 使用 OASIS 标准中的 `partialFingerprints` 属性来检测两个结果在逻辑上是否相同。 有关详细信息，请参阅 OASIS 文档中的 [partialFingerprints 属性](https://docs.oasis-open.org/sarif/sarif/v2.1.0/cs01/sarif-v2.1.0-cs01.html#_Toc16012611)条目。\n\n通过 CodeQL 分析工作流程 或 CodeQL CLI 创建的 SARIF 文件包含指纹数据。 如果使用 `upload-sarif` 操作上传 SARIF 文件并且此数据丢失，GitHub 会尝试从源文件填充 `partialFingerprints` 字段。 有关上传结果的详细信息，请参阅 [将 SARIF 文件上传到 GitHub](/zh/code-security/code-scanning/integrating-with-code-scanning/uploading-a-sarif-file-to-github)。\n\n如果使用 `/code-scanning/sarifs` API 终结点上传无指纹数据的 SARIF 文件，code scanning 警报将被处理并显示，但用户可能会看到重复的警报。 为避免看到重复警报，应在上传 SARIF 文件之前计算指纹数据并填充 `partialFingerprints` 属性。 你可能会发现 `upload-sarif` 操作使用一个有用的起点的脚本： <https://github.com/github/codeql-action/blob/main/src/fingerprints.ts> 。 有关该 API 的详细信息，请参阅 [适用于代码扫描的 REST API 终结点](/zh/rest/code-scanning/code-scanning#upload-an-analysis-as-sarif-data)。\n\n## 规则和结果\n\nSARIF 文件支持规则和结果。 这些元素中存储的信息相似，但用途不同。\n\n* 规则是包含在 `reportingDescriptor` 对象中的 `toolComponent` 对象数组。 可在此处存储分析过程中运行的规则的详细信息。 这些对象中的信息应该很少更改，通常在更新工具时更改。\n* 结果存储为 `result` 对象中 `results` 下的一系列 `run` 对象。 每个 `result` 对象都包含代码库中一个警报的详细信息。 在 `results` 对象中，可以引用检测到警报的规则。\n\n当比较通过使用相同工具和规则分析不同代码库生成的 SARIF 文件时，你应会看到分析结果（而不是规则）存在差异。\n\n## 源文件位置\n\n指定源文件位置和代码行可确保代码扫描警报准确显示在包含已识别问题的文件内，以便有针对性地解决问题。\n\n这种精准率提高了代码评审和解决过程的效率，简化了开发工作流，使开发人员能够在他们的代码库上下文中直接解决问题。\n\n当警报标识的所有代码行都存在于拉取请求差异中时，Code scanning 还将在拉取请求检查结果中显示警报。\n\n若要在拉取请求检查中显示，警报必须满足以下所有条件：\n\n* 警报标识的所有代码行（包括警报的第一行）都存在于拉取请求差异中。\n* 警报必须存在于拉取请求中添加或编辑的代码行中，而不是已删除的行中。\n\n提交的 SARIF 文件中的 `physicalLocation` 对象标识警报的代码行。 有关详细信息，请参阅 [`physicalLocation` 对象](#physicallocation-object)。\n\n### 源文件的根位置\n\nCode scanning 将使用相对路径报告的结果解释为相对于所分析的存储库的根。 如果结果包含绝对 URI，则 URI 会转换为相对 URI。 随后可以将相对 URI 与提交到存储库的文件进行匹配。\n\n可以通过以下方法之一提供源根，用于从绝对 URI 转换为相对 URI。\n\n* [\n  `checkout_path`\n  ](https://github.com/github/codeql-action/blob/c2c0a2908e95769d01b907f9930050ecb5cf050d/analyze/action.yml#L44-L47) 作为 `github/codeql-action/analyze` 操作的输入\n* `checkout_uri` 作为 SARIF 上传 API 终结点的参数。 有关详细信息，请参阅“[适用于代码扫描的 REST API 终结点](/zh/rest/code-scanning/code-scanning#upload-an-analysis-as-sarif-data)”。\n* [\n  `invocations[0].workingDirectory.uri`\n  ](https://docs.oasis-open.org/sarif/sarif/v2.1.0/csprd01/sarif-v2.1.0-csprd01.html#_Toc9244365) 作为 SARIF 文件中 `run` 对象的属性。\n\n如果提供源根，则使用绝对 URI 指定的项目的任何位置都必须使用相同 URI 方案。 如果源根的 URI 方案与一个或多个绝对 URI 不匹配，则上传会被拒绝。\n\n例如，使用 `file:///github/workspace` 的源根上传 SARIF 文件。\n\n```shell\n# Conversion of absolute URIs to relative URIs for location artifacts\n\nfile:///github/workspace/src/main.go -> src/main.go\nfile:///tmp/go-build/tmp.go          -> file:///tmp/go-build/tmp.go\n```\n\n文件会成功上传，因为两个绝对 URI 都使用与源根相同的 URI 方案。\n\n### 符号链接解析\n\n如果结果的相对 URI 与使用符号链接定义的文件相匹配，则代码扫描将无法显示结果。 因此，你需要解析任何符号链接的文件，并使用解析的 URI 报告这些文件中的任何结果。\n\n## 文件兼容性\n\n<!--UI-LINK: When code scanning fails, the error banner shown in the Security > Code scanning alerts view links to this anchor.-->\n\n您可以根据 GitHub 引入规则测试 SARIF 文件是否兼容 code scanning。 有关详细信息，请访问 [Microsoft SARIF 验证程序](https://sarifweb.azurewebsites.net/)。\n\n对于每个 gzip 压缩 SARIF 文件，SARIF 上传支持的最大大小为 10 MB。 任何超过此限制的上传都将被拒绝。 如果 SARIF 文件由于包含太多结果而过大，则应更新配置，以将重点放在最重要的规则或查询的结果上。 有关详细信息，请参阅“[SARIF 结果文件太大](/zh/code-security/how-tos/scan-code-for-vulnerabilities/troubleshooting/troubleshooting-sarif-uploads/file-too-large)”。\n\nCode scanning 支持上传下表中数据对象的最大条目数。 如果这些对象中的任何一个超过其最大值，则 SARIF 文件将遭到拒绝。 对于某些对象，将显示的值的数量还有额外限制。 尽可能显示最重要的值。 当分析包含的数据超出支持的限制时，要充分利用分析，请尝试优化分析配置（例如对于 CodeQL 工具，识别并禁用干扰性最强的查询）。 有关详细信息，请参阅“[SARIF 结果超出一个或多个限制](/zh/code-security/how-tos/scan-code-for-vulnerabilities/troubleshooting/troubleshooting-sarif-uploads/results-exceed-limit)”。\n\n数据重用.code-scanning.sarif-限制 %}\n\n有关其他错误的信息，请参阅 [排查 SARIF 上传问题](/zh/code-security/how-tos/scan-code-for-vulnerabilities/troubleshooting/troubleshooting-sarif-uploads)。\n\n## 支持的属性\n\n如果您使用 CodeQL 以外的代码分析引擎，则可以查看受支持的 SARIF 属性来优化您的分析结果在 GitHub 中的显示方式。\n\n> \\[!NOTE]\n> 对于标记为“required”的任何属性，你都必须提供明确的值。 必填属性不支持空字符串。\n\n任何有效的 SARIF 2.1.0 输出文件都可以上传，但 code scanning 只使用以下受支持的属性。\n\n###\n\n```\n          `sarifLog` 对象\n```\n\n| 姓名        | 必选                                                                                                                                                                                                                                                                                                                        | Description                                                                        |\n| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |\n| `$schema` | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg> | 版本 2.1.0 的 SARIF JSON 架构的 URI。 例如，`https://json.schemastore.org/sarif-2.1.0.json`。 |\n| `version` | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg> | Code scanning 仅支持 SARIF 版本 `2.1.0`。                                                |\n| `runs[]`  | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg> | SARIF 文件包含一个或多个运行的数组。 每个运行代表分析工具的一次运行。 有关 `run` 的详细信息，请参阅 [`run` 对象](#run-object)。 |\n\n###\n\n```\n          `run` 对象\n```\n\nCode scanning 使用 `run` 对象按工具筛选结果并提供关于结果来源的信息。\n`run` 对象包含 `tool.driver` 工具组件对象，该对象包含有关生成结果的工具的信息。 每个 `run` 只能获得一个分析工具的结果。\n\n| 姓名                                | 必选                                                                                                                                                                                                                                                                                                                                                                                                                             | Description                                                                                                                                                                                                               |\n| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `tool.driver`                     | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg>                                                                                                      | 描述分析工具的 `toolComponent` 对象。 有关详细信息，请参阅 [`toolComponent` 对象](#toolcomponent-object)。                                                                                                                                       |\n| `tool.extensions[]`               | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | 表示工具在分析期间使用的任何插件或扩展的 `toolComponent` 对象数组。 有关详细信息，请参阅 [`toolComponent` 对象](#toolcomponent-object)。                                                                                                                        |\n| `invocation.workingDirectory.uri` | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | 仅当未提供 `checkout_uri`（仅限 SARIF 上传 API）或 `checkout_path`（仅限 GitHub Actions）时，才使用此字段。 该值用于将 [`physicalLocation` 对象](#physicallocation-object)中使用的绝对 URI 转换为相对 URI。 有关详细信息，请参阅[《指定源文件的根目录》](#root-location-for-source-files)。 |\n| `results[]`                       | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg>                                                                                                      | 分析工具的结果。 Code scanning 在 GitHub 上显示结果。 有关详细信息，请参阅 [`result` 对象](#result-object)。                                                                                                                                          |\n\n###\n\n```\n          `toolComponent` 对象\n```\n\n| 姓名                | 必选                                                                                                                                                                                                                                                                                                                                                                                                                             | Description                                                                                                                                                                                               |\n| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `name`            | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg>                                                                                                      | 分析工具的名称。 Code scanning 在 GitHub 上显示名称，以允许按工具筛选结果。                                                                                                                                                         |\n| `version`         | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | 分析工具的版本。 Code scanning 使用版本号来跟踪结果何时可能由于工具版本更改而不是所分析代码的更改而发生更改。 如果 SARIF 文件包含 `semanticVersion` 字段，则 code scanning 不使用 `version`。                                                                          |\n| `semanticVersion` | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | 以语义版本 2.0 格式指定的分析工具版本。 Code scanning 使用版本号来跟踪结果何时可能由于工具版本更改而不是所分析代码的更改而发生更改。 如果 SARIF 文件包含 `semanticVersion` 字段，则 code scanning 不使用 `version`。 有关详细信息，请参阅《语义化版本控制》文档中的[语义化版本 2.0.0](https://semver.org/)。 |\n| `rules[]`         | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg>                                                                                                      | 表示规则的 `reportingDescriptor` 对象数组。 分析工具使用规则来查找所分析代码中的问题。 有关详细信息，请参阅 [`reportingDescriptor` 对象](#reportingdescriptor-object)。                                                                               |\n\n###\n\n```\n          `reportingDescriptor` 对象\n```\n\n可在此处存储分析过程中运行的规则的详细信息。 这些对象中的信息应该很少更改，通常在更新工具时更改。 有关详细信息，请参阅上面的 [规则和结果](#rules-and-results) 。\n\n| 姓名   | 必选                                                                                                                                                                                                                                                                                                                        | Description |\n| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |\n| `id` | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg> | 规则的唯一标识符。   |\n\n```\n          `id` 是从 SARIF 文件的其他部分引用的，可能被 code scanning 用于在 GitHub 上显示 URL。 |\n```\n\n\\| `name` | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | 规则的名称。 Code scanning 显示名称，以允许在 GitHub 上按规则筛选结果。 限制为 255 个字符。 |\n\\| `shortDescription.text` | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg> | 规则的简介。 Code scanning 在 GitHub 上的相关结果旁边显示简短说明。 限制为 1024 个字符。\n\\| `fullDescription.text` | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg> | 规则的描述。 Code scanning 在 GitHub 上的相关结果旁边显示完整说明。 限制为 1024 个字符。\n\\| `defaultConfiguration.level` | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | 规则的默认严重性级别。 Code scanning 使用严重性级别来帮助你了解结果对于给定规则的重要程度。 默认情况下，`defaultConfiguration.level` 设置为 `warning`。 但是，可以通过在与结果关联的对象 `level` 中设置 `result` 属性，替代默认的规则级别。 有关详细信息，请参阅 [`result` 对象](#result-object)的相关文档。\n`defaultConfiguration.level` 的有效值为：`note`、`warning` 和 `error`。\n\\| `help.text` | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg> | 使用文本格式的规则的文档。 Code scanning 在相关结果旁边显示此帮助文档。\n\\| `help.markdown` |<svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | （建议）使用 Markdown 格式的规则的文档。 Code scanning 在相关结果旁边显示此帮助文档。 当 `help.markdown` 可用时，将显示它，而不是 `help.text`。\n\\| `properties.tags[]` | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | 字符串数组。 Code scanning 使用 `tags` 允许你在 GitHub 上筛选结果。 例如，可以筛选带标记 `security` 的所有结果。\n\\| `properties.precision` | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | （建议）一个字符串，指示此规则指示的结果为 true 的频率。 例如，如果已知某项规则的误报率较高，则其准确性应为 `low`。 Code scanning 在 GitHub 上按准确性对结果进行排序，使具有最高 `level` 和最高 `precision` 的结果显示在最前面。 可以是下述之一：`very-high`、`high`、`medium` 或 `low`。\n\\| `properties.problem.severity` | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | （建议）一个字符串，指示由非安全查询生成的任何警报的严重性级别。 这与 `properties.precision` 属性一起确定结果是否默认显示在 GitHub 上，使具有最高 `problem.severity` 和最高 `precision` 的结果显示在最前面。 可以是以下选项之一：`error`、`warning` 或 `recommendation`。\n\\| `properties.security-severity` | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | （建议仅用于安全规则）如果包含此字段的值，规则的结果将被视为安全结果。 一个表示分数的字符串，该分数指示安全查询的严重性级别，该值介于 0.0 到 10.0 之间（`@tags` 包括 `security`）。 这与 `properties.precision` 属性一起确定结果是否默认显示在 GitHub 上，使具有最高 `security-severity` 和最高 `precision` 的结果显示在最前面。 Code scanning 转换数值分数如下：超过 9.0 为 `critical`，7.0 至 8.9 为 `high`，4.0 至 6.9 为 `medium`，0.1 至 3.9 为 `low`。 值 0.0 或给定范围之外的任何其他值被视为没有安全严重性。\n\n###\n\n```\n          `result` 对象\n```\n\n每个 `result` 对象都包含代码库中一个警报的详细信息。 在 `results` 对象中，可以引用检测到警报的规则。 有关详细信息，请参阅上面的 [规则和结果](#rules-and-results) 。\n\n| 姓名             | 必选                                                                                                                                                                                                                                                                                                                                                                                                                             | Description                                                                                                                                      |\n| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `ruleId`       | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | 规则的唯一标识符 (`reportingDescriptor.id`)。 有关详细信息，请参阅 [`reportingDescriptor` 对象](#reportingdescriptor-object)。 Code scanning 使用规则标识符在 GitHub 上按规则筛选结果。 |\n| `ruleIndex`    | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | 工具组件 `reportingDescriptor` 数组中关联规则（`rules` 对象）的索引。 有关详细信息，请参阅 [`run` 对象](#run-object)。 此属性的允许范围 0 到 2^63 - 1。                                    |\n| `rule`         | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | 用于定位此结果的规则（报告描述符）的引用。 有关详细信息，请参阅 [`reportingDescriptor` 对象](#reportingdescriptor-object)。                                                        |\n| `level`        | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | 结果的严重性。 此级别覆盖规则定义的默认严重程度。 Code scanning 使用级别在 GitHub 上按严重性筛选结果。                                                                                  |\n| `message.text` | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg>                                                                                                      | 描述结果的消息。 Code scanning 显示消息文本作为结果的标题。 当可见空间有限时，仅显示消息的第一句。                                                                                        |\n| `locations[]`  | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg>                                                                                                      | 最多可以检测到 10 个结果的位置集。 应只包含一个位置，除非只能通过在每个指定位置进行更改来更正问题。                                                                                             |\n\n```\n          **注意：**code scanning 至少需要一个位置才能显示结果。 Code scanning 将使用此属性来决定要用结果注释哪个文件。 仅使用此数组的第一个值。 所有其他值都被忽略。\n```\n\n\\| `partialFingerprints`| <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg> | 一组字符串，用于跟踪结果的唯一标识。 Code scanning 使用 `partialFingerprints` 准确地识别在提交和分支之间相同的结果。 Code scanning 将尝试使用 `partialFingerprints`（如果存在）。 如果使用 `upload-action` 上传第三方 SARIF 文件，当这些文件未包含在 SARIF 文件中时，该操作将为你创建 `partialFingerprints`。 有关详细信息，请参阅[《在多次运行中提供用于跟踪代码扫描警报的数据》](#data-for-preventing-duplicated-alerts)。\n\\*\\*注意：\\*\\*Code scanning 仅使用 `primaryLocationLineHash`。\n\\| `codeFlows[].threadFlows[].locations[]`| <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> |\n`location` 对象的 `threadFlow` 对象数组，通过执行线程描述程序进度。\n`codeFlow` 对象描述用于检测结果的代码执行模式。 如果提供了代码流，code scanning 将在 GitHub 上扩展代码流以获取相关结果。 有关详细信息，请参阅 [`location` 对象](#location-object)。\n\\| `relatedLocations[]`| <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | 与此结果相关的一组位置。 当相关位置嵌入在结果消息中时，Code scanning 将链接到这些位置。 有关详细信息，请参阅 [`location` 对象](#location-object)。\n\n###\n\n```\n          `location` 对象\n```\n\n编程构件中的位置，例如仓库中的文件或在构建过程中生成的文件。\n\n| 姓名                          | 必选                                                                                                                                                                                                                                                                                                                                                                                                                             | Description                                                         |\n| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------- |\n| `location.id`               | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | 用于在单个结果对象中区分此位置与所有其他位置的唯一标识符。 此属性的允许范围 0 到 2^63 - 1。                |\n| `location.physicalLocation` | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg>                                                                                                      | 标识构件和区域。 有关详细信息，请参阅 [`physicalLocation`](#physicallocation-object)。 |\n| `location.message.text`     | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | 与位置相关的消息。                                                           |\n\n###\n\n```\n          `physicalLocation` 对象\n```\n\n| 姓名                     | 必选                                                                                                                                                                                                                                                                                                                        | Description                                                                                                                                             |\n| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `artifactLocation.uri` | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg> | 表示构件位置的 URI，通常是存储库中或在构建期间生成的文件。 为了获得最佳结果，建议这是所分析的 GitHub 存储库根的相对路径。 例如，`src/main.js`。 有关构件 URI 的详细信息，请参阅[《指定源文件的根目录》](#root-location-for-source-files)。 |\n| `region.startLine`     | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg> | 区域中第一个字符的行号。                                                                                                                                            |\n| `region.startColumn`   | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg> | 区域中第一个字符的列号。                                                                                                                                            |\n| `region.endLine`       | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg> | 区域中最后一个字符的行号。                                                                                                                                           |\n| `region.endColumn`     | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-check\" aria-label=\"check icon\" role=\"img\"><path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\"></path></svg> | 区域末尾后面的字符的列号。                                                                                                                                           |\n\n###\n\n```\n          `runAutomationDetails` 对象\n\n          `runAutomationDetails` 对象包含指定运行标识的信息。\n```\n\n| 姓名   | 必选                                                                                                                                                                                                                                                                                                                                                                                                                             | Description                                                      |\n| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------- |\n| `id` | <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-x\" aria-label=\"Optional\" role=\"img\"><path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\"></path></svg> | 标识分析和运行 ID 类别的字符串。 如果您想要为同一工具上传多个 SARIF 文件，但在不同语言或代码的不同部分执行，请使用。 |\n\n使用 `runAutomationDetails` 对象是可选的。\n\n```\n          `id` 字段可以包含分析类别和运行 ID。 我们不使用 `id` 字段的运行 ID 部分，但会存储它。\n```\n\n使用类别来区分同一工具或提交的多次分析，但是在不同语言或代码的不同部分进行。 使用运行 ID 来识别分析的特定运行，例如分析的运行日期。\n\n```\n          `id` 被解释为 `category/run-id`。 如果 `id` 不包含正斜杠 (`/`)，则整个字符串为 `run_id`，而 `category` 为空。 否则，`category` 是字符串中直到最后一个正斜杠的所有内容，而 `run_id` 是之后的所有内容。\n```\n\n| `id`                         | 分类                | `run_id`   |\n| ---------------------------- | ----------------- | ---------- |\n| my-analysis/tool1/2022-01-02 | my-analysis/tool1 | 2022-01-02 |\n| my-analysis/tool1/           | my-analysis/tool1 | None       |\n| 工具 1 的我的分析                   | None              | 工具 1 的我的分析 |\n\n* `id` 为“my-analysis/tool1/2021-02-01”的运行属于类别“my-analysis/tool1”。\n* `id` 为“my-analysis/tool1/”的运行属于类别“my-analysis/tool1”，但未与该类别中的其他运行区分。\n* `id` 为“my-analysis for tool1”的运行具有唯一的标识符，但无法推断属于任何类别。\n\n有关 `runAutomationDetails` 对象和 `id` 字段的详细信息，请参阅 OASIS 文档中的 [runAutomationDetails 对象](https://docs.oasis-open.org/sarif/sarif/v2.1.0/cs01/sarif-v2.1.0-cs01.html#_Toc16012479)。\n\n请注意，将忽略其余支持的字段。\n\n## SARIF 输出文件示例\n\n这些示例 SARIF 输出文件显示支持的属性和示例值。\n\n### 具有最少必需属性的示例\n\n此 SARIF 输出文件的示例值显示了 code scanning 结果正常运行所需的最少属性。 如果移除任何属性、省略值或使用空字符串，此数据将无法正确显示或在 GitHub 上同步。\n\n```json\n{\n  \"$schema\": \"https://json.schemastore.org/sarif-2.1.0.json\",\n  \"version\": \"2.1.0\",\n  \"runs\": [\n    {\n      \"tool\": {\n        \"driver\": {\n          \"name\": \"Tool Name\",\n          \"rules\": [\n            {\n              \"id\": \"R01\"\n                      ...\n              \"properties\" : {\n                 \"id\" : \"java/unsafe-deserialization\",\n                 \"kind\" : \"path-problem\",\n                 \"name\" : \"...\",\n                 \"problem.severity\" : \"error\",\n                 \"security-severity\" : \"9.8\",\n               }\n            }\n          ]\n        }\n      },\n      \"results\": [\n        {\n          \"ruleId\": \"R01\",\n          \"message\": {\n            \"text\": \"Result text. This result does not have a rule associated.\"\n          },\n          \"locations\": [\n            {\n              \"physicalLocation\": {\n                \"artifactLocation\": {\n                  \"uri\": \"fileURI\"\n                },\n                \"region\": {\n                  \"startLine\": 2,\n                  \"startColumn\": 7,\n                  \"endColumn\": 10\n                }\n              }\n            }\n          ],\n          \"partialFingerprints\": {\n            \"primaryLocationLineHash\": \"39fa2ee980eb94b0:1\"\n          }\n        }\n      ]\n    }\n  ]\n}\n```\n\n### SARIF 生成器的相对 URI 指南\n\n此 SARIF 输出文件提供了字段 `originalUriBaseIds` 的示例值，展示了在使用相对 URI 引用时，SARIF 生成器应包含的最低必需属性。\n\n> \\[!NOTE]\n> 虽然 GitHub 并不要求此属性即可正确显示 code scanning 结果，但在使用相对 URI 引用时，生成有效的 SARIF 输出则必须包含该属性。\n\n```json\n{\n  \"$schema\": \"https://json.schemastore.org/sarif-2.1.0.json\",\n  \"version\": \"2.1.0\",\n  \"runs\": [\n    {\n      \"tool\": {\n        \"driver\": {\n          \"name\": \"Tool Name\",\n          \"rules\": [\n            {\n              \"id\": \"R01\"\n                      ...\n              \"properties\" : {\n                 \"id\" : \"java/unsafe-deserialization\",\n                 \"kind\" : \"path-problem\",\n                 \"name\" : \"...\",\n                 \"problem.severity\" : \"error\",\n                 \"security-severity\" : \"9.8\",\n               }\n            }\n          ]\n        }\n      },\n      \"originalUriBaseIds\": {\n        \"PROJECTROOT\": {\n         \"uri\": \"file:///C:/Users/Mary/code/TheProject/\",\n           \"description\": {\n             \"text\": \"The root directory for all project files.\"\n           }\n        },\n         \"%SRCROOT%\": {\n           \"uri\": \"src/\",\n           \"uriBaseId\": \"PROJECTROOT\",\n           \"description\": {\n             \"text\": \"The root of the source tree.\"\n           }\n         }\n      },\n      \"results\": [\n        {\n          \"ruleId\": \"R01\",\n          \"message\": {\n            \"text\": \"Result text. This result does not have a rule associated.\"\n          },\n          \"locations\": [\n            {\n              \"physicalLocation\": {\n                \"artifactLocation\": {\n                  \"uri\": \"fileURI\",\n                  \"uriBaseId\": \"%SRCROOT%\"\n                },\n                \"region\": {\n                  \"startLine\": 2,\n                  \"startColumn\": 7,\n                  \"endColumn\": 10\n                }\n              }\n            }\n          ],\n          \"partialFingerprints\": {\n            \"primaryLocationLineHash\": \"39fa2ee980eb94b0:1\"\n          }\n        }\n      ]\n    }\n  ]\n}\n```\n\n### 显示所有支持的 SARIF 属性的示例\n\n此 SARIF 输出文件的示例值显示了 code scanning 的所有受支持 SARIF 属性。\n\n```json\n{\n  \"$schema\": \"https://json.schemastore.org/sarif-2.1.0.json\",\n  \"version\": \"2.1.0\",\n  \"runs\": [\n    {\n      \"tool\": {\n        \"driver\": {\n          \"name\": \"Tool Name\",\n          \"semanticVersion\": \"2.0.0\",\n          \"rules\": [\n            {\n              \"id\": \"3f292041e51d22005ce48f39df3585d44ce1b0ad\",\n              \"name\": \"js/unused-local-variable\",\n              \"shortDescription\": {\n                \"text\": \"Unused variable, import, function or class\"\n              },\n              \"fullDescription\": {\n                \"text\": \"Unused variables, imports, functions or classes may be a symptom of a bug and should be examined carefully.\"\n              },\n              \"defaultConfiguration\": {\n                \"level\": \"note\"\n              },\n              \"properties\": {\n                \"tags\": [\n                  \"maintainability\"\n                ],\n                \"precision\": \"very-high\"\n              }\n            },\n            {\n              \"id\": \"d5b664aefd5ca4b21b52fdc1d744d7d6ab6886d0\",\n              \"name\": \"js/inconsistent-use-of-new\",\n              \"shortDescription\": {\n                \"text\": \"Inconsistent use of 'new'\"\n              },\n              \"fullDescription\": {\n                \"text\": \"If a function is intended to be a constructor, it should always be invoked with 'new'. Otherwise, it should always be invoked as a normal function, that is, without 'new'.\"\n              },\n              \"properties\": {\n                \"tags\": [\n                  \"reliability\",\n                  \"correctness\",\n                  \"language-features\"\n                ],\n                \"precision\": \"very-high\"\n              }\n            },\n            {\n              \"id\": \"R01\"\n            }\n          ]\n        }\n      },\n      \"automationDetails\": {\n        \"id\": \"my-category/\"\n      },\n      \"results\": [\n        {\n          \"ruleId\": \"3f292041e51d22005ce48f39df3585d44ce1b0ad\",\n          \"ruleIndex\": 0,\n          \"message\": {\n            \"text\": \"Unused variable foo.\"\n          },\n          \"locations\": [\n            {\n              \"physicalLocation\": {\n                \"artifactLocation\": {\n                  \"uri\": \"main.js\",\n                  \"uriBaseId\": \"%SRCROOT%\"\n                },\n                \"region\": {\n                  \"startLine\": 2,\n                  \"startColumn\": 7,\n                  \"endColumn\": 10\n                }\n              }\n            }\n          ],\n          \"partialFingerprints\": {\n            \"primaryLocationLineHash\": \"39fa2ee980eb94b0:1\",\n            \"primaryLocationStartColumnFingerprint\": \"4\"\n          }\n        },\n        {\n          \"ruleId\": \"d5b664aefd5ca4b21b52fdc1d744d7d6ab6886d0\",\n          \"ruleIndex\": 1,\n          \"message\": {\n            \"text\": \"Function resolvingPromise is sometimes invoked as a constructor (for example [here](1)), and sometimes as a normal function (for example [here](2)).\"\n          },\n          \"locations\": [\n            {\n              \"physicalLocation\": {\n                \"artifactLocation\": {\n                  \"uri\": \"src/promises.js\",\n                  \"uriBaseId\": \"%SRCROOT%\"\n                },\n                \"region\": {\n                  \"startLine\": 2\n                }\n              }\n            }\n          ],\n          \"partialFingerprints\": {\n            \"primaryLocationLineHash\": \"5061c3315a741b7d:1\",\n            \"primaryLocationStartColumnFingerprint\": \"7\"\n          },\n          \"relatedLocations\": [\n            {\n              \"id\": 1,\n              \"physicalLocation\": {\n                \"artifactLocation\": {\n                  \"uri\": \"src/ParseObject.js\",\n                  \"uriBaseId\": \"%SRCROOT%\"\n                },\n                \"region\": {\n                  \"startLine\": 2281,\n                  \"startColumn\": 33,\n                  \"endColumn\": 55\n                }\n              },\n              \"message\": {\n                \"text\": \"here\"\n              }\n            },\n            {\n              \"id\": 2,\n              \"physicalLocation\": {\n                \"artifactLocation\": {\n                  \"uri\": \"src/LiveQueryClient.js\",\n                  \"uriBaseId\": \"%SRCROOT%\"\n                },\n                \"region\": {\n                  \"startLine\": 166\n                }\n              },\n              \"message\": {\n                \"text\": \"here\"\n              }\n            }\n          ]\n        },\n        {\n          \"ruleId\": \"R01\",\n          \"message\": {\n            \"text\": \"Specifying both [ruleIndex](1) and [ruleId](2) might lead to inconsistencies.\"\n          },\n          \"level\": \"error\",\n          \"locations\": [\n            {\n              \"physicalLocation\": {\n                \"artifactLocation\": {\n                  \"uri\": \"full.sarif\",\n                  \"uriBaseId\": \"%SRCROOT%\"\n                },\n                \"region\": {\n                  \"startLine\": 54,\n                  \"startColumn\": 10,\n                  \"endLine\": 55,\n                  \"endColumn\": 25\n                }\n              }\n            }\n          ],\n          \"relatedLocations\": [\n            {\n              \"id\": 1,\n              \"physicalLocation\": {\n                \"artifactLocation\": {\n                  \"uri\": \"full.sarif\"\n                },\n                \"region\": {\n                  \"startLine\": 81,\n                  \"startColumn\": 10,\n                  \"endColumn\": 18\n                }\n              },\n              \"message\": {\n                \"text\": \"here\"\n              }\n            },\n            {\n              \"id\": 2,\n              \"physicalLocation\": {\n                \"artifactLocation\": {\n                  \"uri\": \"full.sarif\"\n                },\n                \"region\": {\n                  \"startLine\": 82,\n                  \"startColumn\": 10,\n                  \"endColumn\": 21\n                }\n              },\n              \"message\": {\n                \"text\": \"here\"\n              }\n            }\n          ],\n          \"codeFlows\": [\n            {\n              \"threadFlows\": [\n                {\n                  \"locations\": [\n                    {\n                      \"location\": {\n                        \"physicalLocation\": {\n                          \"region\": {\n                            \"startLine\": 11,\n                            \"endLine\": 29,\n                            \"startColumn\": 10,\n                            \"endColumn\": 18\n                          },\n                          \"artifactLocation\": {\n                            \"uriBaseId\": \"%SRCROOT%\",\n                            \"uri\": \"full.sarif\"\n                          }\n                        },\n                        \"message\": {\n                          \"text\": \"Rule has index 0\"\n                        }\n                      }\n                    },\n                    {\n                      \"location\": {\n                        \"physicalLocation\": {\n                          \"region\": {\n                            \"endColumn\": 47,\n                            \"startColumn\": 12,\n                            \"startLine\": 12\n                          },\n                          \"artifactLocation\": {\n                            \"uriBaseId\": \"%SRCROOT%\",\n                            \"uri\": \"full.sarif\"\n                          }\n                        }\n                      }\n                    }\n                  ]\n                }\n              ]\n            }\n          ],\n          \"partialFingerprints\": {\n            \"primaryLocationLineHash\": \"ABC:2\"\n          }\n        }\n      ],\n      \"columnKind\": \"utf16CodeUnits\"\n    }\n  ]\n}\n```"}