ui: fix ability checking when anon policy is missing namespace (#14144)

ACL Policies aren't required to have any `namespace` blocks, and this is
particularly common with the anonymous policy. If a user visits the web UI
without a token already in their local storage and the anonymous policy has no
`namespace` blocks, the UI will hit unhandled exceptions when rendering the
sidebar or jobs page.

Filter for the case where there's no `namespace` block.
This commit is contained in:
Tim Gross
2022-08-16 16:13:36 -04:00
committed by GitHub
parent a5e6b8fea2
commit 18dcb70cef
2 changed files with 2 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ export default class Job extends AbstractAbility {
// For each policy record, extract all policies of all namespaces
const allNamespacePolicies = policies
.toArray()
.filter((policy) => get(policy, 'rulesJSON.Namespaces'))
.map((policy) => get(policy, 'rulesJSON.Namespaces'))
.flat()
.map((namespace = {}) => {

View File

@@ -81,6 +81,7 @@ export default class Variable extends AbstractAbility {
) {
const namespacesWithSecureVariableCapabilities = policies
.toArray()
.filter((policy) => get(policy, 'rulesJSON.Namespaces'))
.map((policy) => get(policy, 'rulesJSON.Namespaces'))
.flat()
.map((namespace = {}) => {