Skip to content

Commit 013996f

Browse files
committed
fix: solve risk assessment issue
1 parent 36fa1e7 commit 013996f

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

app/models/concerns/organization_scoped.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ module OrganizationScoped
1313
if org_id.present?
1414
where(organization_id: org_id)
1515
else
16-
Rails.logger.warn("[SCOPE] OrganizationScoped: Current.organization_id is nil for #{name}")
17-
all
16+
# SECURITY: Fail-safe - retorna scope vazio em vez de expor dados de todas as orgs
17+
Rails.logger.error("[SECURITY] OrganizationScoped: organization_id is nil for #{name} - BLOCKING ACCESS")
18+
where('1=0')
1819
end
1920
}
2021
end

app/modules/dashboard/controllers/dashboard_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ def roster_status_data
163163
def fetch_recent_activities
164164
# Fetch recent audit logs and format them.
165165
# includes(:user) preloads the user in one query — avoids N+1 on log.user&.email
166-
activities = AuditLog
166+
# SECURITY: Use organization_scoped helper for consistent scoping
167+
activities = organization_scoped(AuditLog)
167168
.includes(:user)
168-
.where(organization: current_organization)
169169
.order(created_at: :desc)
170170
.limit(20)
171171

0 commit comments

Comments
 (0)