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 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Used @jupiterone/integration-sdk project template.
- Loading branch information
0 parents
commit 143893d
Showing
18 changed files
with
5,234 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"/home/charlie/projects/open-source/graph-trend-micro/src/steps/fetchAccounts.ts":"1","/home/charlie/projects/open-source/graph-trend-micro/src/validateInvocation.ts":"2"},{"size":753,"mtime":1586903039134,"results":"3","hashOfConfig":"4"},{"size":664,"mtime":1586903039134,"results":"5","hashOfConfig":"4"},{"filePath":"6","messages":"7","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"18x7ffl",{"filePath":"8","messages":"9","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"/home/charlie/projects/open-source/graph-trend-micro/src/steps/fetchAccounts.ts",["10"],"/home/charlie/projects/open-source/graph-trend-micro/src/validateInvocation.ts",["11","12","13"],{"ruleId":"14","severity":1,"message":"15","line":12,"column":5,"nodeType":"16","endLine":12,"endColumn":11},{"ruleId":"17","severity":1,"message":"18","line":3,"column":16,"nodeType":"19","messageId":"20","endLine":5,"endColumn":2},{"ruleId":"17","severity":1,"message":"18","line":20,"column":1,"nodeType":"19","messageId":"20","endLine":20,"endColumn":43},{"ruleId":"21","severity":1,"message":"22","line":20,"column":39,"nodeType":"23","messageId":"24","endLine":20,"endColumn":42,"suggestions":"25"},"@typescript-eslint/no-unused-vars","'logger' is defined but never used.","Identifier","@typescript-eslint/explicit-function-return-type","Missing return type on function.","FunctionDeclaration","missingReturnType","@typescript-eslint/no-explicit-any","Unexpected any. Specify a different type.","TSAnyKeyword","unexpectedAny",["26","27"],{"messageId":"28","fix":"29","desc":"30"},{"messageId":"31","fix":"32","desc":"33"},"suggestUnknown",{"range":"34","text":"35"},"Use `unknown` instead, this will force you to explicitly, and safely assert the type is correct.","suggestNever",{"range":"34","text":"36"},"Use `never` instead, this is useful when instantiating generic type parameters that you don't need to know the type of.",[523,526],"unknown","never"] |
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 @@ | ||
dist |
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,23 @@ | ||
{ | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:jest/recommended", | ||
"plugin:prettier/recommended" | ||
], | ||
"env": { | ||
"node": true, | ||
"es6": true | ||
}, | ||
"parserOptions": { | ||
"project": "./tsconfig.json" | ||
}, | ||
"rules": { | ||
"@typescript-eslint/no-use-before-define": [ | ||
"error", | ||
{ | ||
"functions": false | ||
} | ||
] | ||
} | ||
} |
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,4 @@ | ||
node_modules/ | ||
.j1-integration/ | ||
.env | ||
dist/ |
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,5 @@ | ||
{ | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
} |
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,3 @@ | ||
{ | ||
"*.{js,jsx,ts,tsx,md,html,css}": "prettier --write" | ||
} |
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 @@ | ||
dist |
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,5 @@ | ||
{ | ||
"trailingComma": "all", | ||
"proseWrap": "always", | ||
"singleQuote": true | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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,86 @@ | ||
# graph-trend-micro | ||
|
||
## Development Environment | ||
|
||
### Prerequisites | ||
|
||
You must have Node.JS installed to run this project. If you don't already have | ||
it installed, you can can download the installer | ||
[here](https://nodejs.org/en/download/). You can alternatively install Node.JS | ||
using a version manager like [fnm](https://github.com/Schniz/fnm) or | ||
[nvm](https://github.com/nvm-sh/nvm). | ||
|
||
### Setup | ||
|
||
#### Installing dependencies | ||
|
||
From the root of this project, run `npm install` to install dependencies. If you | ||
have `yarn` installed, you can install dependencies by running `yarn`. | ||
|
||
#### Loading credentials | ||
|
||
Create a `.env` file at the root of this project and add environment variables | ||
to match what is in `src/instanceConfigFields.json`. The `.env` file is ignored | ||
by git, so you won't have to worry about accidentally pushing credentials. | ||
|
||
Given this example configuration: | ||
|
||
```json | ||
{ | ||
"clientId": { | ||
"type": "string" | ||
}, | ||
"clientSecret": { | ||
"type": "string", | ||
"mask": true | ||
} | ||
} | ||
``` | ||
|
||
You would provide a `.env` file like this: | ||
|
||
```bash | ||
CLIENT_ID="client-id" | ||
CLIENT_SECRET="supersecret" | ||
``` | ||
|
||
The snake cased environment variables will automatically be converted and | ||
applied to the camel cased configuration field. So for example, `CLIENT_ID` will | ||
apply to the `clientId` config field, `CLIENT_SECRET` will apply to | ||
`clientSecret`, and `MY_SUPER_SECRET_CONFIGURATION_VALUE` will apply to a | ||
`mySuperSecretConfigurationValue` configuration field. | ||
|
||
## Running the integration | ||
|
||
To start collecting data, run `yarn start` from the root of the project. This | ||
will load in your configuration and execute the steps stored in `src/steps`. | ||
|
||
## Project structure | ||
|
||
This is the expected project structure for running integrations. | ||
|
||
``` | ||
src/ | ||
/instanceConfigFields.json | ||
/validateInvocation.ts | ||
/getStepStartStates.ts | ||
steps/ | ||
exampleStep.ts | ||
// add additional steps here | ||
``` | ||
|
||
Each of the files listed above contribute to creating an | ||
[integration configuration](https://github.com/JupiterOne/integration-sdk/blob/master/docs/development.md#the-integration-framework). | ||
|
||
Additional files can be placed under `src` and referenced from each of the | ||
integration files. | ||
|
||
The template project hosted | ||
[here](https://github.com/JupiterOne/integration-sdk/tree/master/template) | ||
provides a simple example of how an integration can be setup. | ||
|
||
## Development Docs | ||
|
||
Please reference the `@jupiterone/integration-sdk` | ||
[development documentation](https://github.com/JupiterOne/integration-sdk/blob/master/docs/development.md) | ||
for more information on how to build integrations. |
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,11 @@ | ||
module.exports = () => ({ | ||
clearMocks: true, | ||
preset: 'ts-jest', | ||
testMatch: ['**/__tests__/**/*test.(js|ts)'], | ||
testPathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/node_modules/'], | ||
globals: { | ||
'ts-jest': { | ||
isolatedModules: true, | ||
}, | ||
}, | ||
}); |
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,36 @@ | ||
{ | ||
"name": "@jupiterone/graph-trend-micro", | ||
"version": "0.1.0", | ||
"description": "A graph conversion tool for https://trendmicro.com", | ||
"license": "MPL-2.0", | ||
"scripts": { | ||
"start": "j1-integration collect", | ||
"lint": "eslint . --cache --fix --ext .ts,.tsx", | ||
"format": "prettier --write '**/*.{ts,js,json,css,md,yml}'", | ||
"type-check": "tsc --noEmit", | ||
"test": "jest --passWithNoTests", | ||
"test:ci": "yarn lint && yarn type-check && yarn test", | ||
"prebuild": "yarn test:ci", | ||
"build": "tsc -p tsconfig.dist.json --declaration" | ||
}, | ||
"dependencies": { | ||
"@jupiterone/integration-sdk": "^0.1.0" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^25.2.1", | ||
"@types/node": "^13.11.1", | ||
"@typescript-eslint/eslint-plugin": "^2.28.0", | ||
"@typescript-eslint/parser": "^2.28.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "^6.10.1", | ||
"eslint-plugin-jest": "^23.8.2", | ||
"eslint-plugin-prettier": "^3.1.3", | ||
"husky": "^4.2.5", | ||
"jest": "^25.3.0", | ||
"lint-staged": "^10.1.3", | ||
"prettier": "^2.0.4", | ||
"ts-jest": "^25.3.1", | ||
"ts-node": "^8.8.2", | ||
"typescript": "^3.8.3" | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"clientId": { | ||
"type": "string" | ||
}, | ||
"clientSecret": { | ||
"type": "string", | ||
"mask": true | ||
} | ||
} |
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,33 @@ | ||
import { | ||
IntegrationStep, | ||
IntegrationStepExecutionContext, | ||
createIntegrationEntity, | ||
} from '@jupiterone/integration-sdk'; | ||
|
||
const step: IntegrationStep = { | ||
id: 'fetch-accounts', | ||
name: 'Fetch accounts', | ||
types: ['my_integration_account'], | ||
async executionHandler({ | ||
logger, | ||
jobState, | ||
}: IntegrationStepExecutionContext) { | ||
await jobState.addEntities([ | ||
createIntegrationEntity({ | ||
entityData: { | ||
source: { | ||
id: 'integration-account-a', | ||
name: 'My Account', | ||
}, | ||
assign: { | ||
_key: 'account:integration-account-a', | ||
_type: 'my-integration-account', | ||
_class: 'Account', | ||
}, | ||
}, | ||
}), | ||
]); | ||
}, | ||
}; | ||
|
||
export default step; |
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,24 @@ | ||
import { IntegrationExecutionContext } from '@jupiterone/integration-sdk'; | ||
|
||
export default function validateInvocation( | ||
context: IntegrationExecutionContext, | ||
) { | ||
context.logger.info( | ||
{ | ||
instance: context.instance, | ||
}, | ||
'Validating integration config...', | ||
); | ||
|
||
if (isConfigurationValid(context.instance.config)) { | ||
context.logger.info('Integration instance is valid!'); | ||
} else { | ||
throw new Error('Failed to authenticate with provided credentials'); | ||
} | ||
} | ||
|
||
function isConfigurationValid(config: any) { | ||
// add your own validation logic to ensure you | ||
// can hit the provider's apis. | ||
return config.clientId && config.clientSecret; | ||
} |
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,10 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": ["src"], | ||
"exclude": [ | ||
"dist", | ||
"**/*.test.ts", | ||
"**/*/__tests__/**/*.ts", | ||
"**/*/__mocks__/**/*.ts" | ||
] | ||
} |
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,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"target": "es2018", | ||
"lib": ["es2018"], | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"noUnusedLocals": true, | ||
"pretty": true, | ||
"esModuleInterop": true | ||
}, | ||
"exclude": ["dist"] | ||
} |
Oops, something went wrong.