@jupiterone/integration-sdk-cli 9.4.1 → 9.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/commands/generate-ingestion-sources-config.d.ts +2 -2
- package/dist/src/commands/generate-ingestion-sources-config.js +4 -5
- package/dist/src/commands/generate-ingestion-sources-config.js.map +1 -1
- package/dist/src/commands/generate.d.ts +1 -0
- package/dist/src/commands/generate.js +29 -0
- package/dist/src/commands/generate.js.map +1 -0
- package/dist/src/commands/index.d.ts +1 -0
- package/dist/src/commands/index.js +1 -0
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/generator/actions.d.ts +4 -0
- package/dist/src/generator/actions.js +38 -0
- package/dist/src/generator/actions.js.map +1 -0
- package/dist/src/generator/configFieldsFlow.d.ts +7 -0
- package/dist/src/generator/configFieldsFlow.js +53 -0
- package/dist/src/generator/configFieldsFlow.js.map +1 -0
- package/dist/src/generator/entitiesFlow.d.ts +7 -0
- package/dist/src/generator/entitiesFlow.js +175 -0
- package/dist/src/generator/entitiesFlow.js.map +1 -0
- package/dist/src/generator/helpers.d.ts +2 -0
- package/dist/src/generator/helpers.js +9 -0
- package/dist/src/generator/helpers.js.map +1 -0
- package/dist/src/generator/newIntegration.d.ts +1 -0
- package/dist/src/generator/newIntegration.js +124 -0
- package/dist/src/generator/newIntegration.js.map +1 -0
- package/dist/src/generator/relationshipsFlow.d.ts +7 -0
- package/dist/src/generator/relationshipsFlow.js +65 -0
- package/dist/src/generator/relationshipsFlow.js.map +1 -0
- package/dist/src/generator/stepTemplate/index.ts.hbs +24 -0
- package/dist/src/generator/stepsFlow.d.ts +10 -0
- package/dist/src/generator/stepsFlow.js +94 -0
- package/dist/src/generator/stepsFlow.js.map +1 -0
- package/dist/src/generator/template/.env.example.hbs +3 -0
- package/dist/src/generator/template/.eslintignore.hbs +1 -0
- package/dist/src/generator/template/.eslintrc.hbs +6 -0
- package/dist/src/generator/template/.github/pull_request_template.md.hbs +17 -0
- package/dist/src/generator/template/.github/workflows/build.yml.hbs +53 -0
- package/dist/src/generator/template/.github/workflows/codeql-analysis.yml.hbs +69 -0
- package/dist/src/generator/template/.github/workflows/integration-deployment.yml.hbs +36 -0
- package/dist/src/generator/template/.github/workflows/peril.yml.hbs +90 -0
- package/dist/src/generator/template/.github/workflows/questions.yml.hbs +40 -0
- package/dist/src/generator/template/.gitignore.hbs +8 -0
- package/dist/src/generator/template/.node-version.hbs +1 -0
- package/dist/src/generator/template/.prettierignore.hbs +5 -0
- package/dist/src/generator/template/CHANGELOG.md.hbs +9 -0
- package/dist/src/generator/template/CODEOWNERS.hbs +3 -0
- package/dist/src/generator/template/Dockerfile.hbs +25 -0
- package/dist/src/generator/template/LICENSE.hbs +373 -0
- package/dist/src/generator/template/README.md.hbs +114 -0
- package/dist/src/generator/template/docs/development.md.hbs +28 -0
- package/dist/src/generator/template/docs/jupiterone.md.hbs +1 -0
- package/dist/src/generator/template/husky.config.js.hbs +1 -0
- package/dist/src/generator/template/jest.config.js.hbs +1 -0
- package/dist/src/generator/template/jupiterone/questions/questions.yaml.hbs +16 -0
- package/dist/src/generator/template/lint-staged.config.js.hbs +1 -0
- package/dist/src/generator/template/package.json.hbs +63 -0
- package/dist/src/generator/template/prettier.config.js.hbs +1 -0
- package/dist/src/generator/template/scripts/execute.sh.hbs +7 -0
- package/dist/src/generator/template/src/client.ts.hbs +23 -0
- package/dist/src/generator/template/src/config.ts.hbs +39 -0
- package/dist/src/generator/template/src/index.ts.hbs +14 -0
- package/dist/src/generator/template/src/steps/constants.ts.hbs +34 -0
- package/dist/src/generator/template/src/steps/index.ts.hbs +7 -0
- package/dist/src/generator/template/src/validateInvocation.ts.hbs +23 -0
- package/dist/src/generator/template/test/README.md.hbs +4 -0
- package/dist/src/generator/template/test/config.ts.hbs +30 -0
- package/dist/src/generator/template/test/recording.ts.hbs +74 -0
- package/dist/src/generator/template/tsconfig.dist.json.hbs +13 -0
- package/dist/src/generator/template/tsconfig.json.hbs +7 -0
- package/dist/src/generator/util.d.ts +9 -0
- package/dist/src/generator/util.js +35 -0
- package/dist/src/generator/util.js.map +1 -0
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/tsconfig.dist.tsbuildinfo +1 -1
- package/package.json +12 -6
- package/src/commands/generate-ingestion-sources-config.test.ts +32 -24
- package/src/commands/generate-ingestion-sources-config.ts +12 -10
- package/src/commands/generate.ts +28 -0
- package/src/commands/index.ts +1 -0
- package/src/generator/actions.ts +37 -0
- package/src/generator/configFieldsFlow.ts +60 -0
- package/src/generator/entitiesFlow.ts +185 -0
- package/src/generator/helpers.ts +6 -0
- package/src/generator/newIntegration.ts +137 -0
- package/src/generator/relationshipsFlow.ts +73 -0
- package/src/generator/stepTemplate/index.ts.hbs +24 -0
- package/src/generator/stepsFlow.ts +123 -0
- package/src/generator/template/.env.example.hbs +3 -0
- package/src/generator/template/.eslintignore.hbs +1 -0
- package/src/generator/template/.eslintrc.hbs +6 -0
- package/src/generator/template/.github/pull_request_template.md.hbs +17 -0
- package/src/generator/template/.github/workflows/build.yml.hbs +53 -0
- package/src/generator/template/.github/workflows/codeql-analysis.yml.hbs +69 -0
- package/src/generator/template/.github/workflows/integration-deployment.yml.hbs +36 -0
- package/src/generator/template/.github/workflows/peril.yml.hbs +90 -0
- package/src/generator/template/.github/workflows/questions.yml.hbs +40 -0
- package/src/generator/template/.gitignore.hbs +8 -0
- package/src/generator/template/.node-version.hbs +1 -0
- package/src/generator/template/.prettierignore.hbs +5 -0
- package/src/generator/template/CHANGELOG.md.hbs +9 -0
- package/src/generator/template/CODEOWNERS.hbs +3 -0
- package/src/generator/template/Dockerfile.hbs +25 -0
- package/src/generator/template/LICENSE.hbs +373 -0
- package/src/generator/template/README.md.hbs +114 -0
- package/src/generator/template/docs/development.md.hbs +28 -0
- package/src/generator/template/docs/jupiterone.md.hbs +1 -0
- package/src/generator/template/husky.config.js.hbs +1 -0
- package/src/generator/template/jest.config.js.hbs +1 -0
- package/src/generator/template/jupiterone/questions/questions.yaml.hbs +16 -0
- package/src/generator/template/lint-staged.config.js.hbs +1 -0
- package/src/generator/template/package.json.hbs +63 -0
- package/src/generator/template/prettier.config.js.hbs +1 -0
- package/src/generator/template/scripts/execute.sh.hbs +7 -0
- package/src/generator/template/src/client.ts.hbs +23 -0
- package/src/generator/template/src/config.ts.hbs +39 -0
- package/src/generator/template/src/index.ts.hbs +14 -0
- package/src/generator/template/src/steps/constants.ts.hbs +34 -0
- package/src/generator/template/src/steps/index.ts.hbs +7 -0
- package/src/generator/template/src/validateInvocation.ts.hbs +23 -0
- package/src/generator/template/test/README.md.hbs +4 -0
- package/src/generator/template/test/config.ts.hbs +30 -0
- package/src/generator/template/test/recording.ts.hbs +74 -0
- package/src/generator/template/tsconfig.dist.json.hbs +13 -0
- package/src/generator/template/tsconfig.json.hbs +7 -0
- package/src/generator/util.ts +39 -0
- package/src/index.ts +3 -1
- package/tsconfig.dist.json +3 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { askRepeatedly, generateChoicesFromEntities } from './util';
|
|
2
|
+
import { RelationshipClass } from '@jupiterone/data-model';
|
|
3
|
+
|
|
4
|
+
export type Relationship = {
|
|
5
|
+
from: any;
|
|
6
|
+
to: any;
|
|
7
|
+
_class: any;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
async function relationshipsFlow(inquirer, entities): Promise<Relationship[]> {
|
|
11
|
+
const relationships: Relationship[] = [];
|
|
12
|
+
const { doPrompt } = await inquirer.prompt({
|
|
13
|
+
type: 'confirm',
|
|
14
|
+
name: 'doPrompt',
|
|
15
|
+
message: 'Do you want to add relationships?',
|
|
16
|
+
});
|
|
17
|
+
if (!doPrompt) return relationships;
|
|
18
|
+
|
|
19
|
+
const entityChoices = generateChoicesFromEntities(entities);
|
|
20
|
+
await askRepeatedly(inquirer, async () => {
|
|
21
|
+
const relationship = await createRelationship(inquirer, entityChoices);
|
|
22
|
+
relationships.push(relationship);
|
|
23
|
+
});
|
|
24
|
+
return relationships;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function createRelationship(inquirer, entityChoices) {
|
|
28
|
+
const { from } = await inquirer.prompt({
|
|
29
|
+
type: 'list',
|
|
30
|
+
name: 'from',
|
|
31
|
+
message: 'What entity should the relationship be from?',
|
|
32
|
+
choices: entityChoices,
|
|
33
|
+
pageSize: entityChoices.length,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const { to } = await inquirer.prompt({
|
|
37
|
+
type: 'list',
|
|
38
|
+
name: 'to',
|
|
39
|
+
message: 'What entity should the relationship be to?',
|
|
40
|
+
choices: entityChoices,
|
|
41
|
+
pageSize: entityChoices.length,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const { _class } = await inquirer.prompt({
|
|
45
|
+
type: 'list',
|
|
46
|
+
name: '_class',
|
|
47
|
+
message: 'What should the _class be?',
|
|
48
|
+
choices: relationshipClassChoices(),
|
|
49
|
+
pageSize: 10,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return { from, to, _class };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function relationshipClassChoices() {
|
|
56
|
+
const choices: { name: string; value: string }[] = [];
|
|
57
|
+
for (const [name, value] of Object.entries(RelationshipClass)) {
|
|
58
|
+
choices.push({
|
|
59
|
+
name,
|
|
60
|
+
value,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
choices.sort((a, b) => {
|
|
64
|
+
if (a.name < b.name) {
|
|
65
|
+
return -1;
|
|
66
|
+
} else {
|
|
67
|
+
return 1;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return choices;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { relationshipsFlow };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IntegrationStep,
|
|
3
|
+
IntegrationStepExecutionContext,
|
|
4
|
+
} from '@jupiterone/integration-sdk-core';
|
|
5
|
+
|
|
6
|
+
import { IntegrationConfig } from '../../config';
|
|
7
|
+
import { Steps{{#if entities}}, Entities{{/if}}{{#if relationships}}, Relationships{{/if}} } from '../constants';
|
|
8
|
+
|
|
9
|
+
export const {{camelCase name}}Steps: IntegrationStep<IntegrationConfig>[] = [
|
|
10
|
+
{
|
|
11
|
+
id: Steps.{{constantCase name}},
|
|
12
|
+
name: '{{titleCase name}}',
|
|
13
|
+
entities: [{{#each entities}}Entities.{{constantCase resourceName}}{{#unless @last}},{{/unless}}{{/each}}],
|
|
14
|
+
relationships: [{{#each relationships}}Relationships.{{constantCase (generateRelationshipName this)}}{{#unless @last}},{{/unless}}{{/each}}],
|
|
15
|
+
dependsOn: [],
|
|
16
|
+
executionHandler: {{camelCase name}},
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
export async function {{camelCase name}}({
|
|
21
|
+
jobState,
|
|
22
|
+
}: IntegrationStepExecutionContext<IntegrationConfig>) {
|
|
23
|
+
// TODO
|
|
24
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {
|
|
2
|
+
generateChoicesFromEntities,
|
|
3
|
+
confirmPrompt,
|
|
4
|
+
askRepeatedly,
|
|
5
|
+
} from './util';
|
|
6
|
+
import { generateRelationshipType } from '@jupiterone/integration-sdk-core';
|
|
7
|
+
import { Entity } from './entitiesFlow';
|
|
8
|
+
import { Relationship } from './relationshipsFlow';
|
|
9
|
+
|
|
10
|
+
export type Step = {
|
|
11
|
+
name: string;
|
|
12
|
+
entities: Entity[];
|
|
13
|
+
relationships: Relationship[];
|
|
14
|
+
dependsOn?: string[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
async function stepsFlow(inquirer, entities, relationships): Promise<Step[]> {
|
|
18
|
+
const steps: Step[] = [];
|
|
19
|
+
const { doPrompt } = await inquirer.prompt({
|
|
20
|
+
type: 'confirm',
|
|
21
|
+
name: 'doPrompt',
|
|
22
|
+
message: 'Do you want to declare any steps?',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
if (!doPrompt) return steps;
|
|
26
|
+
|
|
27
|
+
await askRepeatedly(inquirer, async () => {
|
|
28
|
+
const step = await createStep(inquirer, entities, relationships);
|
|
29
|
+
steps.push(step);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (steps.length < 1) return steps;
|
|
33
|
+
|
|
34
|
+
const useStepDependenciesFlow = await confirmPrompt(
|
|
35
|
+
inquirer,
|
|
36
|
+
'Do you want to declare any step dependencies?',
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
if (!useStepDependenciesFlow) return steps;
|
|
40
|
+
|
|
41
|
+
for (const [i, step] of steps.entries()) {
|
|
42
|
+
const { dependsOn } = await inquirer.prompt({
|
|
43
|
+
type: 'checkbox-plus',
|
|
44
|
+
name: 'dependsOn',
|
|
45
|
+
message: `Which steps does '${step.name}' directly depend on?`,
|
|
46
|
+
searchable: true,
|
|
47
|
+
pageSize: 10,
|
|
48
|
+
validate(input) {
|
|
49
|
+
return true;
|
|
50
|
+
},
|
|
51
|
+
source(ans, input) {
|
|
52
|
+
return new Promise((resolve) => {
|
|
53
|
+
const choices = choicesWithoutSelf(steps, i);
|
|
54
|
+
if (input) {
|
|
55
|
+
const filteredChoices = searchSteps(steps, input);
|
|
56
|
+
resolve(filteredChoices);
|
|
57
|
+
} else {
|
|
58
|
+
resolve(choices);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
step.dependsOn = dependsOn;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return steps;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function choicesWithoutSelf(steps: Step[], stepIndex) {
|
|
71
|
+
return steps
|
|
72
|
+
.filter((_, ix) => ix !== stepIndex)
|
|
73
|
+
.map((v) => ({ name: v.name, value: v.name }));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function searchSteps(steps: Step[], searchString: string) {
|
|
77
|
+
return steps.filter((v) =>
|
|
78
|
+
v.name.toLowerCase().includes(searchString.toLowerCase()),
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function createStep(inquirer, entities, relationships) {
|
|
83
|
+
const { name } = await inquirer.prompt({
|
|
84
|
+
type: 'input',
|
|
85
|
+
name: 'name',
|
|
86
|
+
message: 'What should the steps name be?',
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const { stepEntities } = await inquirer.prompt({
|
|
90
|
+
type: 'checkbox',
|
|
91
|
+
name: 'stepEntities',
|
|
92
|
+
message: 'What entities will this step produce?',
|
|
93
|
+
choices: generateChoicesFromEntities(entities),
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const { stepRelationships } = await inquirer.prompt({
|
|
97
|
+
type: 'checkbox',
|
|
98
|
+
name: 'stepRelationships',
|
|
99
|
+
message: 'What relationships will this step produce?',
|
|
100
|
+
choices: generateRelationshipChoices(relationships),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
name,
|
|
105
|
+
entities: stepEntities,
|
|
106
|
+
relationships: stepRelationships,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function generateRelationshipChoices(relationships) {
|
|
111
|
+
const choices: { name: string; value: Relationship }[] = [];
|
|
112
|
+
|
|
113
|
+
for (const rel of relationships) {
|
|
114
|
+
choices.push({
|
|
115
|
+
name: generateRelationshipType(rel._class, rel.from, rel.to),
|
|
116
|
+
value: rel,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return choices;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export { stepsFlow };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dist
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Description
|
|
2
|
+
|
|
3
|
+
Thank you for contributing to a JupiterOne integration!
|
|
4
|
+
|
|
5
|
+
## Summary
|
|
6
|
+
|
|
7
|
+
<!-- Summary here! -->
|
|
8
|
+
|
|
9
|
+
## Type of change
|
|
10
|
+
|
|
11
|
+
Please leave any irrelevant options unchecked.
|
|
12
|
+
|
|
13
|
+
- [ ] Bug fix (non-breaking change which fixes an issue)
|
|
14
|
+
- [ ] New feature (non-breaking change which adds functionality)
|
|
15
|
+
- [ ] Breaking change (fix or feature that would cause existing functionality to
|
|
16
|
+
not work as expected)
|
|
17
|
+
- [ ] This change requires a documentation update
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
name: Build
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- name: Check out code repository source code
|
|
13
|
+
uses: actions/checkout@v3
|
|
14
|
+
|
|
15
|
+
- id: setup-node
|
|
16
|
+
name: Setup Node
|
|
17
|
+
uses: actions/setup-node@v3
|
|
18
|
+
with:
|
|
19
|
+
node-version: 18.x
|
|
20
|
+
cache: yarn
|
|
21
|
+
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: yarn --frozen-lockfile
|
|
24
|
+
|
|
25
|
+
- name: Run tests
|
|
26
|
+
run: yarn test:ci
|
|
27
|
+
|
|
28
|
+
- name: Run build
|
|
29
|
+
run: yarn build
|
|
30
|
+
|
|
31
|
+
# Publishing is done in a separate job to allow
|
|
32
|
+
# for all matrix builds to complete.
|
|
33
|
+
BuildRelease:
|
|
34
|
+
needs: test
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
if: github.ref == 'refs/heads/main'
|
|
37
|
+
name: Checkout Code
|
|
38
|
+
steps:
|
|
39
|
+
- name: Check out repo
|
|
40
|
+
uses: actions/checkout@v3
|
|
41
|
+
with:
|
|
42
|
+
fetch-depth: 0
|
|
43
|
+
token: ${{ secrets.AUTO_GITHUB_PAT_TOKEN }}
|
|
44
|
+
- name: Setup Node
|
|
45
|
+
uses: actions/setup-node@v3
|
|
46
|
+
with:
|
|
47
|
+
node-version: 18.x
|
|
48
|
+
cache: yarn
|
|
49
|
+
- name: Build and Release
|
|
50
|
+
uses: jupiterone/action-npm-build-release@v1
|
|
51
|
+
with:
|
|
52
|
+
npm_auth_token: ${{ secrets.NPM_AUTH_TOKEN }}
|
|
53
|
+
gh_token: ${{ secrets.AUTO_GITHUB_PAT_TOKEN }}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# For most projects, this workflow file will not need changing; you simply need
|
|
2
|
+
# to commit it to your repository.
|
|
3
|
+
#
|
|
4
|
+
# You may wish to alter this file to override the set of languages analyzed,
|
|
5
|
+
# or to provide custom queries or build logic.
|
|
6
|
+
#
|
|
7
|
+
# ******** NOTE ********
|
|
8
|
+
# We have attempted to detect the languages in your repository. Please check
|
|
9
|
+
# the `language` matrix defined below to confirm you have the correct set of
|
|
10
|
+
# supported CodeQL languages.
|
|
11
|
+
#
|
|
12
|
+
name: 'CodeQL'
|
|
13
|
+
|
|
14
|
+
on:
|
|
15
|
+
push:
|
|
16
|
+
branches: ['main']
|
|
17
|
+
pull_request:
|
|
18
|
+
# The branches below must be a subset of the branches above
|
|
19
|
+
branches: ['main']
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
analyze:
|
|
23
|
+
name: Analyze
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
permissions:
|
|
26
|
+
actions: read
|
|
27
|
+
contents: read
|
|
28
|
+
security-events: write
|
|
29
|
+
|
|
30
|
+
strategy:
|
|
31
|
+
fail-fast: false
|
|
32
|
+
matrix:
|
|
33
|
+
language: ['javascript']
|
|
34
|
+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
|
35
|
+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
|
36
|
+
|
|
37
|
+
steps:
|
|
38
|
+
- name: Checkout repository
|
|
39
|
+
uses: actions/checkout@v3
|
|
40
|
+
|
|
41
|
+
# Initializes the CodeQL tools for scanning.
|
|
42
|
+
- name: Initialize CodeQL
|
|
43
|
+
uses: github/codeql-action/init@v2
|
|
44
|
+
with:
|
|
45
|
+
languages: ${{ matrix.language }}
|
|
46
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
47
|
+
# By default, queries listed here will override any specified in a config file.
|
|
48
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
49
|
+
|
|
50
|
+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
|
51
|
+
queries: security-extended,security-and-quality
|
|
52
|
+
|
|
53
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
|
54
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
|
55
|
+
- name: Autobuild
|
|
56
|
+
uses: github/codeql-action/autobuild@v2
|
|
57
|
+
|
|
58
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
|
59
|
+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
|
60
|
+
|
|
61
|
+
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
|
62
|
+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
|
|
63
|
+
|
|
64
|
+
# - run: |
|
|
65
|
+
# echo "Run, Build Application using script"
|
|
66
|
+
# ./location_of_script_within_repo/buildscript.sh
|
|
67
|
+
|
|
68
|
+
- name: Perform CodeQL Analysis
|
|
69
|
+
uses: github/codeql-action/analyze@v2
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: J1 Integration deployment
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types:
|
|
6
|
+
- published
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
j1-integration-deployment:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- name: Get integration name
|
|
13
|
+
id: get-integration-name
|
|
14
|
+
uses: actions/github-script@0.9.0
|
|
15
|
+
with:
|
|
16
|
+
script: |
|
|
17
|
+
const repositoryName = context.payload.repository.name
|
|
18
|
+
const integrationName = repositoryName.replace("graph-", "")
|
|
19
|
+
core.setOutput('integrationName', integrationName)
|
|
20
|
+
- name: Get version number
|
|
21
|
+
id: get-version-number
|
|
22
|
+
uses: actions/github-script@0.9.0
|
|
23
|
+
with:
|
|
24
|
+
script: |
|
|
25
|
+
const tagName = context.payload.release.tag_name
|
|
26
|
+
const versionNumber = tagName.replace("v", "")
|
|
27
|
+
core.setOutput('versionNumber', versionNumber)
|
|
28
|
+
- name: Bump integration deployment version
|
|
29
|
+
uses: JupiterOne/integration-github-actions/create-integration-deployment@v1
|
|
30
|
+
with:
|
|
31
|
+
integrationName:
|
|
32
|
+
${{ steps.get-integration-name.outputs.integrationName }}
|
|
33
|
+
releaseNotes: ${{ github.event.release.body }}
|
|
34
|
+
version: ${{ steps.get-version-number.outputs.versionNumber }}
|
|
35
|
+
githubToken: ${{ secrets.AUTO_GITHUB_PAT_TOKEN }}
|
|
36
|
+
npmAuthToken: ${{ secrets.NPM_AUTH_TOKEN }}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
name: 'Peril'
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
|
|
6
|
+
env:
|
|
7
|
+
TRANSPONDER_DOCKER_IMAGE: 081157560428.dkr.ecr.us-east-1.amazonaws.com/transponder:1
|
|
8
|
+
SECURITY_SCAN_IMAGE: ghcr.io/jupiterone/security-scan:latest
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
Peril:
|
|
12
|
+
name: Peril
|
|
13
|
+
permissions:
|
|
14
|
+
id-token: write
|
|
15
|
+
contents: read
|
|
16
|
+
packages: read
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout
|
|
21
|
+
uses: actions/checkout@v3
|
|
22
|
+
|
|
23
|
+
- name: Setup Node
|
|
24
|
+
uses: actions/setup-node@v1
|
|
25
|
+
with:
|
|
26
|
+
node-version: 18.x
|
|
27
|
+
|
|
28
|
+
- name: Run build
|
|
29
|
+
run: yarn install
|
|
30
|
+
|
|
31
|
+
- name: Get Variables
|
|
32
|
+
id: get-vars
|
|
33
|
+
run: |
|
|
34
|
+
if [[ "${GITHUB_REF}" == 'ref/head/main' && "${GITHUB_EVENT_NAME}" == 'push' ]];
|
|
35
|
+
then
|
|
36
|
+
echo ::set-output name=aws-oidc-role::arn:aws:iam::081157560428:role/github-main-role
|
|
37
|
+
else
|
|
38
|
+
echo ::set-output name=aws-oidc-role::arn:aws:iam::081157560428:role/github-pull-request-role
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
- name: Configure aws credentials
|
|
42
|
+
uses: aws-actions/configure-aws-credentials@v1
|
|
43
|
+
with:
|
|
44
|
+
role-to-assume: ${{ steps.get-vars.outputs.aws-oidc-role }}
|
|
45
|
+
role-session-name: pr-role-session
|
|
46
|
+
aws-region: us-east-1
|
|
47
|
+
|
|
48
|
+
- name: ECR login
|
|
49
|
+
uses: aws-actions/amazon-ecr-login@v1
|
|
50
|
+
id: amazon-ecr-login
|
|
51
|
+
|
|
52
|
+
- name: Login to GHCR
|
|
53
|
+
uses: docker/login-action@v2
|
|
54
|
+
with:
|
|
55
|
+
registry: ghcr.io
|
|
56
|
+
username: ${{ github.actor }}
|
|
57
|
+
password: ${{ secrets.PACKAGE_TOKEN }}
|
|
58
|
+
|
|
59
|
+
- name: Pull security-scan
|
|
60
|
+
run: |
|
|
61
|
+
docker pull $SECURITY_SCAN_IMAGE
|
|
62
|
+
|
|
63
|
+
- name: Run security-scan
|
|
64
|
+
run: |
|
|
65
|
+
docker run \
|
|
66
|
+
--user root \
|
|
67
|
+
-v /var/run/docker.sock:/var/run/docker.sock \
|
|
68
|
+
-v `pwd`:`pwd` \
|
|
69
|
+
-e AWS_ACCESS_KEY_ID=${{ env.AWS_ACCESS_KEY_ID }} \
|
|
70
|
+
-e AWS_SECRET_ACCESS_KEY=${{ env.AWS_SECRET_ACCESS_KEY }} \
|
|
71
|
+
-e AWS_SESSION_TOKEN=${{ env.AWS_SESSION_TOKEN }} \
|
|
72
|
+
-e GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
|
|
73
|
+
-e GITHUB_REF_NAME=$GITHUB_REF_NAME \
|
|
74
|
+
-e GITHUB_RUN_NUMBER=$GITHUB_RUN_NUMBER \
|
|
75
|
+
-e GITHUB_SERVER_URL=$GITHUB_SERVER_URL \
|
|
76
|
+
-e GITHUB_RUN_ID=$GITHUB_RUN_ID \
|
|
77
|
+
-e MODE=ci \
|
|
78
|
+
-w `pwd` $SECURITY_SCAN_IMAGE
|
|
79
|
+
|
|
80
|
+
- name: Pull transponder
|
|
81
|
+
run: |
|
|
82
|
+
docker pull $TRANSPONDER_DOCKER_IMAGE
|
|
83
|
+
|
|
84
|
+
- name: Run transponder
|
|
85
|
+
run: |
|
|
86
|
+
docker run --rm -v `pwd`:`pwd` -w `pwd` \
|
|
87
|
+
-e J1_API_KEY=${{ secrets.J1_API_KEY_TRANSPONDER }} \
|
|
88
|
+
-e J1_API_DOMAIN=${{ secrets.J1_API_DOMAIN_TRANSPONDER }} \
|
|
89
|
+
-e J1_ACCOUNT_ID=${{ secrets.J1_ACCOUNT_ID_TRANSPONDER }} \
|
|
90
|
+
$TRANSPONDER_DOCKER_IMAGE
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: Questions
|
|
2
|
+
on: [pull_request_target]
|
|
3
|
+
|
|
4
|
+
jobs:
|
|
5
|
+
validate:
|
|
6
|
+
runs-on: ubuntu-latest
|
|
7
|
+
|
|
8
|
+
steps:
|
|
9
|
+
- name: Check out `main` branch
|
|
10
|
+
uses: actions/checkout@v3
|
|
11
|
+
with:
|
|
12
|
+
path: source
|
|
13
|
+
|
|
14
|
+
- name: Check out target branch questions
|
|
15
|
+
uses: actions/checkout@v3
|
|
16
|
+
with:
|
|
17
|
+
ref: ${{github.event.pull_request.head.ref}}
|
|
18
|
+
repository: ${{github.event.pull_request.head.repo.full_name}}
|
|
19
|
+
path: target
|
|
20
|
+
|
|
21
|
+
- id: setup-node
|
|
22
|
+
name: Setup Node
|
|
23
|
+
uses: actions/setup-node@v3
|
|
24
|
+
with:
|
|
25
|
+
node-version: 18.x
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies for `main` branch
|
|
28
|
+
run: yarn install --cwd source --frozen-lockfile
|
|
29
|
+
|
|
30
|
+
- name: Validate questions on target branch
|
|
31
|
+
env:
|
|
32
|
+
MANAGED_QUESTIONS_JUPITERONE_ACCOUNT_ID:
|
|
33
|
+
${{ secrets.MANAGED_QUESTIONS_JUPITERONE_ACCOUNT_ID }}
|
|
34
|
+
MANAGED_QUESTIONS_JUPITERONE_API_KEY:
|
|
35
|
+
${{ secrets.MANAGED_QUESTIONS_JUPITERONE_API_KEY }}
|
|
36
|
+
run:
|
|
37
|
+
yarn --cwd source j1-integration validate-question-file -a
|
|
38
|
+
--frozen-lockfile $MANAGED_QUESTIONS_JUPITERONE_ACCOUNT_ID -k
|
|
39
|
+
$MANAGED_QUESTIONS_JUPITERONE_API_KEY -p
|
|
40
|
+
../target/jupiterone/questions/questions.yaml
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
18
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to
|
|
7
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
|
+
|
|
9
|
+
## [Unreleased]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
FROM node:18-bullseye-slim as builder
|
|
2
|
+
|
|
3
|
+
ENV JUPITERONE_INTEGRATION_DIR=/opt/jupiterone/integration
|
|
4
|
+
|
|
5
|
+
COPY package.json yarn.lock tsconfig.dist.json tsconfig.json LICENSE ${JUPITERONE_INTEGRATION_DIR}/
|
|
6
|
+
COPY src/ ${JUPITERONE_INTEGRATION_DIR}/src
|
|
7
|
+
WORKDIR ${JUPITERONE_INTEGRATION_DIR}
|
|
8
|
+
RUN apt-get update && apt-get install -y python3 make g++ && rm -rf /var/lib/api/lists/*
|
|
9
|
+
RUN yarn install
|
|
10
|
+
RUN yarn build:docker
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
FROM node:18-bullseye-slim
|
|
14
|
+
ENV JUPITERONE_INTEGRATION_DIR=/opt/jupiterone/integration
|
|
15
|
+
COPY --from=builder --chown=node:node ${JUPITERONE_INTEGRATION_DIR}/dist ${JUPITERONE_INTEGRATION_DIR}
|
|
16
|
+
COPY --from=builder --chown=node:node ${JUPITERONE_INTEGRATION_DIR}/yarn.lock ${JUPITERONE_INTEGRATION_DIR}
|
|
17
|
+
COPY scripts/ ${JUPITERONE_INTEGRATION_DIR}/scripts
|
|
18
|
+
WORKDIR ${JUPITERONE_INTEGRATION_DIR}
|
|
19
|
+
RUN apt-get update && apt-get install -y python3
|
|
20
|
+
RUN yarn install --production --fronzen-lockfile --cache-folder ./ycache && yarn global add --cache-folder ./ycache @jupiterone/integration-sdk-cli && rm -rf ./ycache && chown -R node:node /opt/jupiterone
|
|
21
|
+
RUN export PATH="$(yarn global bin):$PATH"
|
|
22
|
+
|
|
23
|
+
USER node
|
|
24
|
+
|
|
25
|
+
CMD ["sh", "scripts/execute.sh"]
|