Skip to content

Conversation

@shaohuzhang1
Copy link
Contributor

fix: When having read permission for the application, the application settings page can be viewed

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Nov 10, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Nov 10, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

if (to.path.includes('resource-management')) { return PermissionConst.RESOURCE_APPLICATION_READ }
},
]
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The provided code has several potential issues:

  1. Function get_next_route Usage:

    • The function get_next_route() is not defined in the given snippet. Without its implementation, the logic for determining permissions will not be functional.
  2. String Matching in Conditional Logic:

    • In both cases where to.params.from == 'resource-management', nothing significant is done in either return statement. This could cause unexpected behavior if you intend to conditionally apply different policies within these routes.
  3. Permissions Return Values:

    • While it appears that PermissionConst.APPLICATION_READ should work similarly to PermissionConst.APPLICATION_EDIT, using PermissionConst.RESOURCE_APPLICATION_READ instead of PermissionConst.APPLICATION_READ when handling resource management routes might inadvertently allow more access than intended due to differences between application read and resource edit permissions.
  4. Path Handling:

    • When checking paths with if (to.path.includes('resource-management')), this approach directly checks against partial strings (includes). It’s generally better to compare full URLs or specific path segments to ensure accuracy and prevent false positives.

Suggestions:

  • Ensure that get_next_route() returns an object containing necessary route information if the dependency is needed elsewhere in your application.
  • Evaluate whether conditional logic based on from params is actually required. If all resources fall under "application," perhaps simplifying the check would suffice: if (!to.path.startsWith('/resource-management')). This reduces complexity without changing permissions unnecessarily.
  • Double-check the definitions/assignments of PermissionConst constants to maintain consistency across your project.

To address some of these concerns, here's a revised version of one of the affected sections assuming proper dependencies and correct usage contexts:

const ApplicationDetailRouter = {
  [RouteType.Application]: [
    {
      method: RouteMethod.Get,
      controllerName: 'ApplicationController',
      methodName: 'GetApplicationById',
      authorizationRuleFn: (
        _authInfo: AuthResultInterface | null,
        context: ControllerContext<Request<any>, Response>
      ) => {
        const to: any = context.req.url // Assuming req.url provides enough info
        if (to && to.includes("resource-management")) {
          return PermissionConst.RESOURCE_APPLICATION_READ;
        }
        return PermissionConst.APPLICATION_READ; // Default permission for everything else
      }
    },
    // Repeat similar pattern for other methods/routes as applicable...
  ],
}

Make sure that this revision aligns correctly with your actual architecture and data flow, including how request objects are structured.

@zhanweizhang7 zhanweizhang7 merged commit 7f1299e into v2 Nov 10, 2025
3 of 6 checks passed
@zhanweizhang7 zhanweizhang7 deleted the pr@v2@fix_when_having_application branch November 10, 2025 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants