Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
added ingestion sources
Browse files Browse the repository at this point in the history
  • Loading branch information
Bharatkk-metron committed Jul 22, 2024
1 parent a7252c2 commit 6b4b8fc
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 9 deletions.
15 changes: 9 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SonarqubeIntegrationConfig> = {
instanceConfigFields,
validateInvocation,
getStepStartStates,
integrationSteps,
};
export const invocationConfig: IntegrationInvocationConfig<SonarqubeIntegrationConfig> =
{
instanceConfigFields,
validateInvocation,
getStepStartStates,
integrationSteps,
ingestionConfig,
};
33 changes: 33 additions & 0 deletions src/ingestionConfig.ts
Original file line number Diff line number Diff line change
@@ -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,
},
};
8 changes: 7 additions & 1 deletion src/steps/account/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -19,6 +24,7 @@ export const accountSteps: IntegrationStep<SonarqubeIntegrationConfig>[] = [
{
id: Steps.ACCOUNT,
name: 'Fetch Account',
ingestionSourceId: INGESTION_SOURCE_IDS.ACCOUNT,
entities: [Entities.ACCOUNT],
executionHandler: fetchAccount,
relationships: [],
Expand Down
8 changes: 8 additions & 0 deletions src/steps/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions src/steps/finding/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
FINDING_STATUSES,
FINDING_TYPES,
FINDINGS_SEVERITIES,
INGESTION_SOURCE_IDS,
Relationships,
Steps,
V1_SEVERITIES_VALUES,
Expand Down Expand Up @@ -138,6 +139,7 @@ export const findingSteps: IntegrationStep<SonarqubeIntegrationConfig>[] = [
{
id: Steps.FINDINGS,
name: 'Fetch Project Findings',
ingestionSourceId: INGESTION_SOURCE_IDS.FINDINGS,
entities: [Entities.FINDING],
executionHandler: fetchFindings,
relationships: [Relationships.PROJECT_HAS_FINDING],
Expand Down
2 changes: 2 additions & 0 deletions src/steps/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import {
ACCOUNT_ENTITY_KEY,
Entities,
INGESTION_SOURCE_IDS,
Relationships,
Steps,
} from '../constants';
Expand Down Expand Up @@ -48,6 +49,7 @@ export const projectSteps: IntegrationStep<SonarqubeIntegrationConfig>[] = [
id: Steps.PROJECTS,
name: 'Projects',
entities: [Entities.PROJECT],
ingestionSourceId: INGESTION_SOURCE_IDS.PROJECT,
executionHandler: fetchProjects,
relationships: [Relationships.ACCOUNT_HAS_PROJECT],
dependsOn: [Steps.ACCOUNT],
Expand Down
8 changes: 7 additions & 1 deletion src/steps/user-group/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -27,6 +32,7 @@ export const userGroupSteps: IntegrationStep<SonarqubeIntegrationConfig>[] = [
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],
Expand Down
8 changes: 7 additions & 1 deletion src/steps/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -52,6 +57,7 @@ export const userSteps: IntegrationStep<SonarqubeIntegrationConfig>[] = [
},
{
id: Steps.BUILD_USER_GROUP_HAS_USER,
ingestionSourceId: INGESTION_SOURCE_IDS.USERS,
name: 'Build user group user relationship',
entities: [],
executionHandler: buildUserGroupUserRelationships,
Expand Down

0 comments on commit 6b4b8fc

Please sign in to comment.