Skip to content

Commit 1781a05

Browse files
author
Julia
committed
chore(-): update sast schema to 15.0.6
1 parent 6e6098c commit 1781a05

File tree

4 files changed

+83
-94
lines changed

4 files changed

+83
-94
lines changed

Diff for: docs/results.md

+10-23
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,17 @@ Gitlab SAST reports are sorted by severity (from high to info), following [Gitla
318318

319319
```json
320320
{
321-
"schema": "https://gitlab.com/gitlab-org/security-products/security-report-schemas/-/raw/v14.1.0/dist/sast-report-format.json",
322-
"version": "14.1.0",
321+
"schema": "https://gitlab.com/gitlab-org/security-products/security-report-schemas/-/raw/v15.0.6/dist/sast-report-format.json",
322+
"version": "15.0.6",
323323
"scan": {
324+
"analyzer": {
325+
"id": "keeping-infrastructure-as-code-secure",
326+
"name": "Keeping Infrastructure as Code Secure",
327+
"version": "1.2.0",
328+
"vendor":{
329+
"name": "Checkmarx"
330+
}
331+
},
324332
"start_time": "2021-05-26T17:22:13",
325333
"end_time": "2021-05-26T17:22:13",
326334
"status": "success",
@@ -338,15 +346,8 @@ Gitlab SAST reports are sorted by severity (from high to info), following [Gitla
338346
"vulnerabilities": [
339347
{
340348
"id": "32e763ac363dfee1ea972d951fb3de00f5f7a8d3f9f57b93e55e2d51957794a6",
341-
"category": "sast",
342349
"severity": "High",
343-
"cve": "32e763ac363dfee1ea972d951fb3de00f5f7a8d3f9f57b93e55e2d51957794a6",
344-
"scanner": {
345-
"id": "keeping_infrastructure_as_code_secure",
346-
"name": "Keeping Infrastructure as Code Secure"
347-
},
348350
"name": "Container Is Privileged",
349-
"message": "Do not allow container to be privileged.",
350351
"links": [
351352
{
352353
"url": "https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/pod#privileged"
@@ -368,15 +369,8 @@ Gitlab SAST reports are sorted by severity (from high to info), following [Gitla
368369
},
369370
{
370371
"id": "32e763ac363dfee1ea972d951fb3de00f5f7a8d3f9f57b93e55e2d51957794a6",
371-
"category": "sast",
372372
"severity": "High",
373-
"cve": "32e763ac363dfee1ea972d951fb3de00f5f7a8d3f9f57b93e55e2d51957794a6",
374-
"scanner": {
375-
"id": "keeping_infrastructure_as_code_secure",
376-
"name": "Keeping Infrastructure as Code Secure"
377-
},
378373
"name": "Container Is Privileged",
379-
"message": "Do not allow container to be privileged.",
380374
"links": [
381375
{
382376
"url": "https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/pod#privileged"
@@ -398,15 +392,8 @@ Gitlab SAST reports are sorted by severity (from high to info), following [Gitla
398392
},
399393
{
400394
"id": "3d4f14f3ac2ebc0d2cb1710eec4f61fae359fe78ab244cb716485cb6c90846f6",
401-
"category": "sast",
402395
"severity": "High",
403-
"cve": "3d4f14f3ac2ebc0d2cb1710eec4f61fae359fe78ab244cb716485cb6c90846f6",
404-
"scanner": {
405-
"id": "keeping_infrastructure_as_code_secure",
406-
"name": "Keeping Infrastructure as Code Secure"
407-
},
408396
"name": "Container Is Privileged",
409-
"message": "Do not allow container to be privileged.",
410397
"links": [
411398
{
412399
"url": "https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/pod#privileged"

Diff for: e2e/fixtures/schemas/result-gl-sast.json

+41-35
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,58 @@
1818
"scan": {
1919
"type": "object",
2020
"required": [
21+
"analyzer",
2122
"start_time",
2223
"end_time",
2324
"status",
2425
"type",
2526
"scanner"
2627
],
2728
"properties": {
29+
"analyzer": {
30+
"type": "object",
31+
"required": [
32+
"id",
33+
"name",
34+
"version",
35+
"vendor"
36+
],
37+
"properties": {
38+
"id": {
39+
"type": "string",
40+
"minLength": 1
41+
},
42+
"name": {
43+
"type": "string",
44+
"minLength": 1
45+
},
46+
"url": {
47+
"type": "string",
48+
"format": "uri",
49+
"pattern": "^https?://.+"
50+
},
51+
"vendor": {
52+
"type": "object",
53+
"required": [
54+
"name"
55+
],
56+
"properties": {
57+
"name": {
58+
"type": "string",
59+
"minLength": 1
60+
}
61+
}
62+
}
63+
}
64+
},
2865
"start_time": {
2966
"type": "string",
3067
"minLength": 1
3168
},
3269
"end_time": {
3370
"type": "string",
34-
"minLength": 1
71+
"minLength": 1,
72+
"pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$"
3573
},
3674
"status": {
3775
"type": "string",
@@ -89,12 +127,8 @@
89127
"type": "object",
90128
"required": [
91129
"id",
92-
"category",
93130
"severity",
94-
"cve",
95-
"scanner",
96131
"name",
97-
"message",
98132
"links",
99133
"location",
100134
"identifiers"
@@ -104,10 +138,6 @@
104138
"type": "string",
105139
"pattern": "^[A-Fa-f0-9]{64}$"
106140
},
107-
"category": {
108-
"type": "string",
109-
"minLength": 1
110-
},
111141
"severity": {
112142
"type": "string",
113143
"enum": [
@@ -117,34 +147,10 @@
117147
"Info"
118148
]
119149
},
120-
"cve": {
121-
"type": "string",
122-
"pattern": "^[A-Fa-f0-9]{64}$"
123-
},
124-
"scanner": {
125-
"type": "object",
126-
"required": [
127-
"id",
128-
"name"
129-
],
130-
"properties": {
131-
"id": {
132-
"type": "string",
133-
"minLength": 1
134-
},
135-
"name": {
136-
"type": "string",
137-
"minLength": 1
138-
}
139-
}
140-
},
141150
"name": {
142151
"type": "string",
143-
"minLength": 1
144-
},
145-
"message": {
146-
"type": "string",
147-
"minLength": 1
152+
"minLength": 1,
153+
"maxLength": 255
148154
},
149155
"links": {
150156
"type": "array",

Diff for: pkg/report/model/gitlab_sast.go

+29-25
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ type gitlabSASTReport struct {
2121
}
2222

2323
type gitlabSASTScan struct {
24-
StartTime string `json:"start_time"`
25-
EndTime string `json:"end_time"`
26-
Status string `json:"status"`
27-
Scantype string `json:"type"`
28-
Scanner gitlabSASTScanner `json:"scanner"`
24+
Analyzer gitlabSASTAnalyzer `json:"analyzer"`
25+
StartTime string `json:"start_time"`
26+
EndTime string `json:"end_time"`
27+
Status string `json:"status"`
28+
Scantype string `json:"type"`
29+
Scanner gitlabSASTScanner `json:"scanner"`
2930
}
3031

3132
type gitlabSASTScanner struct {
@@ -44,27 +45,23 @@ type gitlabSASTVulnerabilityDetails map[string]interface{}
4445

4546
type gitlabSASTVulnerability struct {
4647
ID string `json:"id"`
47-
Category string `json:"category"`
4848
Severity string `json:"severity"`
49-
CVE string `json:"cve"`
50-
Scanner gitlabSASTVulnerabilityScanner `json:"scanner"`
5149
Name string `json:"name"`
52-
Message string `json:"message"`
5350
Links []gitlabSASTVulnerabilityLink `json:"links"`
5451
Location gitlabSASTVulnerabilityLocation `json:"location"`
5552
Identifiers []gitlabSASTVulnerabilityIdentifier `json:"identifiers"`
5653
Details gitlabSASTVulnerabilityDetails `json:"details,omitempty"`
5754
}
5855

56+
type gitlabSASTVulnerabilityLink struct {
57+
URL string `json:"url"`
58+
}
59+
5960
type gitlabSASTVulnerabilityScanner struct {
6061
ID string `json:"id"`
6162
Name string `json:"name"`
6263
}
6364

64-
type gitlabSASTVulnerabilityLink struct {
65-
URL string `json:"url"`
66-
}
67-
6865
type gitlabSASTVulnerabilityLocation struct {
6966
File string `json:"file"`
7067
Start int `json:"start_line"`
@@ -78,23 +75,38 @@ type gitlabSASTVulnerabilityIdentifier struct {
7875
Value string `json:"value"`
7976
}
8077

78+
type gitlabSASTAnalyzer struct {
79+
ID string `json:"id"`
80+
Name string `json:"name"`
81+
Version string `json:"version"`
82+
Vendor gitlabSASTScannerVendor `json:"vendor"`
83+
}
84+
8185
// GitlabSASTReport represents a usable gitlab sast report reference
8286
type GitlabSASTReport interface {
8387
BuildGitlabSASTVulnerability(issue *model.QueryResult, file *model.VulnerableFile)
8488
}
8589

86-
// NewGitlabSASTReport initializes a new instance of GitlabSASTReport to be uses
90+
// NewGitlabSASTReport initializes a new instance of GitlabSASTReport to be used
8791
func NewGitlabSASTReport(start, end time.Time) GitlabSASTReport {
8892
return &gitlabSASTReport{
89-
Schema: "https://gitlab.com/gitlab-org/security-products/security-report-schemas/-/raw/v14.1.0/dist/sast-report-format.json",
90-
SchemaVersion: "14.0.1",
93+
Schema: "https://gitlab.com/gitlab-org/security-products/security-report-schemas/-/raw/v15.0.6/dist/sast-report-format.json",
94+
SchemaVersion: "15.0.6",
9195
Scan: initGitlabSASTScan(start, end),
9296
Vulnerabilities: make([]gitlabSASTVulnerability, 0),
9397
}
9498
}
9599

96100
func initGitlabSASTScan(start, end time.Time) gitlabSASTScan {
97101
return gitlabSASTScan{
102+
Analyzer: gitlabSASTAnalyzer{
103+
ID: "keeping-infrastructure-as-code-secure",
104+
Name: constants.Fullname,
105+
Version: constants.Version,
106+
Vendor: gitlabSASTScannerVendor{
107+
Name: "Checkmarx",
108+
},
109+
},
98110
Status: "success",
99111
Scantype: "sast",
100112
StartTime: start.Format(timeFormat),
@@ -116,15 +128,8 @@ func (glsr *gitlabSASTReport) BuildGitlabSASTVulnerability(issue *model.QueryRes
116128
if len(issue.Files) > 0 {
117129
vulnerability := gitlabSASTVulnerability{
118130
ID: file.SimilarityID,
119-
Category: "sast",
120131
Severity: cases.Title(language.Und).String(strings.ToLower(string(issue.Severity))),
121-
CVE: file.SimilarityID,
122-
Scanner: gitlabSASTVulnerabilityScanner{
123-
ID: "keeping_infrastructure_as_code_secure",
124-
Name: constants.Fullname,
125-
},
126-
Name: issue.QueryName,
127-
Message: issue.Description,
132+
Name: issue.QueryName,
128133
Links: []gitlabSASTVulnerabilityLink{
129134
{
130135
URL: issue.QueryURI,
@@ -145,7 +150,6 @@ func (glsr *gitlabSASTReport) BuildGitlabSASTVulnerability(issue *model.QueryRes
145150
},
146151
}
147152
if issue.CISDescriptionID != "" {
148-
vulnerability.Message = issue.CISDescriptionTextFormatted
149153
vulnerability.Details = gitlabSASTVulnerabilityDetails{
150154
"cisTitle": issue.CISDescriptionTitle,
151155
"cisId": issue.CISDescriptionIDFormatted,

Diff for: pkg/report/model/gitlab_sast_test.go

+3-11
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ func TestNewGitlabSASTReport(t *testing.T) {
1616
glSAST := NewGitlabSASTReport(start, end).(*gitlabSASTReport)
1717
require.Equal(
1818
t,
19-
"https://gitlab.com/gitlab-org/security-products/security-report-schemas/-/raw/v14.1.0/dist/sast-report-format.json",
19+
"https://gitlab.com/gitlab-org/security-products/security-report-schemas/-/raw/v15.0.6/dist/sast-report-format.json",
2020
glSAST.Schema,
2121
)
22-
require.Equal(t, "14.0.1", glSAST.SchemaVersion)
22+
require.Equal(t, "15.0.6", glSAST.SchemaVersion)
2323
require.Equal(t, constants.Fullname, glSAST.Scan.Scanner.Name)
2424
require.Equal(t, constants.URL, glSAST.Scan.Scanner.URL)
2525
require.Equal(t, end.Format(timeFormat), glSAST.Scan.EndTime)
@@ -57,7 +57,6 @@ var tests = []gitlabSASTTest{
5757
Description: "test description",
5858
QueryURI: "https://www.test.com",
5959
Severity: model.SeverityHigh,
60-
Category: "sast",
6160
Files: []model.VulnerableFile{
6261
{KeyActualValue: "test", FileName: "test.json", Line: 1, SimilarityID: "similarity"},
6362
},
@@ -72,15 +71,8 @@ var tests = []gitlabSASTTest{
7271
Vulnerabilities: []gitlabSASTVulnerability{
7372
{
7473
ID: "similarity",
75-
Category: "sast",
7674
Severity: "High",
77-
CVE: "similarity",
78-
Scanner: gitlabSASTVulnerabilityScanner{
79-
ID: "keeping_infrastructure_as_code_secure",
80-
Name: constants.Fullname,
81-
},
82-
Name: "test",
83-
Message: "test description",
75+
Name: "test",
8476
Links: []gitlabSASTVulnerabilityLink{
8577
{
8678
URL: "https://www.test.com",

0 commit comments

Comments
 (0)