fix: security hardening, XSS prevention, perf fixes, and org-based KB visibility#3177
Open
srujan00123 wants to merge 2 commits intofrappe:developfrom
Open
fix: security hardening, XSS prevention, perf fixes, and org-based KB visibility#3177srujan00123 wants to merge 2 commits intofrappe:developfrom
srujan00123 wants to merge 2 commits intofrappe:developfrom
Conversation
Security fixes: - Fix admin check logic bug (always evaluated truthy) and typo in api/auth.py - Fix auth bypass via substring path matching in auth.py - Fix has_app_permission() always returning True - Add permission check in saved_replies API (IDOR prevention) - Escape values in generated JS to prevent injection (field_dependency.py) - Fix bare except clause in hd_ticket.py permission check - Remove v-html XSS vectors in SearchAgent, SearchArticles, ConfirmDialog, dialogs - Add socket.user validation and room membership checks in Socket.IO handlers - Restrict window globals to allowlist in main.js Performance & stability: - Fix N+1 query in doc.py group_by options (batch fetch labels) - Fix event listener memory leak in realtime.ts (stored handler refs + cleanup) - Add try-catch around JSON.parse calls in frontend composables - Reduce view pageLength from 1000 to 100 - Add missing return after redirect in router guard - Guard empty count query result in doc.py Feature: Organization-based KB article visibility - Add visibility field (Public/Restricted) to HD Article - Add HD Article Organization child doctype for org assignment - Add organization Link field to HD Customer - Filter KB articles by user's organization membership - Agents see all articles; customers see Public + their org's Restricted Code quality: - Fix Python version requirement (3.14 -> 3.11) in pyproject.toml - Fix docker/init.sh shebang and add set -e - Fix AUTHOR_EMAIl typo in welcome_ticket.py - Remove debug print() from 5 patch files - Add email validation and duplicate check in agent invites - Add pagination to get_users() API - Fix unreachable code and generic error handling in knowledge_base.py - Fix redundant f-string+format in hd_ticket.py permission_query - Fix via_customer_portal detection in ticket creation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Comprehensive code review fixes covering security vulnerabilities, frontend XSS prevention, performance improvements, and a new organization-based knowledge base visibility feature.
Security Fixes
api/auth.py)auth.py)has_app_permission()no longer returnsTruefor everyone (api/permission.py)frappe.has_permission()check in saved replies APIjson.dumps()in generated JS (field_dependency.py)socket.uservalidation and room membership checks on all eventsXSS Prevention (Frontend)
v-htmlwith text interpolation orstripHtml()in SearchAgent, SearchArticles, ConfirmDialog, dialogs.jsxPerformance & Stability
doc.pygroup_by options (batch fetch labels)realtime.ts(stored handler refs + cleanup)try-catcharoundJSON.parsecalls in frontend composablespageLengthfrom 1000 to 100returnafter redirect in router guarddoc.pyFeature: Organization-Based KB Article Visibility
visibilityfield (Public/Restricted) to HD ArticleHD Article Organizationchild doctype for org assignmentorganizationLink field to HD CustomerCode Quality
init.shshebang and addedset -eAUTHOR_EMAIltypo inwelcome_ticket.pyprint()from 5 patch filesget_users()APIknowledge_base.pyhd_ticket.pypermission_queryvia_customer_portaldetection in ticket creationTest Plan
bench startruns cleanlybench --site <site> migrateto apply doctype changes