airbyte-faros-destination 0.9.35 → 0.9.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/lib/converters/vanta/queries.d.ts +3 -0
  2. package/lib/converters/vanta/queries.js +49 -0
  3. package/lib/converters/vanta/queries.js.map +1 -0
  4. package/lib/converters/vanta/types.d.ts +98 -0
  5. package/lib/converters/vanta/types.js +5 -0
  6. package/lib/converters/vanta/types.js.map +1 -0
  7. package/lib/converters/vanta/vulnerabilities.d.ts +39 -0
  8. package/lib/converters/vanta/vulnerabilities.js +390 -0
  9. package/lib/converters/vanta/vulnerabilities.js.map +1 -0
  10. package/lib/converters/zendesk/common.d.ts +21 -1
  11. package/lib/converters/zendesk/common.js +23 -1
  12. package/lib/converters/zendesk/common.js.map +1 -1
  13. package/lib/converters/zendesk/groups.d.ts +7 -0
  14. package/lib/converters/zendesk/groups.js +26 -0
  15. package/lib/converters/zendesk/groups.js.map +1 -0
  16. package/lib/converters/zendesk/satisfaction_ratings.d.ts +3 -2
  17. package/lib/converters/zendesk/satisfaction_ratings.js +25 -6
  18. package/lib/converters/zendesk/satisfaction_ratings.js.map +1 -1
  19. package/lib/converters/zendesk/tickets.js +5 -6
  20. package/lib/converters/zendesk/tickets.js.map +1 -1
  21. package/lib/destination.js +3 -1
  22. package/lib/destination.js.map +1 -1
  23. package/lib/sync.js +8 -2
  24. package/lib/sync.js.map +1 -1
  25. package/lib/tsconfig.tsbuildinfo +1 -1
  26. package/package.json +3 -3
  27. package/resources/source-specific-configs/agileaccelerator.json +0 -1
  28. package/resources/source-specific-configs/asana.json +0 -1
  29. package/resources/source-specific-configs/aws-cloudwatch-metrics.json +0 -1
  30. package/resources/source-specific-configs/azurepipeline.json +0 -1
  31. package/resources/source-specific-configs/backlog.json +0 -1
  32. package/resources/source-specific-configs/bamboohr.json +0 -1
  33. package/resources/source-specific-configs/bitbucket.json +0 -1
  34. package/resources/source-specific-configs/circleci.json +0 -1
  35. package/resources/source-specific-configs/clickup.json +0 -1
  36. package/resources/source-specific-configs/datadog.json +0 -1
  37. package/resources/source-specific-configs/docker.json +0 -1
  38. package/resources/source-specific-configs/firehydrant.json +0 -1
  39. package/resources/source-specific-configs/jenkins.json +0 -1
  40. package/resources/source-specific-configs/jira.json +0 -1
  41. package/resources/source-specific-configs/notion.json +0 -1
  42. package/resources/source-specific-configs/octopus.json +0 -1
  43. package/resources/source-specific-configs/opsgenie.json +0 -1
  44. package/resources/source-specific-configs/pagerduty.json +0 -1
  45. package/resources/source-specific-configs/phabricator.json +0 -1
  46. package/resources/source-specific-configs/servicenow.json +0 -1
  47. package/resources/source-specific-configs/squadcast.json +0 -1
  48. package/resources/source-specific-configs/statuspage.json +0 -1
  49. package/resources/source-specific-configs/surveys.json +3 -4
  50. package/resources/source-specific-configs/trello.json +1 -2
  51. package/resources/source-specific-configs/victorops.json +0 -1
  52. package/resources/source-specific-configs/workday.json +1 -2
  53. package/resources/source-specific-configs/zendesk.json +47 -30
