Skip to content

Commit cd23b23

Browse files
committed
enhance plan visibility check
1 parent 9cf8c45 commit cd23b23

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

app/controllers/v3/service_instances_controller.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ def create_user_provided(message)
254254

255255
def create_managed(message, space:)
256256
service_plan = ServicePlan.first(guid: message.service_plan_guid)
257+
log_service_plan_visibility(service_plan)
257258
unprocessable_service_plan! unless service_plan_valid?(service_plan)
258259
unavailable_service_plan!(service_plan) unless service_plan_active?(service_plan)
259260
service_plan_not_visible_in_space!(service_plan, space) unless service_plan_exists_in_space?(service_plan, space)
@@ -413,6 +414,7 @@ def raise_if_invalid_service_plan!(service_instance, message)
413414
return unless message.service_plan_guid
414415

415416
service_plan = ServicePlan.first(guid: message.service_plan_guid)
417+
log_service_plan_visibility(service_plan)
416418
unprocessable_service_plan! unless service_plan_valid?(service_plan)
417419
unavailable_service_plan!(service_plan) unless service_plan_active?(service_plan)
418420
service_plan_not_visible_in_space!(service_plan, service_instance.space) unless service_plan_exists_in_space?(service_plan, service_instance.space)
@@ -458,4 +460,20 @@ def operation_in_progress!
458460
def read_scope
459461
%w[show_permissions].include?(action_name) && roles.cloud_controller_service_permissions_reader? ? true : super
460462
end
463+
464+
def logger
465+
@logger ||= Steno.logger('cc.api')
466+
end
467+
468+
def log_service_plan_visibility(service_plan)
469+
unless service_plan
470+
logger.info('Service Plan does not exist.')
471+
return
472+
end
473+
474+
return if visible_to_current_user?(plan: service_plan)
475+
476+
user = VCAP::CloudController::SecurityContext.current_user
477+
logger.info("Service Plan with guid '#{service_plan.guid}' and id '#{service_plan.id}' is not visible in current org to user with guid '#{user.guid}'.")
478+
end
461479
end

0 commit comments

Comments
 (0)