Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
17.10.9
-
None
-
Unknown
-
Description
Steps to reproduce* Create a page holding an XWiki.WikiMacroClass object whose visibility is Current Wiki (the default), with some Velocity in its code property.
- Open "Information" > "Review required rights" and read the recommendation.
- Select the recommended right, enforce it, and save.
- Look at a page that uses the macro.
Expected result
The analysis recommends Wiki Admin, because that is the right the document author needs for the macro to be registered at all.
Actual result
The analysis recommends Script, which is only what the macro's body needs. Enforcing it caps the document author below what registration requires, so the macro is silently never registered and every page using it renders {{Unknown macro: }}. Nothing in "Analysis Details" hints at the cause, and the page that breaks is not the page that was edited.
Why
DefaultWikiMacroFactory.isAllowed checks, against the macro document's author, Right.PROGRAM for Global visibility and Right.ADMIN at EntityType.WIKI for Current Wiki visibility. That has been the intended behaviour since XWIKI-7880.
The analyzer never learned about it: there is no RequiredRightAnalyzer registered for XWiki.WikiMacroClass. The only one the module ships is WikiMacroParameterObjectRequiredRightAnalyzer, for WikiMacroParameterClass, which analyses the parameter's wiki content. So a WikiMacroClass object falls through to DefaultObjectRequiredRightAnalyzer, which reads the object's wiki-content properties, sees the Velocity in code and stops at Script.
The two analogous cases are handled, which is what makes this easy to miss:
- UIExtensionRequiredRightsAnalyzer maps a UI extension's scope to wiki admin, and even carries a dedicated message for it (uiextension.requiredrights.wiki / uiextension.requiredrights.global);
- TranslationDocumentObjectRequiredRightAnalyzer does the same for a wiki-scoped translation bundle.
Suggested fix
A RequiredRightAnalyzer for XWiki.WikiMacroClass that reads visibility the way UIExtensionRequiredRightsAnalyzer reads scope: report wiki admin as required for Current Wiki and programming right for Global, in addition to whatever the macro body needs. Registering it under the class-name hint is enough to stop the fall-through to the default analyzer.
Verified on
Checked by reading the shipped jars of the jetty-hsqldb flavors of 17.10.9 and 18.6.0: in both, META-INF/components.txt of xwiki-platform-legacy-rendering-wikimacro-store declares only WikiMacroParameterObjectRequiredRightAnalyzer, and no other module declares an analyzer for WikiMacroClass. The behaviour is therefore present in the current LTS line and in current dev. It has most likely been there since required-rights analysis was introduced; 17.10.9 is simply the oldest release I confirmed rather than the oldest affected.
How it was found
In xwiki-contrib/application-releasenotes (RN-111) the analyzer was asked page by page over the requiredRights REST resource and its recommendation applied verbatim. It reported Script for all five of the application's wiki-visible macro pages; the resulting build failed 6 of 10 functional tests with Unknown macro, and the cause was invisible both to mvn install and to a local wiki that already had the macros registered from an earlier install. See https://github.com/xwiki-contrib/application-releasenotes/pull/51 for the diagnosis.
Attachments
Issue Links
- relates to
-
XWIKI-7880 Wiki Macro should require admin right for WIKI scope
-
- Closed
-
-
XWIKI-22821 Allow having generic analyzers for different types of macro arguments
-
- Closed
-