This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from JupiterOne/INT-9065-legacy-applications
Int 9065 - Adding legacy applications and local users
- Loading branch information
Showing
11 changed files
with
376 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { | ||
createDirectRelationship, | ||
createIntegrationEntity, | ||
Entity, | ||
parseTimePropertyValue, | ||
Relationship, | ||
RelationshipClass, | ||
} from '@jupiterone/integration-sdk-core'; | ||
|
||
import { Entities } from '../constants'; | ||
|
||
export function createLocalUserKey(id: string) { | ||
return `${Entities.LOCAL_USER._type}:${id}`; | ||
} | ||
|
||
export function createLocalUserEntity(user: any): Entity { | ||
const id = user.SID0?.toString(); | ||
return createIntegrationEntity({ | ||
entityData: { | ||
source: user, | ||
assign: { | ||
_key: createLocalUserKey(id), | ||
_type: Entities.LOCAL_USER._type, | ||
_class: Entities.LOCAL_USER._class, | ||
id: id, | ||
name: id, | ||
displayName: id, | ||
localPath: user.LocalPath0, | ||
createdOn: parseTimePropertyValue(user.TimeStamp), | ||
}, | ||
}, | ||
}); | ||
} | ||
|
||
export function createDeviceLocalUserRelationship( | ||
device: Entity, | ||
user: Entity, | ||
): Relationship { | ||
return createDirectRelationship({ | ||
_class: RelationshipClass.HAS, | ||
from: device, | ||
to: user, | ||
}); | ||
} |
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,29 @@ | ||
import { executeStepWithDependencies } from '@jupiterone/integration-sdk-testing'; | ||
import { buildStepTestConfigForStep } from '../../../test/config'; | ||
import { Steps } from '../constants'; | ||
import sql from 'mssql'; | ||
import { deviceRecords, localUserRecords } from '../../../test/mockData'; | ||
|
||
test('fetch-local-users', async () => { | ||
jest.mock('mssql'); | ||
sql.connect = jest | ||
.fn() | ||
.mockResolvedValueOnce({ | ||
query: jest.fn().mockResolvedValue({ | ||
recordset: deviceRecords, | ||
recordsets: [0, 0], | ||
}), | ||
close: jest.fn(), | ||
}) | ||
.mockReturnValueOnce({ | ||
query: jest.fn().mockResolvedValue({ | ||
recordset: localUserRecords, | ||
recordsets: [0, 0], | ||
}), | ||
close: jest.fn(), | ||
}); | ||
|
||
const stepConfig = buildStepTestConfigForStep(Steps.FETCH_LOCAL_USERS); | ||
const stepResult = await executeStepWithDependencies(stepConfig); | ||
expect(stepResult).toMatchStepMetadata(stepConfig); | ||
}); |
Oops, something went wrong.