Skip to content

Commit

Permalink
[Backport 4.5-7.10] Change RexExp (#5225)
Browse files Browse the repository at this point in the history
Change RexExp (#5201)

* change RexExp

* add changelog

(cherry picked from commit 8f51a0a)

Co-authored-by: Ian Yenien Serrano <63758389+yenienserrano@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and yenienserrano authored Mar 8, 2023
1 parent 8164e50 commit a1741e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
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

0 comments on commit a1741e4

Please sign in to comment.