You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The requirement from the customer is as below -
a) To clean up and standardize the outputs for queries to pull members for an app and/or a project with and without admin credentials.
b) Create the below new APIs for Engines / Apps to display the list of users who has access to view (filtering the access permission levels)
/getUsersForEngine
/getUsersForEngineNoCredentials
/getUsersForApp
/getUsersForAppNoCredentials
c) Created the APIs to do the CRUD operations to add / modify / remove users from App (Project) and Engine catalogs.
Changes Made
Changes made in the below classes :
EngineAuthorizationResource
ProjectAuthorizationResource
AdminProjectAuthorizationResource
AdminEngineAuthorizationResource
How to Test
The above APIs can be tested in the POSTMAN directly.
The requirement from the customer is as below -
a) To clean up and standardize the outputs for queries to pull members for an app and/or a project with and without admin credentials.
b) Create the below new APIs for Engines / Apps to display the list of users who has access to view (filtering the access permission levels)
/getUsersForEngine
/getUsersForEngineNoCredentials
/getUsersForApp
/getUsersForAppNoCredentials
c) Created the APIs to do the CRUD operations to add / modify / remove users from App (Project) and Engine catalogs.
Changes Made
Changes made in the below classes :
EngineAuthorizationResource
ProjectAuthorizationResource
AdminProjectAuthorizationResource
AdminEngineAuthorizationResource
How to Test
The above APIs can be tested in the POSTMAN directly.
Notes
PR Type
Enhancement
Description
Add admin engine user list/add/remove/update APIs
Add admin project user list/add/remove/update APIs
Introduce public endpoints for engine and app listing
Standardize permission utils calls and input sanitization
Diagram Walkthrough
flowchart LR
AEAdmin["AdminEngineAuthorizationResource"]
APAdmin["AdminProjectAuthorizationResource"]
EAuth["EngineAuthorizationResource"]
PAuth["ProjectAuthorizationResource"]
SecAdmin["SecurityAdminUtils"]
SecEngine["SecurityEngineUtils"]
SecProject["SecurityProjectUtils"]
AEAdmin -- "admin user management" --> SecAdmin
APAdmin -- "admin user management" --> SecAdmin
EAuth -- "public user listing & add" --> SecEngine
PAuth -- "public user listing & add" --> SecProject
Here are some key observations to aid the review process:
⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 No relevant tests
🔒 Security concerns
Possible SQL injection: several query parameters (e.g., searchTerm, appId, permission) are sanitized with inputSanitizer instead of inputSQLSanitizer. Validate or escape inputs consistently before using them in SQL queries.
Different sanitizers are used for parameters (inputSanitizer vs inputSQLSanitizer), which may lead to SQL injection risk. Ensure all parameters used in database queries are consistently sanitized using inputSQLSanitizer.
Logging in catch blocks calls User.getSingleLogginName(user) but user may be null when ResourceUtility.getUser throws, causing a potential NPE. Add null checks or guard against null user in logs.
try {
user = ResourceUtility.getUser(request);
} catch (IllegalAccessExceptione) {
classLogger.warn(ResourceUtility.getLogMessage(request, request.getSession(false), User.getSingleLogginName(user), "invalid user session trying to access authorization resources"));
classLogger.error(Constants.STACKTRACE, e);
Map<String, String> errorMap = newHashMap<String, String>();
Many API endpoints across AdminEngineAuthorizationResource and AdminProjectAuthorizationResource share nearly identical logic. Consider refactoring common patterns into shared utilities or a base class to reduce maintenance overhead.
All parameters used in DB queries should be SQL-sanitized to prevent injection. Replace inputSanitizer with inputSQLSanitizer for engineId and searchTerm.
@Path("getUsersForEngine")
public Response getUsersForEngine(...,
@QueryParam("limit") long limit, @QueryParam("offset") long offset) {
+ if (limit < 0 || offset < 0) {+ Map<String,String> err = new HashMap<>();+ err.put(Constants.ERROR_MESSAGE, "limit and offset must be non-negative");+ return WebUtility.getResponse(err, 400);+ }
...
Suggestion importance[1-10]: 6
__
Why: Adding checks for negative limit and offset ensures invalid pagination parameters are rejected early, improving robustness.
Low
General
Use generic JSON parsing
Use a TypeToken to parse JSON into the correct generic type and avoid unchecked conversions.
List<Map<String, Object>> permission =
- new Gson().fromJson(form.getFirst("userpermissions"), List.class);+ new Gson().fromJson(+ form.getFirst("userpermissions"),+ new TypeToken<List<Map<String,Object>>>(){}.getType()+ );
Suggestion importance[1-10]: 5
__
Why: Parsing JSON with a TypeToken avoids unchecked conversions and makes the code safer and clearer.
Low
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The requirement from the customer is as below -
a) To clean up and standardize the outputs for queries to pull members for an app and/or a project with and without admin credentials.
b) Create the below new APIs for Engines / Apps to display the list of users who has access to view (filtering the access permission levels)
/getUsersForEngine
/getUsersForEngineNoCredentials
/getUsersForApp
/getUsersForAppNoCredentials
c) Created the APIs to do the CRUD operations to add / modify / remove users from App (Project) and Engine catalogs.
Changes Made
Changes made in the below classes :
EngineAuthorizationResource
ProjectAuthorizationResource
AdminProjectAuthorizationResource
AdminEngineAuthorizationResource
How to Test
The above APIs can be tested in the POSTMAN directly.
Notes