Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change RexExp #5201

Merged
merged 2 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ All notable changes to the Wazuh app project will be documented in this file.

### Changed

-
- Changed of regular expression in RBAC. [#5201](https://github.com/wazuh/wazuh-kibana-app/pull/5201)

### Fixed

Expand Down
10 changes: 5 additions & 5 deletions public/react-services/wz-user-permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class WzUserPermissions{
const missingOrPermissions = WzUserPermissions.checkMissingUserPermissions(permission, userPermissions);
return Array.isArray(missingOrPermissions) ? missingOrPermissions.length === permission.length : missingOrPermissions;
}

const isGenericResource = (permission.resource.match(':\\*') || []).index === permission.resource.length - 2

const actionName = typeof permission === 'string' ? permission : permission.action;
Expand All @@ -48,8 +48,8 @@ export class WzUserPermissions{
const simplePermission = (resource: string) => {
return (
![actionResource, actionResourceAll].includes(resource) &&
(resource.match(actionResource.replace('*', '\\*')) ||
resource.match(actionResourceAll.replace('*', '\*')))
(resource.match(actionResource.replace(/\*/g, '.+')) ||
resource.match(actionResourceAll.replace(/\*/g, '.+')))
);
};

Expand Down Expand Up @@ -102,10 +102,10 @@ export class WzUserPermissions{
return userPermissions[actionName][actionResource]
? notAllowInWazuhPermissions(actionResource)
: Object.keys(userPermissions[actionName]).some((resource) => {
return resource.match(actionResourceAll.replace('*', '\\*')) !== null;
return resource.match(actionResourceAll.replace(/\*/g, '.+')) !== null;
})
? Object.keys(userPermissions[actionName]).some((resource) => {
if (resource.match(actionResourceAll.replace('*', '\\*'))) {
if (resource.match(actionResourceAll.replace(/\*/g, '.+'))) {
return notAllowInWazuhPermissions(resource);
}
})
Expand Down