forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadditional-finding.js
More file actions
209 lines (201 loc) · 6.36 KB
/
Copy pathadditional-finding.js
File metadata and controls
209 lines (201 loc) · 6.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
import { GraphQLObjectType, GraphQLList, GraphQLString } from 'graphql'
import { GraphQLDateTime } from 'graphql-scalars'
export const additionalFinding = new GraphQLObjectType({
name: 'AdditionalFinding',
fields: () => ({
timestamp: {
type: GraphQLDateTime,
description: `The date the finding was discovered.`,
resolve: ({ timestamp }) => new Date(timestamp),
},
locations: {
type: new GraphQLList(webComponentLocationType),
description: `The locations the finding was discovered.`,
resolve: ({ locations }) => locations,
},
ports: {
type: new GraphQLList(webComponentPortType),
description: `The ports the finding was discovered.`,
resolve: ({ ports }) => ports,
},
headers: {
type: new GraphQLList(GraphQLString),
description: `The headers the finding was discovered.`,
resolve: ({ headers }) => headers,
},
webComponents: {
type: new GraphQLList(webConnectionType),
description: `The web components the finding was discovered.`,
resolve: ({ webComponents }) => webComponents,
},
vulnerabilities: {
type: vulnerabilitesType,
description: `The vulnerabilities the finding was discovered.`,
resolve: ({ webComponents }) => {
const cves = []
for (const webComponent of webComponents) {
cves.push(...webComponent.WebComponentCves)
}
const jsonObject = cves.map(JSON.stringify)
const uniqueSet = new Set(jsonObject)
const uniqueArray = Array.from(uniqueSet).map(JSON.parse)
const critical = uniqueArray.filter((cve) => cve.Cvss3Score >= 9)
const high = uniqueArray.filter((cve) => cve.Cvss3Score >= 7 && cve.Cvss3Score < 9)
const medium = uniqueArray.filter((cve) => cve.Cvss3Score >= 4 && cve.Cvss3Score < 7)
const low = uniqueArray.filter((cve) => cve.Cvss3Score < 4)
return { critical, high, medium, low }
},
},
}),
description: `A finding imported from an external ASM tool.`,
})
export const webConnectionType = new GraphQLObjectType({
name: 'WebConnectionType',
fields: () => ({
webComponentName: {
type: GraphQLString,
description: `The URL of the web component.`,
resolve: ({ WebComponentName }) => WebComponentName,
},
webComponentCategory: {
type: GraphQLString,
description: `The type of web component.`,
resolve: ({ WebComponentCategory }) => WebComponentCategory,
},
webComponentVersion: {
type: GraphQLString,
description: `The status of the web component.`,
resolve: ({ WebComponentVersion }) => WebComponentVersion,
},
webComponentCves: {
type: new GraphQLList(webComponentCveType),
description: '',
resolve: ({ WebComponentCves }) => WebComponentCves,
},
webComponentPorts: {
type: new GraphQLList(webComponentPortType),
description: '',
resolve: ({ WebComponentPorts }) => WebComponentPorts,
},
webComponentFirstSeen: {
type: GraphQLString,
description: '',
resolve: ({ WebComponentFirstSeen }) => WebComponentFirstSeen,
},
webComponentLastSeen: {
type: GraphQLString,
description: '',
resolve: ({ WebComponentLastSeen }) => WebComponentLastSeen,
},
}),
})
export const webComponentLocationType = new GraphQLObjectType({
name: 'WebComponentLocation',
fields: () => ({
region: {
type: GraphQLString,
description: `The location of the finding.`,
resolve: ({ Region }) => Region,
},
city: {
type: GraphQLString,
description: `The location of the finding.`,
resolve: ({ City }) => City,
},
latitude: {
type: GraphQLString,
description: `The location of the finding.`,
resolve: ({ Latitude }) => Latitude,
},
longitude: {
type: GraphQLString,
description: `The location of the finding.`,
resolve: ({ Longitude }) => Longitude,
},
firstSeen: {
type: GraphQLString,
description: `The location of the finding.`,
resolve: ({ FirstSeen }) => FirstSeen,
},
lastSeen: {
type: GraphQLString,
description: `The location of the finding.`,
resolve: ({ LastSeen }) => LastSeen,
},
}),
})
export const webComponentPortType = new GraphQLObjectType({
name: 'WebComponentPort',
fields: () => ({
port: {
type: GraphQLString,
description: `The port the finding was discovered.`,
resolve: ({ Port }) => Port,
},
lastPortState: {
type: GraphQLString,
description: `The protocol the finding was discovered.`,
resolve: ({ LastPortState }) => LastPortState,
},
portStateFirstSeen: {
type: GraphQLString,
description: `The date the finding was discovered.`,
resolve: ({ PortStateFirstSeen }) => PortStateFirstSeen,
},
portStateLastSeen: {
type: GraphQLString,
description: `The date the finding was discovered.`,
resolve: ({ PortStateLastSeen }) => PortStateLastSeen,
},
}),
})
export const vulnerabilitesType = new GraphQLObjectType({
name: 'Vulnerabilites',
fields: () => ({
critical: {
type: new GraphQLList(webComponentCveType),
description: `The criticality of the finding.`,
resolve: ({ critical }) => critical,
},
high: {
type: new GraphQLList(webComponentCveType),
description: `The criticality of the finding.`,
resolve: ({ high }) => high,
},
medium: {
type: new GraphQLList(webComponentCveType),
description: `The criticality of the finding.`,
resolve: ({ medium }) => medium,
},
low: {
type: new GraphQLList(webComponentCveType),
description: `The criticality of the finding.`,
resolve: ({ low }) => low,
},
}),
})
export const webComponentCveType = new GraphQLObjectType({
name: 'WebComponentCVE',
fields: () => ({
cve: {
type: GraphQLString,
description: `The CVE of the finding.`,
resolve: ({ Cve }) => Cve,
},
cwe: {
type: GraphQLString,
description: `The description of the CVE.`,
resolve: ({ Cwe }) => Cwe,
},
cvssScore: {
type: GraphQLString,
description: `The severity of the CVE.`,
resolve: ({ CvssScore }) => CvssScore,
},
cvss3Score: {
type: GraphQLString,
description: `The severity of the CVE.`,
resolve: ({ Cvss3Score }) => Cvss3Score,
},
}),
})