From 6b4b8fc215fd174f26b44f75d1b7bb7b05fc72fd Mon Sep 17 00:00:00 2001 From: bharatkk-metron Date: Mon, 22 Jul 2024 17:51:30 +0530 Subject: [PATCH] added ingestion sources --- src/index.ts | 15 +++++++++------ src/ingestionConfig.ts | 33 +++++++++++++++++++++++++++++++++ src/steps/account/index.ts | 8 +++++++- src/steps/constants.ts | 8 ++++++++ src/steps/finding/index.ts | 2 ++ src/steps/project/index.ts | 2 ++ src/steps/user-group/index.ts | 8 +++++++- src/steps/user/index.ts | 8 +++++++- 8 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 src/ingestionConfig.ts diff --git a/src/index.ts b/src/index.ts index d97340d..afce38b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,10 +5,13 @@ import { integrationSteps } from './steps'; import { SonarqubeIntegrationConfig } from './types'; import validateInvocation from './validateInvocation'; import getStepStartStates from './getStepStartStates'; +import { ingestionConfig } from './ingestionConfig'; -export const invocationConfig: IntegrationInvocationConfig = { - instanceConfigFields, - validateInvocation, - getStepStartStates, - integrationSteps, -}; +export const invocationConfig: IntegrationInvocationConfig = + { + instanceConfigFields, + validateInvocation, + getStepStartStates, + integrationSteps, + ingestionConfig, + }; diff --git a/src/ingestionConfig.ts b/src/ingestionConfig.ts new file mode 100644 index 0000000..a52b201 --- /dev/null +++ b/src/ingestionConfig.ts @@ -0,0 +1,33 @@ +import { IntegrationIngestionConfigFieldMap } from '@jupiterone/integration-sdk-core'; +import { INGESTION_SOURCE_IDS } from './steps/constants'; + +export const ingestionConfig: IntegrationIngestionConfigFieldMap = { + [INGESTION_SOURCE_IDS.ACCOUNT]: { + title: 'Account', + description: 'SonarQube Accounts', + defaultsToDisabled: false, + }, + + [INGESTION_SOURCE_IDS.FINDINGS]: { + title: 'Users', + description: 'SonarQube Issues', + defaultsToDisabled: false, + }, + [INGESTION_SOURCE_IDS.USERS]: { + title: 'Users', + description: 'SonarQube Users', + defaultsToDisabled: false, + }, + + [INGESTION_SOURCE_IDS.PROJECT]: { + title: 'Projects', + description: 'SonarQube Projects', + defaultsToDisabled: false, + }, + + [INGESTION_SOURCE_IDS.USER_GROUPS]: { + title: 'User Groups', + description: 'SonarQube Groups', + defaultsToDisabled: false, + }, +}; diff --git a/src/steps/account/index.ts b/src/steps/account/index.ts index a6c311e..f36e309 100644 --- a/src/steps/account/index.ts +++ b/src/steps/account/index.ts @@ -3,7 +3,12 @@ import { IntegrationStepExecutionContext, } from '@jupiterone/integration-sdk-core'; -import { ACCOUNT_ENTITY_KEY, Entities, Steps } from '../constants'; +import { + ACCOUNT_ENTITY_KEY, + Entities, + INGESTION_SOURCE_IDS, + Steps, +} from '../constants'; import { createAccountEntity } from './converter'; import { SonarqubeIntegrationConfig } from '../../types'; @@ -19,6 +24,7 @@ export const accountSteps: IntegrationStep[] = [ { id: Steps.ACCOUNT, name: 'Fetch Account', + ingestionSourceId: INGESTION_SOURCE_IDS.ACCOUNT, entities: [Entities.ACCOUNT], executionHandler: fetchAccount, relationships: [], diff --git a/src/steps/constants.ts b/src/steps/constants.ts index fdb2d73..d684b9a 100644 --- a/src/steps/constants.ts +++ b/src/steps/constants.ts @@ -34,6 +34,14 @@ export const FINDING_TYPES = { VULNERABILITY: 'SECURITY', }; +export const INGESTION_SOURCE_IDS = { + ACCOUNT: 'accounts', + PROJECT: 'projects', + USERS: 'users', + USER_GROUPS: 'user-groups', + FINDINGS: 'findings', +}; + export const Steps = { ACCOUNT: 'fetch-account', PROJECTS: 'fetch-projects', diff --git a/src/steps/finding/index.ts b/src/steps/finding/index.ts index 430ee7f..22cc0d3 100644 --- a/src/steps/finding/index.ts +++ b/src/steps/finding/index.ts @@ -12,6 +12,7 @@ import { FINDING_STATUSES, FINDING_TYPES, FINDINGS_SEVERITIES, + INGESTION_SOURCE_IDS, Relationships, Steps, V1_SEVERITIES_VALUES, @@ -138,6 +139,7 @@ export const findingSteps: IntegrationStep[] = [ { id: Steps.FINDINGS, name: 'Fetch Project Findings', + ingestionSourceId: INGESTION_SOURCE_IDS.FINDINGS, entities: [Entities.FINDING], executionHandler: fetchFindings, relationships: [Relationships.PROJECT_HAS_FINDING], diff --git a/src/steps/project/index.ts b/src/steps/project/index.ts index 5680173..798e7c1 100644 --- a/src/steps/project/index.ts +++ b/src/steps/project/index.ts @@ -10,6 +10,7 @@ import { import { ACCOUNT_ENTITY_KEY, Entities, + INGESTION_SOURCE_IDS, Relationships, Steps, } from '../constants'; @@ -48,6 +49,7 @@ export const projectSteps: IntegrationStep[] = [ id: Steps.PROJECTS, name: 'Projects', entities: [Entities.PROJECT], + ingestionSourceId: INGESTION_SOURCE_IDS.PROJECT, executionHandler: fetchProjects, relationships: [Relationships.ACCOUNT_HAS_PROJECT], dependsOn: [Steps.ACCOUNT], diff --git a/src/steps/user-group/index.ts b/src/steps/user-group/index.ts index 89d9205..b591d18 100644 --- a/src/steps/user-group/index.ts +++ b/src/steps/user-group/index.ts @@ -7,7 +7,12 @@ import { APIVersion } from '../../provider/types/common'; import { fetchUserGroupsV1 } from './fetch-user-groups-api-v1'; import { fetchUserGroupsV2 } from './fetch-user-groups-api-v2'; import { SonarqubeIntegrationConfig } from '../../types'; -import { Steps, Entities, Relationships } from '../constants'; +import { + Steps, + Entities, + Relationships, + INGESTION_SOURCE_IDS, +} from '../constants'; const fetchUserGroupsFnMap = { [APIVersion.V1]: fetchUserGroupsV1, @@ -27,6 +32,7 @@ export const userGroupSteps: IntegrationStep[] = [ id: Steps.USER_GROUPS, name: 'User Groups', entities: [Entities.USER_GROUP], + ingestionSourceId: INGESTION_SOURCE_IDS.USER_GROUPS, executionHandler: fetchUserGroups, relationships: [Relationships.ACCOUNT_HAS_USER_GROUP], dependsOn: [Steps.ACCOUNT], diff --git a/src/steps/user/index.ts b/src/steps/user/index.ts index 43484d0..66f96ee 100644 --- a/src/steps/user/index.ts +++ b/src/steps/user/index.ts @@ -3,7 +3,12 @@ import { IntegrationStepExecutionContext, } from '@jupiterone/integration-sdk-core'; -import { Entities, Steps, Relationships } from '../constants'; +import { + Entities, + Steps, + Relationships, + INGESTION_SOURCE_IDS, +} from '../constants'; import { SonarqubeIntegrationConfig } from '../../types'; import { APIVersion } from '../../provider/types/common'; import { @@ -52,6 +57,7 @@ export const userSteps: IntegrationStep[] = [ }, { id: Steps.BUILD_USER_GROUP_HAS_USER, + ingestionSourceId: INGESTION_SOURCE_IDS.USERS, name: 'Build user group user relationship', entities: [], executionHandler: buildUserGroupUserRelationships,