Conversation
…Script - Drop locals that are declared but never read across the admin/common/ end-user UI and the bundled scripts, including two dead helper functions - Add the missing semicolons where automatic semicolon insertion was relied on - policy.js: remove the unreachable "resource === null" branch and treat an undefined resourcePath like a null one Resolves CodeQL alerts #761-#767, #788-#854, #860, #864, #867, #868, #872-#879, #908, #922, #923.
Comment on lines
+894
to
+895
| policyRequirements = validate(policies, conditionalPolicies, fallbackPolicies, fullObject, | ||
| propName, getPropertyValue(fullObject, propName), failedPolicyRequirements); |
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
Fourth note-level CodeQL batch: the JavaScript findings —
js/unused-local-variable(93),js/automatic-semicolon-insertion(7),js/unneeded-defensive-code(1). 87 fixed across 42 files, 14 dismissed as false positives.This PR deliberately also touches files that #204, #209 and #210 change (
policy.js,router-authz.js,autoPurgeAuditRecon.js,postOperation-roles.js,temporalConstraints.js,defaultMapping.js,FormGenerationUtils.js,RelationshipWidget.js,UserQueryFilterEditor.js); the overlaps are neighbouring line removals and will be resolved at merge time, whichever lands second.js/unused-local-variablevar x,= []/= {}/= this, side-effect-free DOM lookups,$.Deferred(),AbstractModel.extend(...), an unusedrequire('roles/effectiveRoles'); two dead helpers (getUserByIdingetavailableuserstoassign.js,joiningettasksview.js); the unusedallUsedClasses/usableForQueriesClassesblock inAuditEventHandlersView. Where avarlist was shortened, the following object/array literal was re-indented (eslintindent). TheexcludeMappings→excludeMappingtypo inautoPurgeAuditRecon.jsis the same fix as in #209.js/automatic-semicolon-insertion;added inreconResults.js,resetPassword.js,router-authz.js,policy.js×2,autoPurgeAuditRecon.js,defaultMapping.js.js/unneeded-defensive-codepolicy.js:getResource()never yieldsnull(an unconfigured resource becomes an empty entry), so theif (resource === null) … else …around the validation was dead; the body is unwrapped. Small correctness gain: anundefinedresourcePathnow fails with "No resource specified" like anullone instead of aTypeError.Dismissed as false positives (14): the 13
router-authz.js"unused function" alerts (ownDataOnly,isOneOfMyWorkflows,reauthIfProtectedAttributeChange, …) — they are referenced by name from thecustomAuthzexpressions inconf/script/access.js, whichpassesAccessConfig()evaluates witheval(); andpolicy.jsaddPolicy, the documented API that custom policy scripts call, again througheval()insideadditionalPolicyLoader.load().Test plan
.jsparse-checked with Node and linted with the module's eslint configopenidm-ui-common,openidm-ui-admin,openidm-ui-enduser: eslint clean, QUnit green, BUILD SUCCESSmvn -pl openidm-zip -am package—ScriptRunnerTestgreen over all JS test modules (incl.policyFilterTest,effectiveRolesTest,temporalConstraintsTest,conditionalRolesTest)