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 #566 from JupiterOne/INT-6165-permissions-logs
Browse files Browse the repository at this point in the history
feat(INT-6165): change permissions logs to warnings
  • Loading branch information
gastonyelmini authored Jan 9, 2023
2 parents bbd0a2f + 18c7c00 commit 88cedef
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/steps/app-engine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);
Expand Down
2 changes: 1 addition & 1 deletion src/steps/binary-authorization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);
Expand Down
2 changes: 1 addition & 1 deletion src/steps/cloud-asset/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export async function fetchIamBindings(
);
} catch (err) {
if (err.status === 403) {
logger.info(
logger.warn(
{
err,
},
Expand Down
4 changes: 2 additions & 2 deletions src/steps/compute/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);
Expand Down Expand Up @@ -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',
);
Expand Down
27 changes: 19 additions & 8 deletions src/steps/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
});
}
}
Expand Down

0 comments on commit 88cedef

Please sign in to comment.