sarif.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. package sarif
  2. const Version = "2.1.0"
  3. const Schema = "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json"
  4. type Log struct {
  5. Version string `json:"version"`
  6. Schema string `json:"$schema"`
  7. Runs []Run `json:"runs"`
  8. }
  9. type Run struct {
  10. Tool Tool `json:"tool"`
  11. Results []Result `json:"results,omitempty"`
  12. Invocations []Invocation `json:"invocations,omitempty"`
  13. Artifacts []Artifact `json:"artifacts,omitempty"`
  14. }
  15. type Artifact struct {
  16. Location ArtifactLocation `json:"location"`
  17. Length int `json:"length"`
  18. SourceLanguage string `json:"sourceLanguage"`
  19. Roles []string `json:"roles"`
  20. Encoding string `json:"encoding"`
  21. }
  22. const (
  23. AnalysisTarget = "analysisTarget"
  24. UTF8 = "UTF-8"
  25. Fail = "fail"
  26. Warning = "warning"
  27. Error = "error"
  28. Note = "note"
  29. None = "none"
  30. )
  31. type Hash struct {
  32. Sha256 string `json:"sha-256"`
  33. }
  34. type Tool struct {
  35. Driver ToolComponent `json:"driver"`
  36. }
  37. type Invocation struct {
  38. CommandLine string `json:"commandLine,omitempty"`
  39. Arguments []string `json:"arguments,omitempty"`
  40. WorkingDirectory ArtifactLocation `json:"workingDirectory,omitempty"`
  41. ExecutionSuccessful bool `json:"executionSuccessful"`
  42. }
  43. type ToolComponent struct {
  44. Name string `json:"name,omitempty"`
  45. Version string `json:"version,omitempty"`
  46. SemanticVersion string `json:"semanticVersion,omitempty"`
  47. InformationURI string `json:"informationUri,omitempty"`
  48. Rules []ReportingDescriptor `json:"rules,omitempty"`
  49. }
  50. type ReportingDescriptor struct {
  51. ID string `json:"id"`
  52. ShortDescription Message `json:"shortDescription"`
  53. // FullDescription Message `json:"fullDescription"`
  54. Help Message `json:"help"`
  55. HelpURI string `json:"helpUri,omitempty"`
  56. DefaultConfiguration ReportingConfiguration `json:"defaultConfiguration"`
  57. }
  58. type ReportingConfiguration struct {
  59. Enabled bool `json:"enabled"`
  60. Level string `json:"level,omitempty"`
  61. Parameters map[string]interface{} `json:"parameters,omitempty"`
  62. }
  63. type Result struct {
  64. RuleID string `json:"ruleId"`
  65. // RuleIndex int `json:"ruleIndex"`
  66. Kind string `json:"kind"`
  67. Level string `json:"level,omitempty"`
  68. Message Message `json:"message"`
  69. Locations []Location `json:"locations,omitempty"`
  70. RelatedLocations []Location `json:"relatedLocations,omitempty"`
  71. Fixes []Fix `json:"fixes,omitempty"`
  72. Suppressions []Suppression `json:"suppressions"`
  73. }
  74. type Suppression struct {
  75. Kind string `json:"kind"`
  76. Justification string `json:"justification"`
  77. }
  78. type Fix struct {
  79. Description Message `json:"description"`
  80. ArtifactChanges []ArtifactChange `json:"artifactChanges"`
  81. }
  82. type ArtifactChange struct {
  83. ArtifactLocation ArtifactLocation `json:"artifactLocation"`
  84. Replacements []Replacement `json:"replacements"`
  85. }
  86. type Replacement struct {
  87. DeletedRegion Region `json:"deletedRegion"`
  88. InsertedContent ArtifactContent `json:"insertedContent"`
  89. }
  90. type ArtifactContent struct {
  91. Text string `json:"text"`
  92. }
  93. type Message struct {
  94. Text string `json:"text,omitempty"`
  95. Markdown string `json:"markdown,omitempty"`
  96. }
  97. type Location struct {
  98. ID int `json:"id,omitempty"`
  99. Message *Message `json:"message,omitempty"`
  100. PhysicalLocation PhysicalLocation `json:"physicalLocation"`
  101. }
  102. type PhysicalLocation struct {
  103. ArtifactLocation ArtifactLocation `json:"artifactLocation"`
  104. Region Region `json:"region"`
  105. }
  106. type ArtifactLocation struct {
  107. URI string `json:"uri,omitempty"`
  108. Index int `json:"index,omitempty"`
  109. URIBaseID string `json:"uriBaseId,omitempty"`
  110. }
  111. type Region struct {
  112. StartLine int `json:"startLine"`
  113. StartColumn int `json:"startColumn"`
  114. EndLine int `json:"endLine,omitempty"`
  115. EndColumn int `json:"endColumn,omitempty"`
  116. }