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

INT-4833 - Add Consumable, License and User #30

Conversation

eXtremeX
Copy link
Contributor

@eXtremeX eXtremeX commented Oct 18, 2022

Description

Thank you for contributing to a JupiterOne integration!

Please include a summary of the change and which issue is fixed. Please also
include relevant motivation and context. List any dependencies that are required
for this change.

Summary

image

  • Reorganized files
  • Added more test cases
  • Added new entities and relationships:

Entities

Resources Entity _type Entity _class
Consumable snipeit_consumable_resource Resource
License snipeit_licensed_application Application
User snipeit_user User

Relationships

Source Entity _type Relationship _class Target Entity _type
snipeit_account HAS snipeit_consumable_resource
snipeit_account HAS snipeit_licensed_application
snipeit_account HAS snipeit_user
snipeit_user USES snipeit_consumable_resource

Mapped Relationships

Source Entity _type Relationship _class Target Entity _type Direction
snipeit_user IS *person* FORWARD

Type of change

Please leave any irrelevant options unchecked.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)
  • This change requires a documentation update

Checklist

General Development Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Integration Development Checklist:

Please leave any irrelevant options unchecked.

  • I have checked for additional permissions required to call any new API
    endpoints, and have documented any additional permissions in
    jupiterone.md, where necessary.
  • My changes properly paginate the target service provider's API
  • My changes properly handle rate limiting of the target service provider's
    API
  • My new integration step is instrumented to execute in the correct order
    using dependsOn
  • I have referred to the
    JupiterOne data model
    to ensure that any new entities/relationships, and relevant properties,
    match the recommended model for this class of data
  • I have updated the CHANGELOG.md file to describe my changes
  • When changes include modifications to existing graph data ingestion, I've
    reviewed all existing managed questions referencing the entities,
    relationships, and their property names, to ensure those questions still
    function with my changes.

@eXtremeX eXtremeX requested a review from a team as a code owner October 18, 2022 10:58
@socket-security
Copy link

socket-security bot commented Oct 18, 2022

Socket Security Pull Request Report

👍 No new dependency issues detected in pull request

Pull request report summary
Issue Status
Install scripts ✅ 0 issues
Native code ✅ 0 issues
Bin script confusion ✅ 0 issues
Bin script shell injection ✅ 0 issues
Unresolved require ✅ 0 issues
Invalid package.json ✅ 0 issues
HTTP dependency ✅ 0 issues
Git dependency ✅ 0 issues
Potential typo squat ✅ 0 issues
Known Malware ✅ 0 issues
Telemetry ✅ 0 issues
Protestware/Troll package ✅ 0 issues
Bot Commands

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore [email protected] [email protected]

Ignoring: [email protected]

Powered by socket.dev

@eXtremeX eXtremeX changed the title Add Consumable, License and User INT-4833 - Add Consumable, License and User Oct 18, 2022
@electricgull electricgull marked this pull request as draft October 19, 2022 21:00
@electricgull
Copy link
Contributor

Converting to a draft to 1) investigate the socket warning and 2) test the socket slack alert when it is moved back to a PR.

@electricgull electricgull marked this pull request as ready for review October 19, 2022 21:43
@electricgull
Copy link
Contributor

Researched socket alert https://jupiterone.atlassian.net/browse/DESK-1995
Determined alert was acceptable risk.

@electricgull
Copy link
Contributor

@SocketSecurity ignore [email protected]

@mdaum
Copy link
Contributor

mdaum commented Oct 25, 2022

I think recordings are not working because your test/context.ts is pointing to a different hostname than localhost:8000 when you are running yarn test
https://github.com/Creativice-Oy/graph-snipe-it/blob/feature/resource-application-user/test/context.ts#L8

@mdaum mdaum self-requested a review October 25, 2022 18:36
@eXtremeX
Copy link
Contributor Author

I think recordings are not working because your test/context.ts is pointing to a different hostname than localhost:8000 when you are running yarn test https://github.com/Creativice-Oy/graph-snipe-it/blob/feature/resource-application-user/test/context.ts#L8

Thanks for looking into this! It turns out we had to re-record every recording/test anyway, so I've set the context.ts URL to localhost:8000. The other option perhaps would have been to modify recording.har(s) and change localhost:8000 to the URL we had in the context.ts, but considering there isn't a mixture of both this feels more proper? Also, I heard we don't have a partner account so any additional dev efforts might use the (free) stand-alone version again (meaning localhost).

Copy link
Contributor

@mdaum mdaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general looks good! Just a few small comments.

@@ -8,6 +8,33 @@ and this project adheres to

## [Unreleased]

- Reorganized files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changelog doesn't reflect what I'm seeing in jupiterone.md. I think it needs to be updated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Max, I think you might be referring to the mapped relationships. The thing is, previous version wasn't using mappedRelationships array to declare them in the step functions so they were put next to the regular ones. So we aren't creating them thanks to some code change now, but we just fixed that part so that it's properly displayed in the jupiterone.md now. I'm not sure if we should document that in the CHANGELOG, should we?

Perhaps you've meant something different entirely 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I see that makes sense. Thanks for the explanation!

package.json Outdated
"@jupiterone/integration-sdk-core": "^5.5.0",
"@jupiterone/integration-sdk-dev-tools": "^5.5.0",
"@jupiterone/integration-sdk-testing": "^5.5.0",
"@jupiterone/integration-sdk-core": "^7.4.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason we didn't jump to latest version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No particular reason, I've updated it now, thanks for the reminder! It did complain that hardware converter needs deviceId property to be set now and I've used the id that gets sent along with hardware response.

@@ -21,6 +24,7 @@ export async function fetchAccount({

const accountEntity = getAccountEntity(instance);
await jobState.addEntity(accountEntity);
await jobState.setData(ACCOUNT_ENTITY_KEY, accountEntity);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you know the account entity key or are able to derive at a future time, you can avoid setting this data in the jobState and instead use jobState.findEntity when you need this entity in future steps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting, I think previously we've always used setData/getData to store those "singleton" entities such as Service (e.g. scanner) and more importantly Account.

Is this a new idea for findEntity to be used instead? Using setData/getData felt like pattern and we've got into to the habit of using it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure when findEntity was introduced, but it is what I've personally gone with to avoid storing redundant copies of entity data we already have. All that being said for single entities like Service, Account etc this really isn't a big concern. Just pointing it out as an alternative option. I wouldn't hold up a PR over this :)

jobState,
}: IntegrationStepExecutionContext<IntegrationConfig>) {
const client = createServicesClient(instance);
const accountEntity = (await jobState.getData(ACCOUNT_ENTITY_KEY)) as Entity;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use jobState.findEntity if you know account entity key. If you don't you can store it with jobState.setData instead of the entire entity object. More space efficient.


consumableUsers.map(async (consumableUser) => {
if ((consumableUser as ConsumableUser).name) {
const $ = cheerio.load((consumableUser as ConsumableUser).name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a small comment here about what cheerio is and what it is used for. I see it is for jquery for server-side, but not obvious unless I google.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list of users that use a consumable is returned as a link to those users. We used cheerio to easily manipulate the response. I've added a comment to detail this, as suggested.

@mdaum mdaum self-requested a review November 9, 2022 21:56
Copy link
Contributor

@mdaum mdaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work on this!

@eXtremeX eXtremeX merged commit 6f9a654 into JupiterOne-Archives:main Nov 10, 2022
@j1-internal-automation
Copy link
Collaborator

🚀 PR was released in v2.1.0 🚀

@j1-internal-automation j1-internal-automation added the released This issue/pull request has been released. label Jul 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants