-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…#1759) * Replace GraphQL Queries with generic vulnerability endpoints * URL mod and auth mod * getting session token * secrets * Vanta converter refactor wip * Add resources pull to vanta source * API endpoints for resources * Generate in a function * typing * Refactor destination to process new vulnerability and vulnerability remediation records. * Add assets endpoint to retrieve repo name and image tags, implement query for cicd vulns * Remove unused variable * Remove updates and use vuln record type enum * Split into two streams and add retryal with exponential backoff for 429 errors * Remove extra data object. * Use getAxiosResponse method * Support incremental sync * Bump max request retries to 8 * -Remove unused query to Faros graph -Refactor Vanta api to use Faros axios client and support retry logic. - Added schemas * Set vanta property in instance method and remove unused import * Add provisional logs and simplify remediations converter * Fix vulnerability asset linking * use assetType Signed-off-by: Chalenge Masekera <5385518+chalenge@users.noreply.github.com> * Query all repos and cicd artifacts in single queries and write identifiers + repo/cicd vulnerabilities on processing complete. * Fix tests and remove unused stuff * Fix sonnarcloud issues and remove vuln remediation records snapshot as it contains update "at" date and fails * Refactor destination logic to reduce duplication and push assets both for vulns and remediations, to use in destination. * Move things to common sec and fix severity and vulnerability identifier logic. * add package lock * Revert "add package lock" This reverts commit 10c1403. * fix build * update package lock * update lock * Fix null asset error * Review comments fixes * Move functions to correct common file * Fix dep and build * Log vulnerabilities grouped. * Add log and default retry Number fallback * Remove log, add 60 seconds base default with exponential backoff for 429 and 500 statuses. --------- Signed-off-by: Chalenge Masekera <5385518+chalenge@users.noreply.github.com> Co-authored-by: omreego <omreeg@faros.ai> Co-authored-by: Chalenge Masekera <5385518+chalenge@users.noreply.github.com>
- Loading branch information
1 parent
9750e6c
commit 0232a4f
Showing
48 changed files
with
1,899 additions
and
3,181 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
destinations/airbyte-faros-destination/resources/cicdArtifactQueryByCommitSha.gql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
destinations/airbyte-faros-destination/resources/cicdArtifactQueryByRepoName.gql
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
destinations/airbyte-faros-destination/resources/cicdArtifactVulnerabilityQuery.gql
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
destinations/airbyte-faros-destination/resources/vcsRepositoryQuery.gql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
destinations/airbyte-faros-destination/resources/vcsRepositoryVulnerabilityQuery.gql
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
destinations/airbyte-faros-destination/src/converters/common/cicd.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import {StreamContext} from '../converter'; | ||
import {getQueryFromName} from '../vanta/utils'; | ||
|
||
export interface CicdOrgKey { | ||
uid: string; | ||
source: string; | ||
} | ||
|
||
export interface CicdRepoKey { | ||
organization: CicdOrgKey; | ||
uid: string; | ||
} | ||
|
||
export interface ArtifactKey { | ||
uid: string; | ||
repository: CicdRepoKey; | ||
} | ||
|
||
const cicdArtifactQueryByCommitSha = getQueryFromName( | ||
'cicdArtifactQueryByCommitSha' | ||
); | ||
|
||
export async function getCICDArtifactsFromCommitShas( | ||
commitShas: string[], | ||
ctx: StreamContext | ||
): Promise<ArtifactKey[] | null> { | ||
const result = await ctx.farosClient.gql( | ||
ctx.graph, | ||
cicdArtifactQueryByCommitSha, | ||
{ | ||
commitShas, | ||
} | ||
); | ||
return result?.cicd_Artifact; | ||
} |
5 changes: 5 additions & 0 deletions
5
destinations/airbyte-faros-destination/src/converters/common/sec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
destinations/airbyte-faros-destination/src/converters/vanta/common.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import {AirbyteRecord} from 'faros-airbyte-cdk'; | ||
import {VulnerableAssetSummary} from 'faros-airbyte-common/lib/vanta'; | ||
|
||
import {Converter, StreamContext} from '../converter'; | ||
import {looksLikeGitCommitSha} from './utils'; | ||
|
||
export abstract class VantaConverter extends Converter { | ||
source = 'Vanta'; | ||
|
||
/** All Vanta records should have id property */ | ||
id(record: AirbyteRecord): any { | ||
return record?.record?.data?.id; | ||
} | ||
|
||
protected isVCSRepoVulnerability( | ||
vulnerableAsset: VulnerableAssetSummary | ||
): boolean { | ||
return vulnerableAsset.type === 'CODE_REPOSITORY'; | ||
} | ||
|
||
protected isCICDArtifactVulnerability( | ||
vulnerableAsset: VulnerableAssetSummary | ||
): boolean { | ||
return this.getCommitSha(vulnerableAsset.imageTags)?.length > 0; | ||
} | ||
|
||
protected getCommitSha(imageTags?: string[]): string | null { | ||
for (const imageTag of imageTags ?? []) { | ||
if (looksLikeGitCommitSha(imageTag)) { | ||
return imageTag; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
protected logVulnerabilityWarnings( | ||
ctx: StreamContext, | ||
vulnerabilities: Set<string>, | ||
message: string | ||
): void { | ||
if (vulnerabilities.size > 0) { | ||
ctx.logger.warn(`${message}: ${Array.from(vulnerabilities).join(', ')}`); | ||
} | ||
} | ||
} |
137 changes: 0 additions & 137 deletions
137
destinations/airbyte-faros-destination/src/converters/vanta/types.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.