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

fixed review comments #161

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/steps/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export enum IntegrationSteps {
GROUPS = 'fetch-groups',
ADMINS = 'fetch-admins',
DEVICE_USERS = 'fetch-device-users',
COMPUTER_USES_PROFILE = 'build-computer-uses-profile-relationship',
}

export const Entities: Record<
Expand Down
11 changes: 1 addition & 10 deletions src/steps/devices/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13644,14 +13644,6 @@ exports[`#fetchComputers should collect data: jobState 1`] = `
"homeSize": "-1MB",
"homeSizeMb": -1,
},
{
"_class": "USES",
"_fromEntityKey": "C02T705EGTF1",
"_key": "C02T705EGTF1|uses|jamf_osx_configuration_profile_2",
"_toEntityKey": "jamf_osx_configuration_profile_2",
"_type": "user_endpoint_uses_jamf_osx_configuration_profile",
"displayName": "USES",
},
],
"encounteredTypes": [
"jamf_account",
Expand All @@ -13663,10 +13655,9 @@ exports[`#fetchComputers should collect data: jobState 1`] = `
"jamf_account_has_user_endpoint",
"user_endpoint_installed_application",
"jamf_local_account_uses_user_endpoint",
"user_endpoint_uses_jamf_osx_configuration_profile",
],
"numCollectedEntities": 9,
"numCollectedRelationships": 314,
"numCollectedRelationships": 313,
}
`;

Expand Down
26 changes: 21 additions & 5 deletions src/steps/devices/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,24 +512,24 @@ export async function fetchComputers({

// build computer group and group relationship
for (const groupName of computerDetail.groups_accounts
?.computer_group_memberships) {
?.computer_group_memberships || []) {
const computerGroupKey = generateEntityKey(
Entities.COMPUTER_GROUP._type,
groupName,
);
const computerGroupEntity = await jobState.findEntity(computerGroupKey);

if (computerGroupEntity != null) {
const groupHasComputerRelatioinship = createDirectRelationship({
const groupHasComputerRelationship = createDirectRelationship({
_class: RelationshipClass.HAS,
from: computerGroupEntity,
to: computerEntity,
});

// Some large Jamf datasets are causing issues with duplicate relationships,
// so check that we won't have a duplicate before creating.
if (!jobState.hasKey(groupHasComputerRelatioinship._key)) {
await jobState.addRelationship(groupHasComputerRelatioinship);
if (!jobState.hasKey(groupHasComputerRelationship._key)) {
await jobState.addRelationship(groupHasComputerRelationship);
}
}
}
Expand Down Expand Up @@ -560,7 +560,12 @@ export async function fetchComputers({
jobState,
computerDeviceIdToGraphObjectKeyMap,
);
}

export async function fetchComputerUsesProfile({
jobState,
logger,
}: IntegrationStepExecutionContext<IntegrationConfig>) {
await createComputerUsesProfileRelationships(logger, jobState);
}

Expand Down Expand Up @@ -641,13 +646,24 @@ export const deviceSteps: IntegrationStep<IntegrationConfig>[] = [
executionHandler: fetchMobileDevices,
dependsOn: [IntegrationSteps.ACCOUNTS],
},
{
id: IntegrationSteps.COMPUTER_USES_PROFILE,
name: 'Build Computer Uses Profile',
entities: [],
relationships: [Relationships.COMPUTER_USES_PROFILE],
ingestionSourceId: IngestionSources.COMPUTERS,
executionHandler: fetchComputerUsesProfile,
dependsOn: [
IntegrationSteps.COMPUTERS,
IntegrationSteps.MACOS_CONFIGURATION_PROFILES,
],
},
{
id: IntegrationSteps.COMPUTERS,
name: 'Fetch Computers',
entities: [Entities.COMPUTER, Entities.COMPUTER_GROUP],
relationships: [
Relationships.ACCOUNT_HAS_COMPUTER,
Relationships.COMPUTER_USES_PROFILE,
Relationships.COMPUTER_GROUP_HAS_COMPUTER,
],
mappedRelationships: [
Expand Down
Loading