diff --git a/src/steps/app-engine/index.ts b/src/steps/app-engine/index.ts index 85e6ff47..b057f651 100644 --- a/src/steps/app-engine/index.ts +++ b/src/steps/app-engine/index.ts @@ -103,7 +103,7 @@ export async function fetchAppEngineApplication( ); } catch (err) { if (err.code === 403) { - logger.info( + logger.warn( { err }, 'Could not fetch app engine application. Requires additional permission', ); diff --git a/src/steps/binary-authorization/index.ts b/src/steps/binary-authorization/index.ts index ae6fceec..7a5bf0c7 100644 --- a/src/steps/binary-authorization/index.ts +++ b/src/steps/binary-authorization/index.ts @@ -36,7 +36,7 @@ export async function fetchBinaryAuthorizationPolicy( policy = await client.fetchPolicy(); } catch (err) { if (err.code === 403) { - logger.trace( + logger.warn( { err }, 'Could not fetch binary authorization policy. Requires additional permission', ); diff --git a/src/steps/cloud-asset/index.ts b/src/steps/cloud-asset/index.ts index 5949dfea..01a194ed 100644 --- a/src/steps/cloud-asset/index.ts +++ b/src/steps/cloud-asset/index.ts @@ -197,7 +197,7 @@ export async function fetchIamBindings( ); } catch (err) { if (err.status === 403) { - logger.info( + logger.warn( { err, }, diff --git a/src/steps/compute/index.ts b/src/steps/compute/index.ts index 003aba74..429383dd 100644 --- a/src/steps/compute/index.ts +++ b/src/steps/compute/index.ts @@ -309,7 +309,7 @@ export async function fetchComputeProject( computeProject = await client.fetchComputeProject(); } catch (err) { if (err.code === 403) { - logger.trace( + logger.warn( { err }, 'Could not fetch compute project. Requires additional permission', ); @@ -478,7 +478,7 @@ export async function buildDiskImageRelationships( ); } catch (err) { if (err.code === 403) { - logger.trace( + logger.warn( { err }, 'Could not fetch compute image. Requires additional permission', ); diff --git a/src/steps/storage/index.ts b/src/steps/storage/index.ts index 9b89c849..8de12493 100644 --- a/src/steps/storage/index.ts +++ b/src/steps/storage/index.ts @@ -4,7 +4,10 @@ import { IntegrationConfig, IntegrationStepContext } from '../../types'; import { createCloudStorageBucketEntity } from './converters'; import { StorageStepsSpec, StorageEntitiesSpec } from './constants'; import { storage_v1 } from 'googleapis'; -import { publishUnprocessedBucketsEvent } from '../../utils/events'; +import { + publishMissingPermissionEvent, + publishUnprocessedBucketsEvent, +} from '../../utils/events'; import { OrgPolicyClient } from '../orgpolicy/client'; export async function fetchStorageBuckets( @@ -25,13 +28,21 @@ export async function fetchStorageBuckets( publicAccessPreventionPolicy = await orgPolicyClient.fetchOrganizationPublicAccessPreventionPolicy(); } catch (err) { - logger.warn({ err }, 'Error fetching organization public access prevention policy'); - - if (err.code === 403 && (err.message as string).includes(`Permission 'orgpolicy.policy.get' denied on resource`)) { - logger.publishEvent({ - name: 'missing_permission', - description: - '"orgpolicy.policy.get" is not a required permission to run the Google Cloud integration, but is required for getting organization policy for "storage.publicAccessPrevention"', + logger.warn( + { err }, + 'Error fetching organization public access prevention policy', + ); + + if ( + err.code === 403 && + (err.message as string).includes( + `Permission 'orgpolicy.policy.get' denied on resource`, + ) + ) { + publishMissingPermissionEvent({ + logger, + permission: 'orgpolicy.policy.get', + stepId: StorageStepsSpec.FETCH_STORAGE_BUCKETS.id, }); } }