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

Commit

Permalink
Merge pull request #554 from JupiterOne/INT-5917-cloud-function-relat…
Browse files Browse the repository at this point in the history
…ionship

feat(INT-5917): add cloud function storage bucket relationship
  • Loading branch information
gastonyelmini authored Nov 9, 2022
2 parents 1ed6534 + 44fd8ab commit 43c93cc
Show file tree
Hide file tree
Showing 9 changed files with 2,809 additions and 30 deletions.
1 change: 1 addition & 0 deletions docs/jupiterone.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ The following relationships are created:
| `google_cloud_folder` | **HAS** | `google_cloud_folder` |
| `google_cloud_function` | **USES** | `google_iam_service_account` |
| `google_cloud_function` | **USES** | `google_cloud_source_repository` |
| `google_cloud_function` | **USES** | `google_storage_bucket` |
| `google_cloud_organization` | **HAS** | `google_cloud_folder` |
| `google_cloud_project` | **HAS** | `google_cloud_api_service` |
| `google_cloud_project` | **HAS** | `google_billing_budget` |
Expand Down
2 changes: 1 addition & 1 deletion docs/spec/src/steps/services/functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const functionSteps: StepSpec<IntegrationInstanceConfig>[] = [
},
],
dependsOn: ['fetch-cloud-functions', 'fetch-cloud-storage-buckets'],
implemented: false,
implemented: true,
},
{
/**
Expand Down
5 changes: 5 additions & 0 deletions src/getStepStartStates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ import {
STEP_CLOUD_FUNCTIONS,
STEP_CLOUD_FUNCTIONS_SERVICE_ACCOUNT_RELATIONSHIPS,
STEP_CLOUD_FUNCTIONS_SOURCE_REPO_RELATIONSHIPS,
STEP_CLOUD_FUNCTIONS_STORAGE_BUCKET_RELATIONSHIPS,
} from './steps/functions';
import {
STEP_IAM_CUSTOM_ROLES,
Expand Down Expand Up @@ -303,6 +304,7 @@ function getDefaultStepStartStates(params: {
[STEP_CLOUD_FUNCTIONS]: { disabled: false },
[STEP_CLOUD_FUNCTIONS_SERVICE_ACCOUNT_RELATIONSHIPS]: { disabled: false },
[STEP_CLOUD_FUNCTIONS_SOURCE_REPO_RELATIONSHIPS]: { disabled: false },
[STEP_CLOUD_FUNCTIONS_STORAGE_BUCKET_RELATIONSHIPS]: { disabled: false },
[STEP_CLOUD_STORAGE_BUCKETS]: { disabled: false },
[STEP_IAM_CUSTOM_ROLES]: { disabled: false },
[STEP_IAM_CUSTOM_ROLE_SERVICE_API_RELATIONSHIPS]: { disabled: false },
Expand Down Expand Up @@ -596,6 +598,9 @@ async function getStepStartStatesUsingServiceEnablements(params: {
[STEP_CLOUD_FUNCTIONS_SOURCE_REPO_RELATIONSHIPS]: createStepStartState(
ServiceUsageName.CLOUD_FUNCTIONS,
),
[STEP_CLOUD_FUNCTIONS_STORAGE_BUCKET_RELATIONSHIPS]: createStepStartState(
ServiceUsageName.CLOUD_FUNCTIONS,
),
[STEP_CLOUD_STORAGE_BUCKETS]: createStepStartState(
ServiceUsageName.STORAGE,
ServiceUsageName.STORAGE_COMPONENT,
Expand Down
4 changes: 4 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ import {
STEP_CLOUD_FUNCTIONS,
STEP_CLOUD_FUNCTIONS_SERVICE_ACCOUNT_RELATIONSHIPS,
STEP_CLOUD_FUNCTIONS_SOURCE_REPO_RELATIONSHIPS,
STEP_CLOUD_FUNCTIONS_STORAGE_BUCKET_RELATIONSHIPS,
} from './steps/functions';

interface ValidateInvocationInvalidConfigTestParams {
Expand Down Expand Up @@ -330,6 +331,9 @@ describe('#getStepStartStates success', () => {
[STEP_CLOUD_FUNCTIONS_SOURCE_REPO_RELATIONSHIPS]: {
disabled: false,
},
[STEP_CLOUD_FUNCTIONS_STORAGE_BUCKET_RELATIONSHIPS]: {
disabled: false,
},
[STEP_CLOUD_STORAGE_BUCKETS]: {
disabled: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@
"url": "https://www.googleapis.com/oauth2/v4/token"
},
"response": {
"bodySize": 414,
"bodySize": 384,
"content": {
"encoding": "utf-8",
"mimeType": "application/json; charset=UTF-8",
"size": 414,
"size": 384,
"text": "{\"access_token\":\"[REDACTED]\",\"expires_in\":9999,\"token_type\":\"Bearer\"}"
},
"cookies": [],
Expand All @@ -81,7 +81,7 @@
},
{
"name": "date",
"value": "Tue, 01 Nov 2022 15:52:58 GMT"
"value": "Tue, 08 Nov 2022 15:57:25 GMT"
},
{
"name": "server",
Expand Down Expand Up @@ -118,16 +118,16 @@
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2022-11-01T15:52:58.699Z",
"time": 145,
"startedDateTime": "2022-11-08T15:57:25.395Z",
"time": 119,
"timings": {
"blocked": -1,
"connect": -1,
"dns": -1,
"receive": 0,
"send": 0,
"ssl": -1,
"wait": 145
"wait": 119
}
},
{
Expand Down Expand Up @@ -180,12 +180,12 @@
"url": "https://cloudfunctions.googleapis.com/v1/projects/j1-gc-integration-dev-v3/locations/-/functions"
},
"response": {
"bodySize": 1145,
"bodySize": 1420,
"content": {
"encoding": "utf-8",
"mimeType": "application/json; charset=UTF-8",
"size": 1145,
"text": "{\"functions\":[{\"name\":\"projects/j1-gc-integration-dev-v3/locations/us-central1/functions/gaston-delete\",\"sourceRepository\":{\"url\":\"https://source.developers.google.com/projects/j1-gc-integration-dev-v3/repos/gaston/moveable-aliases/master/paths/\",\"deployedUrl\":\"https://source.developers.google.com/projects/j1-gc-integration-dev-v3/repos/gaston/revisions//paths/\"},\"httpsTrigger\":{\"url\":\"https://us-central1-j1-gc-integration-dev-v3.cloudfunctions.net/gaston-delete\",\"securityLevel\":\"SECURE_ALWAYS\"},\"status\":\"UNKNOWN\",\"entryPoint\":\"helloWorld\",\"timeout\":\"60s\",\"availableMemoryMb\":256,\"serviceAccountEmail\":\"[email protected]\",\"updateTime\":\"2022-10-31T12:04:14.816Z\",\"versionId\":\"1\",\"labels\":{\"deployment-tool\":\"console-cloud\"},\"runtime\":\"nodejs16\",\"maxInstances\":3000,\"ingressSettings\":\"ALLOW_ALL\",\"dockerRegistry\":\"CONTAINER_REGISTRY\"},{\"name\":\"projects/j1-gc-integration-dev-v3/locations/us-central1/functions/j1-gc-integration-dev-v3testfunction\",\"description\":\"Test function\",\"sourceArchiveUrl\":\"gs://j1-gc-integration-dev-v3cloudfunctions/http_trigger.zip\",\"httpsTrigger\":{\"url\":\"https://us-central1-j1-gc-integration-dev-v3.cloudfunctions.net/j1-gc-integration-dev-v3testfunction\",\"securityLevel\":\"SECURE_OPTIONAL\"},\"status\":\"ACTIVE\",\"entryPoint\":\"handler\",\"timeout\":\"60s\",\"availableMemoryMb\":128,\"serviceAccountEmail\":\"[email protected]\",\"updateTime\":\"2021-05-31T16:36:15.024Z\",\"versionId\":\"1\",\"environmentVariables\":{\"TEST_ENV_VAR\":\"test-env-var-val\"},\"runtime\":\"nodejs10\",\"ingressSettings\":\"ALLOW_ALL\",\"buildId\":\"468a40b5-ba13-41aa-84d8-0ffb43a9c153\",\"buildName\":\"projects/167984947943/locations/us-central1/builds/468a40b5-ba13-41aa-84d8-0ffb43a9c153\",\"dockerRegistry\":\"CONTAINER_REGISTRY\"},{\"name\":\"projects/j1-gc-integration-dev-v3/locations/us-central1/functions/j1-gc-integration-dev-v3testfunctionwithsa\",\"description\":\"Test function with service account\",\"sourceArchiveUrl\":\"gs://j1-gc-integration-dev-v3cloudfunctions/http_trigger.zip\",\"httpsTrigger\":{\"url\":\"https://us-central1-j1-gc-integration-dev-v3.cloudfunctions.net/j1-gc-integration-dev-v3testfunctionwithsa\",\"securityLevel\":\"SECURE_OPTIONAL\"},\"status\":\"ACTIVE\",\"entryPoint\":\"handler\",\"timeout\":\"60s\",\"availableMemoryMb\":128,\"serviceAccountEmail\":\"j1-gc-integration-dev-f-sa@j1-gc-integration-dev-v3.iam.gserviceaccount.com\",\"updateTime\":\"2021-05-31T16:36:14.851Z\",\"versionId\":\"1\",\"environmentVariables\":{\"TEST_ENV_VAR\":\"test-env-var-val\"},\"runtime\":\"nodejs10\",\"ingressSettings\":\"ALLOW_ALL\",\"buildId\":\"f90313dc-1de2-4181-8709-9865b6507e04\",\"buildName\":\"projects/167984947943/locations/us-central1/builds/f90313dc-1de2-4181-8709-9865b6507e04\",\"dockerRegistry\":\"CONTAINER_REGISTRY\"}]}"
"size": 1420,
"text": "{\"functions\":[{\"name\":\"projects/j1-gc-integration-dev-v3/locations/us-central1/functions/function-1\",\"sourceRepository\":{\"url\":\"https://source.developers.google.com/projects/j1-gc-integration-dev-v3/repos/nacho/moveable-aliases/master/paths/\",\"deployedUrl\":\"https://source.developers.google.com/projects/j1-gc-integration-dev-v3/repos/nacho/revisions//paths/\"},\"httpsTrigger\":{\"url\":\"https://us-central1-j1-gc-integration-dev-v3.cloudfunctions.net/function-1\",\"securityLevel\":\"SECURE_ALWAYS\"},\"status\":\"UNKNOWN\",\"entryPoint\":\"helloWorld\",\"timeout\":\"60s\",\"availableMemoryMb\":256,\"serviceAccountEmail\":\"[email protected]\",\"updateTime\":\"2022-11-01T19:38:17.683Z\",\"versionId\":\"1\",\"labels\":{\"deployment-tool\":\"console-cloud\"},\"runtime\":\"nodejs16\",\"maxInstances\":3000,\"ingressSettings\":\"ALLOW_ALL\",\"dockerRegistry\":\"CONTAINER_REGISTRY\"},{\"name\":\"projects/j1-gc-integration-dev-v3/locations/us-central1/functions/gaston-delete\",\"sourceRepository\":{\"url\":\"https://source.developers.google.com/projects/j1-gc-integration-dev-v3/repos/gaston/moveable-aliases/master/paths/\",\"deployedUrl\":\"https://source.developers.google.com/projects/j1-gc-integration-dev-v3/repos/gaston/revisions//paths/\"},\"httpsTrigger\":{\"url\":\"https://us-central1-j1-gc-integration-dev-v3.cloudfunctions.net/gaston-delete\",\"securityLevel\":\"SECURE_ALWAYS\"},\"status\":\"UNKNOWN\",\"entryPoint\":\"helloWorld\",\"timeout\":\"60s\",\"availableMemoryMb\":256,\"serviceAccountEmail\":\"[email protected]\",\"updateTime\":\"2022-10-31T12:04:14.816Z\",\"versionId\":\"1\",\"labels\":{\"deployment-tool\":\"console-cloud\"},\"runtime\":\"nodejs16\",\"maxInstances\":3000,\"ingressSettings\":\"ALLOW_ALL\",\"dockerRegistry\":\"CONTAINER_REGISTRY\"},{\"name\":\"projects/j1-gc-integration-dev-v3/locations/us-central1/functions/gaston-delete-2\",\"sourceArchiveUrl\":\"gs://gaston-delete/carpeta sin título.zip\",\"httpsTrigger\":{\"url\":\"https://us-central1-j1-gc-integration-dev-v3.cloudfunctions.net/gaston-delete-2\",\"securityLevel\":\"SECURE_ALWAYS\"},\"status\":\"OFFLINE\",\"entryPoint\":\"helloWorld\",\"timeout\":\"60s\",\"availableMemoryMb\":256,\"serviceAccountEmail\":\"[email protected]\",\"updateTime\":\"2022-11-04T13:15:28.330Z\",\"versionId\":\"1\",\"labels\":{\"deployment-tool\":\"console-cloud\"},\"runtime\":\"nodejs16\",\"maxInstances\":3000,\"ingressSettings\":\"ALLOW_ALL\",\"buildId\":\"e7790f72-962e-4bef-aac1-3f49efe41066\",\"buildName\":\"projects/167984947943/locations/us-central1/builds/e7790f72-962e-4bef-aac1-3f49efe41066\",\"dockerRegistry\":\"CONTAINER_REGISTRY\"},{\"name\":\"projects/j1-gc-integration-dev-v3/locations/us-central1/functions/j1-gc-integration-dev-v3testfunction\",\"description\":\"Test function\",\"sourceArchiveUrl\":\"gs://j1-gc-integration-dev-v3cloudfunctions/http_trigger.zip\",\"httpsTrigger\":{\"url\":\"https://us-central1-j1-gc-integration-dev-v3.cloudfunctions.net/j1-gc-integration-dev-v3testfunction\",\"securityLevel\":\"SECURE_OPTIONAL\"},\"status\":\"ACTIVE\",\"entryPoint\":\"handler\",\"timeout\":\"60s\",\"availableMemoryMb\":128,\"serviceAccountEmail\":\"[email protected]\",\"updateTime\":\"2021-05-31T16:36:15.024Z\",\"versionId\":\"1\",\"environmentVariables\":{\"TEST_ENV_VAR\":\"test-env-var-val\"},\"runtime\":\"nodejs10\",\"ingressSettings\":\"ALLOW_ALL\",\"buildId\":\"468a40b5-ba13-41aa-84d8-0ffb43a9c153\",\"buildName\":\"projects/167984947943/locations/us-central1/builds/468a40b5-ba13-41aa-84d8-0ffb43a9c153\",\"dockerRegistry\":\"CONTAINER_REGISTRY\"},{\"name\":\"projects/j1-gc-integration-dev-v3/locations/us-central1/functions/j1-gc-integration-dev-v3testfunctionwithsa\",\"description\":\"Test function with service account\",\"sourceArchiveUrl\":\"gs://j1-gc-integration-dev-v3cloudfunctions/http_trigger.zip\",\"httpsTrigger\":{\"url\":\"https://us-central1-j1-gc-integration-dev-v3.cloudfunctions.net/j1-gc-integration-dev-v3testfunctionwithsa\",\"securityLevel\":\"SECURE_OPTIONAL\"},\"status\":\"ACTIVE\",\"entryPoint\":\"handler\",\"timeout\":\"60s\",\"availableMemoryMb\":128,\"serviceAccountEmail\":\"j1-gc-integration-dev-f-sa@j1-gc-integration-dev-v3.iam.gserviceaccount.com\",\"updateTime\":\"2021-05-31T16:36:14.851Z\",\"versionId\":\"1\",\"environmentVariables\":{\"TEST_ENV_VAR\":\"test-env-var-val\"},\"runtime\":\"nodejs10\",\"ingressSettings\":\"ALLOW_ALL\",\"buildId\":\"f90313dc-1de2-4181-8709-9865b6507e04\",\"buildName\":\"projects/167984947943/locations/us-central1/builds/f90313dc-1de2-4181-8709-9865b6507e04\",\"dockerRegistry\":\"CONTAINER_REGISTRY\"},{\"name\":\"projects/j1-gc-integration-dev-v3/locations/us-central1/functions/nacho\",\"sourceRepository\":{\"url\":\"https://source.developers.google.com/projects/j1-gc-integration-dev-v3/repos/default/moveable-aliases/master/paths/\",\"deployedUrl\":\"https://source.developers.google.com/projects/j1-gc-integration-dev-v3/repos/default/revisions//paths/\"},\"httpsTrigger\":{\"url\":\"https://us-central1-j1-gc-integration-dev-v3.cloudfunctions.net/nacho\",\"securityLevel\":\"SECURE_ALWAYS\"},\"status\":\"UNKNOWN\",\"entryPoint\":\"helloWorld\",\"timeout\":\"60s\",\"availableMemoryMb\":256,\"serviceAccountEmail\":\"[email protected]\",\"updateTime\":\"2022-11-01T19:37:28.455Z\",\"versionId\":\"1\",\"labels\":{\"deployment-tool\":\"console-cloud\"},\"runtime\":\"nodejs16\",\"maxInstances\":3000,\"ingressSettings\":\"ALLOW_ALL\",\"dockerRegistry\":\"CONTAINER_REGISTRY\"}]}"
},
"cookies": [],
"headers": [
Expand All @@ -199,7 +199,7 @@
},
{
"name": "date",
"value": "Tue, 01 Nov 2022 15:52:59 GMT"
"value": "Tue, 08 Nov 2022 15:57:26 GMT"
},
{
"name": "server",
Expand Down Expand Up @@ -236,16 +236,16 @@
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2022-11-01T15:52:58.847Z",
"time": 965,
"startedDateTime": "2022-11-08T15:57:25.520Z",
"time": 708,
"timings": {
"blocked": -1,
"connect": -1,
"dns": -1,
"receive": 0,
"send": 0,
"ssl": -1,
"wait": 965
"wait": 708
}
},
{
Expand Down Expand Up @@ -303,11 +303,11 @@
"url": "https://www.googleapis.com/oauth2/v4/token"
},
"response": {
"bodySize": 394,
"bodySize": 445,
"content": {
"encoding": "utf-8",
"mimeType": "application/json; charset=UTF-8",
"size": 394,
"size": 445,
"text": "{\"access_token\":\"[REDACTED]\",\"expires_in\":9999,\"token_type\":\"Bearer\"}"
},
"cookies": [],
Expand All @@ -322,7 +322,7 @@
},
{
"name": "date",
"value": "Tue, 01 Nov 2022 15:53:00 GMT"
"value": "Tue, 08 Nov 2022 15:57:26 GMT"
},
{
"name": "server",
Expand Down Expand Up @@ -359,16 +359,16 @@
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2022-11-01T15:52:59.846Z",
"time": 120,
"startedDateTime": "2022-11-08T15:57:26.238Z",
"time": 116,
"timings": {
"blocked": -1,
"connect": -1,
"dns": -1,
"receive": 0,
"send": 0,
"ssl": -1,
"wait": 120
"wait": 116
}
},
{
Expand Down Expand Up @@ -421,11 +421,11 @@
"url": "https://sourcerepo.googleapis.com/v1/projects/j1-gc-integration-dev-v3/repos"
},
"response": {
"bodySize": 243,
"bodySize": 253,
"content": {
"encoding": "utf-8",
"mimeType": "application/json; charset=UTF-8",
"size": 243,
"size": 253,
"text": "{\"repos\":[{\"name\":\"projects/j1-gc-integration-dev-v3/repos/gaston\",\"url\":\"https://source.developers.google.com/p/j1-gc-integration-dev-v3/r/gaston\"},{\"name\":\"projects/j1-gc-integration-dev-v3/repos/nacho\",\"url\":\"https://source.developers.google.com/p/j1-gc-integration-dev-v3/r/nacho\"}]}"
},
"cookies": [],
Expand All @@ -440,7 +440,7 @@
},
{
"name": "date",
"value": "Tue, 01 Nov 2022 15:53:01 GMT"
"value": "Tue, 08 Nov 2022 15:57:27 GMT"
},
{
"name": "server",
Expand Down Expand Up @@ -477,16 +477,16 @@
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2022-11-01T15:52:59.976Z",
"time": 1066,
"startedDateTime": "2022-11-08T15:57:26.361Z",
"time": 979,
"timings": {
"blocked": -1,
"connect": -1,
"dns": -1,
"receive": 0,
"send": 0,
"ssl": -1,
"wait": 1066
"wait": 979
}
}
],
Expand Down
Loading

0 comments on commit 43c93cc

Please sign in to comment.