Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions frontend/public/components/utils/rbac.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as React from 'react';
import { connect } from 'react-redux';
import * as _ from 'lodash-es';

import { getName, getNamespace } from '@console/shared';

import store from '../../redux';
import { impersonateStateToProps } from '../../reducers/ui';
import {
Expand Down Expand Up @@ -87,10 +89,16 @@ type RequireCreatePermissionProps = {
children: React.ReactNode;
};

export const asAccessReview = (kindObj: K8sKind, obj: K8sResourceKind, verb: K8sVerb): AccessReviewResourceAttributes => ({
group: kindObj.apiGroup,
resource: kindObj.plural,
name: obj.metadata.name,
namespace: obj.metadata.namespace,
verb,
});
export const asAccessReview = (kindObj: K8sKind, obj: K8sResourceKind, verb: K8sVerb): AccessReviewResourceAttributes => {
if (!obj){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return null if the obj is null

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't return null here, it will make an entirely different, unintended access review check. That is my original concern with the change :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah sorry, my bad. Fixed

console.warn('review obj should not be null'); // eslint-disable-line no-console
return null;
}
return ({
group: kindObj.apiGroup,
resource: kindObj.plural,
name: getName(obj),
namespace: getNamespace(obj),
verb,
});
};