@@ -0,0 +1,3 @@
1
+ export declare const vcsRepositoryQuery = "\nquery vcsRepositoryQuery {\n vcs_Repository(where: {name: {_eq: \"<REPONAME>\"}}, limit: 1) {\n organization {\n uid\n source\n }\n name\n }\n}\n";
2
+ export declare const cicdArtifactQueryByCommitSha = "\nquery cicdArtifactQueryByCommitSha {\n cicd_Artifact(where: {uid: {_eq: \"<COMMIT_SHA>\"}}, limit: 1) {\n uid\n repository {\n organization {\n uid\n source\n }\n uid\n }\n }\n}\n";
3
+ export declare const cicdArtifactQueryByRepoName = "\nquery cicdArtifactQueryByRepoName {\n cicd_Artifact(\n where: {repository: {uid: {_eq: \"<REPONAME>\"}}}\n limit: 1\n order_by: {refreshedAt: asc}\n ) {\n uid\n repository {\n organization {\n uid\n source\n }\n uid\n }\n }\n}\n";
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ // Note the queries must have a single set of double quotes surrounding
3
+ // the object of interest in order for the unit tests to work.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.cicdArtifactQueryByRepoName = exports.cicdArtifactQueryByCommitSha = exports.vcsRepositoryQuery = void 0;
6
+ exports.vcsRepositoryQuery = `
7
+ query vcsRepositoryQuery {
8
+ vcs_Repository(where: {name: {_eq: "<REPONAME>"}}, limit: 1) {
9
+ organization {
10
+ uid
11
+ source
12
+ }
13
+ name
14
+ }
15
+ }
16
+ `;
17
+ exports.cicdArtifactQueryByCommitSha = `
18
+ query cicdArtifactQueryByCommitSha {
19
+ cicd_Artifact(where: {uid: {_eq: "<COMMIT_SHA>"}}, limit: 1) {
20
+ uid
21
+ repository {
22
+ organization {
23
+ uid
24
+ source
25
+ }
26
+ uid
27
+ }
28
+ }
29
+ }
30
+ `;
31
+ exports.cicdArtifactQueryByRepoName = `
32
+ query cicdArtifactQueryByRepoName {
33
+ cicd_Artifact(
34
+ where: {repository: {uid: {_eq: "<REPONAME>"}}}
35
+ limit: 1
36
+ order_by: {refreshedAt: asc}
37
+ ) {
38
+ uid
39
+ repository {
40
+ organization {
41
+ uid
42
+ source
43
+ }
44
+ uid
45
+ }
46
+ }
47
+ }
48
+ `;
49
+ //# sourceMappingURL=queries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/converters/vanta/queries.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,8DAA8D;;;AAEjD,QAAA,kBAAkB,GAAG;;;;;;;;;;CAUjC,CAAC;AAEW,QAAA,4BAA4B,GAAG;;;;;;;;;;;;;CAa3C,CAAC;AAEW,QAAA,2BAA2B,GAAG;;;;;;;;;;;;;;;;;CAiB1C,CAAC"}
@@ -0,0 +1,98 @@
1
+ type OptString = string | null | undefined;
2
+ export interface BaseVulnerabilityType {
3
+ uid: OptString;
4
+ displayName: OptString;
5
+ createdAt: OptString;
6
+ externalURL: OptString;
7
+ severity: OptString;
8
+ }
9
+ export type ExtendedVulnerabilityType = BaseVulnerabilityType & {
10
+ description?: OptString;
11
+ externalIds?: OptString[];
12
+ [key: string]: any;
13
+ };
14
+ export interface GithubSecurityAdvisory {
15
+ cveId: OptString;
16
+ description: OptString;
17
+ ghsaId: OptString;
18
+ }
19
+ export interface GithubVulnerabilityData {
20
+ createdAt: OptString;
21
+ displayName: OptString;
22
+ externalURL: OptString;
23
+ repositoryName: OptString;
24
+ severity: OptString;
25
+ slaDeadline: OptString;
26
+ uid: OptString;
27
+ vantaDescription: OptString;
28
+ securityAdvisory: GithubSecurityAdvisory;
29
+ }
30
+ export interface AWSFindings {
31
+ description: OptString;
32
+ providerSeverity: OptString;
33
+ name: OptString;
34
+ }
35
+ export interface AWSVulnerabilityData {
36
+ createdAt: OptString;
37
+ packageName: OptString;
38
+ packageVersion: OptString;
39
+ externalURL: OptString;
40
+ scanType: OptString;
41
+ severity: OptString;
42
+ slaDeadline: OptString;
43
+ uid: OptString;
44
+ repositoryName: OptString;
45
+ repositoryArn: OptString;
46
+ displayName: OptString;
47
+ findings: AWSFindings[];
48
+ }
49
+ export interface AWSV2Ignored {
50
+ ignoreReason: OptString;
51
+ ignoredUntil: OptString;
52
+ ignoredAt: OptString;
53
+ }
54
+ export interface AWSV2Asset {
55
+ displayName: OptString;
56
+ }
57
+ export interface AWSV2VulnerabilityData {
58
+ createdAt: OptString;
59
+ externalURL: OptString;
60
+ packageName: OptString;
61
+ packageIdentifier: OptString;
62
+ scanType: OptString;
63
+ scannerScore: OptString;
64
+ severity: OptString;
65
+ uid: OptString;
66
+ description: OptString;
67
+ displayName: OptString;
68
+ name: OptString;
69
+ isFixable: OptString;
70
+ remediation: OptString;
71
+ remediateBy: OptString;
72
+ asset: AWSV2Asset;
73
+ ignored: AWSV2Ignored;
74
+ imageTags: string[];
75
+ imageDigest: OptString;
76
+ }
77
+ export declare const vulnTypeOptions: string[];
78
+ export interface VcsOrgKey {
79
+ uid: string;
80
+ source: string;
81
+ }
82
+ export interface VcsRepoKey {
83
+ organization: VcsOrgKey;
84
+ name: string;
85
+ }
86
+ export interface CicdOrgKey {
87
+ uid: string;
88
+ source: string;
89
+ }
90
+ export interface CicdRepoKey {
91
+ organization: CicdOrgKey;
92
+ uid: string;
93
+ }
94
+ export interface CicdArtifactKey {
95
+ uid: string;
96
+ repository: CicdRepoKey;
97
+ }
98
+ export {};
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.vulnTypeOptions = void 0;
4
+ exports.vulnTypeOptions = ['git', 'aws', 'awsv2'];
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/converters/vanta/types.ts"],"names":[],"mappings":";;;AAsFa,QAAA,eAAe,GAAa,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { AirbyteRecord } from 'faros-airbyte-cdk';
2
+ import { Converter, DestinationModel, DestinationRecord, StreamContext } from '../converter';
3
+ import { AWSV2VulnerabilityData, AWSVulnerabilityData, CicdArtifactKey, ExtendedVulnerabilityType, GithubVulnerabilityData, VcsRepoKey } from './types';
4
+ export declare function looksLikeGithubCommitSha(sha: string): boolean;
5
+ export declare abstract class Vulnerabilities extends Converter {
6
+ source: string;
7
+ readonly destinationModels: ReadonlyArray<DestinationModel>;
8
+ git_vulns: GithubVulnerabilityData[];
9
+ aws_vulns: AWSVulnerabilityData[];
10
+ awsv2_vulns: AWSV2VulnerabilityData[];
11
+ vulnsMissingIds: ExtendedVulnerabilityType[];
12
+ severityMap: {
13
+ [key: string]: number;
14
+ };
15
+ repositoryNamesToUids: Record<string, string[]>;
16
+ awsV2ContainerNamesToUids: Record<string, string[]>;
17
+ gitUidsToVulns: Record<string, GithubVulnerabilityData>;
18
+ awsUidsToVulns: Record<string, AWSVulnerabilityData>;
19
+ duplicateAwsUids: Set<string>;
20
+ /** All Vanta records should have id property */
21
+ id(record: AirbyteRecord): any;
22
+ addUIDToMapping(name: string, uid: string, mapping: Record<string, string[]>): void;
23
+ getVulnRecordsFromGit(data: GithubVulnerabilityData[]): DestinationRecord[];
24
+ getVulnRecordsFromAws(data: AWSVulnerabilityData[]): DestinationRecord[];
25
+ getVCSRepositoryFromName(vcsRepoName: string, ctx: StreamContext): Promise<VcsRepoKey | null>;
26
+ getCICDArtifactFromCommitSha(commitSha: string, ctx: StreamContext): Promise<CicdArtifactKey | null>;
27
+ getAWSCicdArtifactFromName(repoName: string, ctx: StreamContext): Promise<CicdArtifactKey | null>;
28
+ getVCSMappingsFromGit(gitRepoNamesToUIDs: Record<string, string[]>, ctx: StreamContext): Promise<DestinationRecord[]>;
29
+ getAWSV2VulnStatusCategory(vuln: AWSV2VulnerabilityData): string;
30
+ getCICDMappingsFromAWS(ctx: StreamContext): Promise<DestinationRecord[]>;
31
+ getCICDMappingsFromAWSV2(aws_vulns: AWSV2VulnerabilityData[], ctx: StreamContext): Promise<DestinationRecord[]>;
32
+ getUidFromAWSV2Vuln(vuln: AWSV2VulnerabilityData): string;
33
+ getVulnRecordsFromAwsV2(data: AWSV2VulnerabilityData[]): DestinationRecord[];
34
+ combineAwsVulns(aws_v1_vulns: DestinationRecord[], aws_v2_vulns: DestinationRecord[], ctx: StreamContext): DestinationRecord[];
35
+ getSecVulnerabilityRecordFromData(data: ExtendedVulnerabilityType): DestinationRecord;
36
+ convert(record: AirbyteRecord): Promise<ReadonlyArray<DestinationRecord>>;
37
+ printReport(ctx: StreamContext): void;
38
+ onProcessingComplete(ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
39
+ }
@@ -0,0 +1,390 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Vulnerabilities = exports.looksLikeGithubCommitSha = void 0;
4
+ const converter_1 = require("../converter");
5
+ const queries_1 = require("./queries");
6
+ function looksLikeGithubCommitSha(sha) {
7
+ return /^[a-f0-9]{40}$/i.test(sha);
8
+ }
9
+ exports.looksLikeGithubCommitSha = looksLikeGithubCommitSha;
10
+ class Vulnerabilities extends converter_1.Converter {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.source = 'vanta';
14
+ this.destinationModels = [
15
+ 'sec_Vulnerability',
16
+ 'vcs_RepositoryVulnerability',
17
+ 'cicd_ArtifactVulnerability',
18
+ ];
19
+ this.git_vulns = [];
20
+ this.aws_vulns = [];
21
+ this.awsv2_vulns = [];
22
+ this.vulnsMissingIds = [];
23
+ this.severityMap = {
24
+ LOW: 3.0,
25
+ MEDIUM: 6.0,
26
+ HIGH: 9.0,
27
+ CRITICAL: 10.0,
28
+ };
29
+ this.repositoryNamesToUids = {};
30
+ this.awsV2ContainerNamesToUids = {};
31
+ this.gitUidsToVulns = {};
32
+ this.awsUidsToVulns = {};
33
+ this.duplicateAwsUids = new Set();
34
+ }
35
+ /** All Vanta records should have id property */
36
+ id(record) {
37
+ var _a, _b, _c;
38
+ return (_c = (_b = (_a = record === null || record === void 0 ? void 0 : record.record) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.vuln_data) === null || _c === void 0 ? void 0 : _c.id;
39
+ }
40
+ addUIDToMapping(name, uid, mapping) {
41
+ if (name in mapping) {
42
+ mapping[name].push(uid);
43
+ }
44
+ else {
45
+ mapping[name] = [uid];
46
+ }
47
+ }
48
+ getVulnRecordsFromGit(data) {
49
+ const vuln_data = [];
50
+ for (const vuln of data) {
51
+ if (!vuln.uid) {
52
+ this.vulnsMissingIds.push(vuln);
53
+ continue;
54
+ }
55
+ vuln['description'] = vuln.vantaDescription;
56
+ this.addUIDToMapping(vuln.repositoryName, vuln.uid, this.repositoryNamesToUids);
57
+ vuln_data.push(this.getSecVulnerabilityRecordFromData(vuln));
58
+ this.gitUidsToVulns[vuln.uid] = vuln;
59
+ }
60
+ return vuln_data;
61
+ }
62
+ getVulnRecordsFromAws(data) {
63
+ const vuln_data = [];
64
+ for (const vuln of data) {
65
+ if (!vuln.uid) {
66
+ this.vulnsMissingIds.push(vuln);
67
+ continue;
68
+ }
69
+ for (const finding of vuln.findings) {
70
+ // We copy vuln data and add the finding data to it
71
+ const new_vuln = { ...vuln };
72
+ const cve_str = finding['name'];
73
+ const uid_addition = '|' + cve_str.split(' ')[0];
74
+ new_vuln.uid += uid_addition;
75
+ new_vuln['description'] = finding['description'];
76
+ vuln_data.push(this.getSecVulnerabilityRecordFromData(new_vuln));
77
+ this.awsUidsToVulns[new_vuln.uid] = new_vuln;
78
+ }
79
+ }
80
+ return vuln_data;
81
+ }
82
+ async getVCSRepositoryFromName(vcsRepoName, ctx) {
83
+ const replacedQuery = queries_1.vcsRepositoryQuery.replace('<REPONAME>', vcsRepoName);
84
+ if (ctx.farosClient) {
85
+ const resp = await ctx.farosClient.gql(ctx.graph, replacedQuery);
86
+ if (!resp) {
87
+ ctx.logger.warn(`Did not get any results for vcsRepository query with name "${vcsRepoName}"`);
88
+ return null;
89
+ }
90
+ const results = resp === null || resp === void 0 ? void 0 : resp.vcs_Repository;
91
+ let result = null;
92
+ if (results.length > 0) {
93
+ result = results[0];
94
+ }
95
+ else {
96
+ ctx.logger.warn(`Did not get any results for vcsRepository query with name "${vcsRepoName}"`);
97
+ }
98
+ return result;
99
+ }
100
+ return null;
101
+ }
102
+ async getCICDArtifactFromCommitSha(commitSha, ctx) {
103
+ const replacedQuery = queries_1.cicdArtifactQueryByCommitSha.replace('<COMMIT_SHA>', commitSha);
104
+ if (ctx.farosClient) {
105
+ const resp = await ctx.farosClient.gql(ctx.graph, replacedQuery);
106
+ if (!resp) {
107
+ ctx.logger.warn(`Did not get any results for cicdArtifact query with commit sha "${commitSha}"`);
108
+ return null;
109
+ }
110
+ const results = resp === null || resp === void 0 ? void 0 : resp.cicd_Artifact;
111
+ let result = null;
112
+ if (results.length > 0) {
113
+ result = results[0];
114
+ }
115
+ else {
116
+ ctx.logger.warn(`Did not get any results for cicdArtifact query with commit sha "${commitSha}"`);
117
+ }
118
+ return result;
119
+ }
120
+ return null;
121
+ }
122
+ async getAWSCicdArtifactFromName(repoName, ctx) {
123
+ // Because we don't have the actual commit sha, we can't query the cicd_Artifact table
124
+ // using the uid. Instead, we'll need to query the cicd_Artifact table using the repository name
125
+ // and choosing the most recent artifact.
126
+ const replacedQuery = queries_1.cicdArtifactQueryByRepoName.replace('<REPONAME>', repoName);
127
+ if (ctx.farosClient) {
128
+ const resp = await ctx.farosClient.gql(ctx.graph, replacedQuery);
129
+ if (!resp) {
130
+ ctx.logger.warn(`Did not get any results for cicdArtifact query with repository name "${repoName}"`);
131
+ return null;
132
+ }
133
+ const results = resp === null || resp === void 0 ? void 0 : resp.cicd_Artifact;
134
+ let result = null;
135
+ if (results.length > 0) {
136
+ result = results[0];
137
+ }
138
+ else {
139
+ ctx.logger.warn(`Did not get any results for cicdArtifact query with repository name "${repoName}"`);
140
+ }
141
+ return result;
142
+ }
143
+ }
144
+ async getVCSMappingsFromGit(gitRepoNamesToUIDs, ctx) {
145
+ const vuln_data = [];
146
+ for (const [repoName, uids] of Object.entries(gitRepoNamesToUIDs)) {
147
+ const repoKey = await this.getVCSRepositoryFromName(repoName, ctx);
148
+ if (repoKey) {
149
+ for (const uid of uids) {
150
+ const vulnKey = {
151
+ uid: uid,
152
+ source: this.source,
153
+ };
154
+ const vuln = this.gitUidsToVulns[uid];
155
+ vuln_data.push({
156
+ model: 'vcs_RepositoryVulnerability',
157
+ record: {
158
+ repository: repoKey,
159
+ vulnerability: vulnKey,
160
+ url: vuln.externalURL,
161
+ dueAt: vuln.slaDeadline,
162
+ },
163
+ });
164
+ }
165
+ }
166
+ }
167
+ return vuln_data;
168
+ }
169
+ getAWSV2VulnStatusCategory(vuln) {
170
+ var _a, _b;
171
+ if ((_a = vuln.ignored) === null || _a === void 0 ? void 0 : _a.ignoreReason) {
172
+ return 'IGNORED';
173
+ }
174
+ else if ((_b = vuln.ignored) === null || _b === void 0 ? void 0 : _b.ignoredUntil) {
175
+ return 'IGNORED';
176
+ }
177
+ else {
178
+ return 'ACTIVE';
179
+ }
180
+ }
181
+ async getCICDMappingsFromAWS(ctx) {
182
+ // We iterate through the key-value pairs of awsUidsToVulns
183
+ // We get the repository name from the vuln, and we take the most
184
+ // recent cicd_Artifact, rather than getting the cicd_Artifact by commit sha
185
+ const res = [];
186
+ for (const [uid, vuln] of Object.entries(this.awsUidsToVulns)) {
187
+ let repoName = vuln.repositoryName;
188
+ if (!repoName) {
189
+ ctx.logger.warn(`Could not find repository name for vulnerability with uid "${uid}"`);
190
+ continue;
191
+ }
192
+ // If repoName has '/' in it, we split by backslash and take the last piece:
193
+ if (repoName.includes('/')) {
194
+ const split = repoName.split('/');
195
+ repoName = split[split.length - 1];
196
+ }
197
+ const repoKey = await this.getAWSCicdArtifactFromName(repoName, ctx);
198
+ if (!repoKey) {
199
+ ctx.logger.warn(`Could not find cicd_Artifact for vulnerability with uid "${uid}"`);
200
+ continue;
201
+ }
202
+ res.push({
203
+ model: 'cicd_ArtifactVulnerability',
204
+ record: {
205
+ artifact: repoKey,
206
+ vulnerability: {
207
+ uid: uid,
208
+ source: this.source,
209
+ },
210
+ url: vuln.externalURL,
211
+ dueAt: vuln.slaDeadline,
212
+ createdAt: vuln.createdAt,
213
+ acknowledgedAt: vuln.createdAt,
214
+ },
215
+ });
216
+ }
217
+ return res;
218
+ }
219
+ async getCICDMappingsFromAWSV2(aws_vulns, ctx) {
220
+ const res = [];
221
+ const seenUids = new Set();
222
+ for (const vuln of aws_vulns) {
223
+ // First we check for dup uids
224
+ const uid = this.getUidFromAWSV2Vuln(vuln);
225
+ if (seenUids.has(uid)) {
226
+ ctx.logger.info('Found duplicate vuln id: ' + uid);
227
+ this.duplicateAwsUids.add(uid);
228
+ continue;
229
+ }
230
+ seenUids.add(uid);
231
+ // We need to do the following for each vuln:
232
+ // Get the image tags. For each image tag, check if it is a github commit sha
233
+ // If you get the github commit sha, query the cicd_Artifact table by commit sha
234
+ // If you get a cicd_Artifact, add the mapping to the cicd_ArtifactVulnerability table
235
+ const imageTags = vuln.imageTags;
236
+ if (!imageTags || imageTags.length === 0) {
237
+ continue;
238
+ }
239
+ let commitSha = null;
240
+ for (const tag of imageTags) {
241
+ if (looksLikeGithubCommitSha(tag)) {
242
+ commitSha = tag;
243
+ break;
244
+ }
245
+ }
246
+ if (!commitSha) {
247
+ ctx.logger.info(`Skipped getting commit Sha from below imageTags due to not finding git commit sha:`);
248
+ ctx.logger.info(JSON.stringify(imageTags));
249
+ continue;
250
+ }
251
+ const CicdArtifactKey = await this.getCICDArtifactFromCommitSha(commitSha, ctx);
252
+ if (CicdArtifactKey) {
253
+ res.push({
254
+ model: 'cicd_ArtifactVulnerability',
255
+ record: {
256
+ artifact: CicdArtifactKey,
257
+ vulnerability: {
258
+ uid: this.getUidFromAWSV2Vuln(vuln),
259
+ source: this.source,
260
+ },
261
+ url: vuln.externalURL,
262
+ dueAt: vuln.remediateBy,
263
+ createdAt: vuln.createdAt,
264
+ acknowledgedAt: vuln.createdAt,
265
+ status: {
266
+ category: this.getAWSV2VulnStatusCategory(vuln),
267
+ },
268
+ },
269
+ });
270
+ }
271
+ }
272
+ return res;
273
+ }
274
+ getUidFromAWSV2Vuln(vuln) {
275
+ return vuln.uid;
276
+ }
277
+ getVulnRecordsFromAwsV2(data) {
278
+ const vuln_data = [];
279
+ for (const vuln of data) {
280
+ if (!vuln.uid) {
281
+ this.vulnsMissingIds.push(vuln);
282
+ continue;
283
+ }
284
+ const sev = this.severityMap[vuln.severity];
285
+ let sevString;
286
+ if (!sev) {
287
+ sevString = 'UNKNOWN';
288
+ }
289
+ else {
290
+ sevString = sev.toString();
291
+ }
292
+ const uid = this.getUidFromAWSV2Vuln(vuln);
293
+ const vuln_copy = {
294
+ uid,
295
+ createdAt: vuln.createdAt,
296
+ externalURL: vuln.externalURL,
297
+ severity: sevString,
298
+ description: vuln.description,
299
+ displayName: vuln.asset.displayName,
300
+ };
301
+ vuln_data.push(this.getSecVulnerabilityRecordFromData(vuln_copy));
302
+ }
303
+ return vuln_data;
304
+ }
305
+ combineAwsVulns(aws_v1_vulns, aws_v2_vulns, ctx) {
306
+ const seenUids = new Set();
307
+ const combined = [];
308
+ for (const vuln_list of [aws_v2_vulns, aws_v1_vulns]) {
309
+ for (const vuln of vuln_list) {
310
+ if (!seenUids.has(vuln.record.uid)) {
311
+ combined.push(vuln);
312
+ seenUids.add(vuln.record.uid);
313
+ }
314
+ else {
315
+ ctx.logger.info('Found duplicate vuln id: ' + vuln.record.uid);
316
+ this.duplicateAwsUids.add(vuln.record.uid);
317
+ }
318
+ }
319
+ }
320
+ return combined;
321
+ }
322
+ getSecVulnerabilityRecordFromData(data) {
323
+ return {
324
+ model: 'sec_Vulnerability',
325
+ record: {
326
+ uid: data.uid,
327
+ source: this.source,
328
+ title: data.displayName,
329
+ description: data.description,
330
+ severity: data.severity,
331
+ url: data.externalURL,
332
+ discoveredAt: data.createdAt,
333
+ vulnerabilityIds: data.externalIds,
334
+ },
335
+ };
336
+ }
337
+ async convert(record) {
338
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
339
+ if (((_b = (_a = record === null || record === void 0 ? void 0 : record.record) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.vuln_type) === 'git') {
340
+ this.git_vulns.push((_d = (_c = record === null || record === void 0 ? void 0 : record.record) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.vuln_data);
341
+ }
342
+ else if (((_f = (_e = record === null || record === void 0 ? void 0 : record.record) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.vuln_type) === 'aws') {
343
+ this.aws_vulns.push((_h = (_g = record === null || record === void 0 ? void 0 : record.record) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.vuln_data);
344
+ }
345
+ else if (((_k = (_j = record === null || record === void 0 ? void 0 : record.record) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.vuln_type) === 'awsv2') {
346
+ this.awsv2_vulns.push((_m = (_l = record === null || record === void 0 ? void 0 : record.record) === null || _l === void 0 ? void 0 : _l.data) === null || _m === void 0 ? void 0 : _m.vuln_data);
347
+ }
348
+ return [];
349
+ }
350
+ printReport(ctx) {
351
+ const report_obj = {
352
+ nVulnsMissingIds: this.vulnsMissingIds.length,
353
+ nDuplicateAwsUids: this.duplicateAwsUids.size,
354
+ };
355
+ ctx.logger.info('Vulnerabilities converter report:');
356
+ ctx.logger.info(JSON.stringify(report_obj, null, 2));
357
+ if (this.vulnsMissingIds.length > 0) {
358
+ ctx.logger.warn('Vulnerabilities missing ids:');
359
+ ctx.logger.warn(JSON.stringify(this.vulnsMissingIds, null, 2));
360
+ }
361
+ if (this.duplicateAwsUids.size > 0) {
362
+ ctx.logger.warn('Duplicate AWS vuln uids:');
363
+ ctx.logger.warn(JSON.stringify(this.duplicateAwsUids, null, 2));
364
+ }
365
+ }
366
+ async onProcessingComplete(ctx) {
367
+ // We'll need to grab vcs and cicd data from the graph to match the vulns
368
+ // to the correct parts
369
+ ctx.logger.debug('Running onProcessing complete');
370
+ const res = [];
371
+ // Getting sec_Vulnerability records
372
+ res.push(...this.getVulnRecordsFromGit(this.git_vulns));
373
+ const aws_v1_vulns = this.getVulnRecordsFromAws(this.aws_vulns);
374
+ const aws_v2_vulns = this.getVulnRecordsFromAwsV2(this.awsv2_vulns);
375
+ const combined_aws_vulns = this.combineAwsVulns(aws_v1_vulns, aws_v2_vulns, ctx);
376
+ res.push(...combined_aws_vulns);
377
+ // Getting vcs_RepositoryVulnerability records
378
+ const vcsMappings = await this.getVCSMappingsFromGit(this.repositoryNamesToUids, ctx);
379
+ res.push(...vcsMappings);
380
+ // Getting cicd_ArtifactVulnerability records
381
+ const cicdArtifactMappingsAWSV2 = await this.getCICDMappingsFromAWSV2(this.awsv2_vulns, ctx);
382
+ res.push(...cicdArtifactMappingsAWSV2);
383
+ const cicdArtifactMappingsAWS = await this.getCICDMappingsFromAWS(ctx);
384
+ res.push(...cicdArtifactMappingsAWS);
385
+ this.printReport(ctx);
386
+ return res;
387
+ }
388
+ }
389
+ exports.Vulnerabilities = Vulnerabilities;
390
+ //# sourceMappingURL=vulnerabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vulnerabilities.js","sourceRoot":"","sources":["../../../src/converters/vanta/vulnerabilities.ts"],"names":[],"mappings":";;;AAEA,4CAKsB;AACtB,uCAImB;AAUnB,SAAgB,wBAAwB,CAAC,GAAW;IAClD,OAAO,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC;AAFD,4DAEC;AAED,MAAsB,eAAgB,SAAQ,qBAAS;IAAvD;;QACE,WAAM,GAAG,OAAO,CAAC;QACR,sBAAiB,GAAoC;YAC5D,mBAAmB;YACnB,6BAA6B;YAC7B,4BAA4B;SAC7B,CAAC;QACF,cAAS,GAA8B,EAAE,CAAC;QAC1C,cAAS,GAA2B,EAAE,CAAC;QACvC,gBAAW,GAA6B,EAAE,CAAC;QAC3C,oBAAe,GAAgC,EAAE,CAAC;QAClD,gBAAW,GAA4B;YACrC,GAAG,EAAE,GAAG;YACR,MAAM,EAAE,GAAG;YACX,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,0BAAqB,GAA6B,EAAE,CAAC;QACrD,8BAAyB,GAA6B,EAAE,CAAC;QACzD,mBAAc,GAA4C,EAAE,CAAC;QAC7D,mBAAc,GAAyC,EAAE,CAAC;QAC1D,qBAAgB,GAAgB,IAAI,GAAG,EAAE,CAAC;IAqc5C,CAAC;IAncC,gDAAgD;IAChD,EAAE,CAAC,MAAqB;;QACtB,OAAO,MAAA,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,0CAAE,IAAI,0CAAE,SAAS,0CAAE,EAAE,CAAC;IAC7C,CAAC;IAED,eAAe,CACb,IAAY,EACZ,GAAW,EACX,OAAiC;QAEjC,IAAI,IAAI,IAAI,OAAO,EAAE,CAAC;YACpB,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI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ts-essentials';
3
+ import { Converter, StreamContext, StreamName } from '../converter';
4
+ type TeamMapping = Dictionary<string>;
5
+ export interface ZendeskConfig {
6
+ additional_fields_array_limit: number;
7
+ customStatuses: any;
8
+ fieldIdsByName: Map<string, Set<number>>;
9
+ sync_groups?: boolean;
10
+ team_mapping?: TeamMapping;
11
+ ticket_additional_fields?: ReadonlyArray<string>;
12
+ }
13
+ interface OrgTeam {
14
+ uid: string;
15
+ name?: string;
16
+ description?: string;
17
+ }
3
18
  export declare const TicketMetricsStream: StreamName;
4
19
  export declare const TicketFieldsStream: StreamName;
20
+ export declare const GroupsStream: StreamName;
5
21
  export declare abstract class ZendeskConverter extends Converter {
6
22
  readonly projectUid = "zendesk_tickets";
7
23
  readonly projectName = "Zendesk Tickets";
8
24
  source: string;
9
25
  id(record: AirbyteRecord): any;
26
+ protected zendeskConfig(ctx: StreamContext): ZendeskConfig;
27
+ protected teamMapping(ctx: StreamContext): TeamMapping;
28
+ protected orgTeam(ctx: StreamContext, group: Dictionary<any>): OrgTeam;
10
29
  }
30
+ export {};