mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-13 22:51:49 +00:00
fix(stock): permission check and test cleanup for bundle item fetch
The whitelisted get_items_from_product_bundle endpoint now verifies read permission on Product Bundle (doc-level when a name is passed, doctype- level for the legacy item_code path) so authenticated users can't enumerate bundle components. The disabled-bundle test also restores the disabled flag via addCleanup. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -465,6 +465,7 @@ def get_items_from_product_bundle(row: str):
|
||||
parent item's active version.
|
||||
"""
|
||||
row, items = ItemDetailsCtx(json.loads(row)), []
|
||||
frappe.has_permission("Product Bundle", "read", row.get("product_bundle"), throw=True)
|
||||
|
||||
if bundle_name := row.get("product_bundle"):
|
||||
bundle = frappe.db.get_value("Product Bundle", bundle_name, ["docstatus", "disabled"], as_dict=True)
|
||||
|
||||
@@ -232,6 +232,7 @@ class TestPackedItem(ERPNextTestSuite):
|
||||
|
||||
# a disabled version is rejected
|
||||
frappe.db.set_value("Product Bundle", version, "disabled", 1)
|
||||
self.addCleanup(frappe.db.set_value, "Product Bundle", version, "disabled", 0)
|
||||
self.assertRaises(
|
||||
frappe.ValidationError,
|
||||
get_items_from_product_bundle,
|
||||
|
||||
Reference in New Issue
Block a user