Skip to content
New issue

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

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

Already on GitHub? # to your account

RANGER-5061: checkstyle compliance updates - security-admin module #508

Merged
merged 15 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
d4d8e58
RANGER-5061: checkstyle compliance : security-admin module
pradeepagrawal8184 Dec 31, 2024
d149d1a
RANGER-5061: checkstyle compliance updates - security-admin module - …
kumaab Jan 2, 2025
5c6f87b
RANGER-5061: checkstyle compliance updates - security-admin module fo…
dineshkumar-yadav Jan 3, 2025
9c3ac97
RANGER-5061: security-admin module(elasticsearch package): update for…
vyommani Jan 3, 2025
04a69db
RANGER-5061: checkstyle compliance updates - security-admin elasticse…
mneethiraj Jan 3, 2025
29d7277
RANGER-5061: checkstyle compliance updates - security-admin module fo…
mneethiraj Jan 3, 2025
e920ec7
RANGER-5061: checkstyle compliance updates - security-admin module or…
dineshkumar-yadav Jan 6, 2025
19cf1ac
RANGER-5061: checkstyle compliance updates - security-admin module - …
rameeshm Jan 6, 2025
7fb9a39
RANGER-5061: checkstyle compliance updates - security-admin org.apach…
vyommani Jan 6, 2025
ddcde41
RANGER-5061: checkstyle compliance updates - security-admin org.apach…
mneethiraj Jan 7, 2025
b1ca7fb
RANGER-5061: checkstyle compliance updates - security-admin modules (…
pradeepagrawal8184 Jan 7, 2025
942b3ce
RANGER-5061: checkstyle compliance updates - security-admin org.apach…
pradeepagrawal8184 Jan 11, 2025
10cc6b5
RANGER-5061: checkstyle compliance updates - security-admin org.apach…
pradeepagrawal8184 Jan 11, 2025
376b2af
RANGER-5061: checkstyle compliance updates - security-admin modules :…
pradeepagrawal8184 Jan 12, 2025
610bd5e
RANGER-5061: checkstyle compliance updates - security-admin module's …
pradeepagrawal8184 Jan 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
63 changes: 63 additions & 0 deletions dev-support/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,69 @@
<suppress files="AuditFileCacheProviderSpool.java" checks="TypeName"/>
<suppress files="AuthzAuditEvent.java" checks="StaticVariableName"/>
<suppress files="buildks.java" checks="TypeName"/>
<suppress files="BaseDao.java" checks="StaticVariableName"/>
<suppress files="ContextUtil.java" checks="HideUtilityClassConstructor"/>
<suppress files="MapUtil.java" checks="HideUtilityClassConstructor"/>
<suppress files="PolicyRefUpdater.java" checks="TypeName"/>
<suppress files="RangerAdminTagEnricher.java" checks="StaticVariableName"/>
<suppress files="RangerCommonEnums.java" checks="HideUtilityClassConstructor"/>
<suppress files="RangerConstants.java" checks="TypeName"/>
<suppress files="RangerRolesUtil.java" checks="TypeName"/>
<suppress files="SearchField.java" checks="TypeName"/>
<suppress files="ServiceDBStore.java" checks="StaticVariableName"/>
<suppress files="ServiceDBStore.java" checks="TypeName"/>
<suppress files="SortField.java" checks="TypeName"/>
<suppress files="SPOOL_FILE_STATUS.java" checks="TypeName"/>
<suppress files="TagDBStore.java" checks="StaticVariableName"/>
<suppress files="TagDBStore.java" checks="TypeName"/>
<suppress files="TimedEventUtil.java" checks="HideUtilityClassConstructor"/>
<suppress files="PatchAssignSecurityZonePersmissionToAdmin_J10026.java" checks="TypeName"/>
<suppress files="PatchAtlasForClassificationResource_J10047" checks="TypeName"/>
<suppress files="PatchForAllServiceDefForPolicyConditionUpdate_J10060" checks="TypeName"/>
<suppress files="PatchForAllServiceDefUpdateForDefaultAuditFilters_J10049" checks="TypeName"/>
<suppress files="PatchForAllServiceDefUpdateForResourceSpecificAccesses_J10012" checks="TypeName"/>
<suppress files="PatchForAtlasAdminAudits_J10043" checks="TypeName"/>
<suppress files="PatchForAtlasResourceAndAccessTypeUpdate_J10016" checks="TypeName"/>
<suppress files="PatchForAtlasServiceDefUpdate_J10013" checks="TypeName"/>
<suppress files="PatchForAtlasToAddEntityLabelAndBusinessMetadata_J10034" checks="TypeName"/>
<suppress files="PatchForAtlasToAddTypeRead_J10040" checks="TypeName"/>
<suppress files="PatchForDefaultAuidtFilters_J10050" checks="TypeName"/>
<suppress files="PatchForExternalUserStatusUpdate_J10056" checks="TypeName"/>
<suppress files="PatchForHBaseDefaultPolicyUpdate_J10045" checks="TypeName"/>
<suppress files="PatchForHBaseServiceDefUpdate_J10035" checks="TypeName"/>
<suppress files="PatchForHiveServiceDefUpdate_J10006" checks="TypeName"/>
<suppress files="PatchForHiveServiceDefUpdate_J10007" checks="TypeName"/>
<suppress files="PatchForHiveServiceDefUpdate_J10009" checks="TypeName"/>
<suppress files="PatchForHiveServiceDefUpdate_J10010" checks="TypeName"/>
<suppress files="PatchForHiveServiceDefUpdate_J10017" checks="TypeName"/>
<suppress files="PatchForHiveServiceDefUpdate_J10027" checks="TypeName"/>
<suppress files="PatchForHiveServiceDefUpdate_J10030" checks="TypeName"/>
<suppress files="PatchForKafkaServiceDefUpdate_J10015" checks="TypeName"/>
<suppress files="PatchForKafkaServiceDefUpdate_J10025" checks="TypeName"/>
<suppress files="PatchForKafkaServiceDefUpdate_J10033" checks="TypeName"/>
<suppress files="PatchForMigratingOldRegimePolicyJson_J10046" checks="TypeName"/>
<suppress files="PatchForMigratingRangerServiceResource_J10037" checks="TypeName"/>
<suppress files="PatchForNifiResourceUpdateExclude_J10011" checks="TypeName"/>
<suppress files="PatchForOzoneDefaultPoliciesUpdate_J10044" checks="TypeName"/>
<suppress files="PatchForOzoneServiceDefConfigUpdate_J10051" checks="TypeName"/>
<suppress files="PatchForOzoneServiceDefUpdate_J10041" checks="TypeName"/>
<suppress files="PatchForPrestoToSupportPresto333_J10038" checks="TypeName"/>
<suppress files="PatchForServiceVersionInfo_J10004" checks="TypeName"/>
<suppress files="PatchForSolrSvcDefAndPoliciesUpdate_J10055" checks="TypeName"/>
<suppress files="PatchForSyncSourceUpdate_J10054" checks="TypeName"/>
<suppress files="PatchForTagServiceDefUpdate_J10008" checks="TypeName"/>
<suppress files="PatchForTagServiceDefUpdate_J10028" checks="TypeName"/>
<suppress files="PatchForTrinoSvcDefUpdate_J10062" checks="TypeName"/>
<suppress files="PatchForUpdatingAtlasSvcDefAndTagPolicies_J10063" checks="TypeName"/>
<suppress files="PatchForUpdatingPolicyJson_J10019" checks="TypeName"/>
<suppress files="PatchForUpdatingTagsJson_J10020" checks="TypeName"/>
<suppress files="PatchForXGlobalState_J10036" checks="TypeName"/>
<suppress files="PatchGrantAuditPermissionToKeyRoleUser_J10014" checks="TypeName"/>
<suppress files="PatchMigration_J10002" checks="TypeName"/>
<suppress files="PatchPasswordEncryption_J10001" checks="TypeName"/>
<suppress files="PatchPermissionModel_J10003" checks="TypeName"/>
<suppress files="PatchPreSql_057_ForUpdateToUniqueGUID_J10052" checks="TypeName"/>
<suppress files="PatchPreSql_058_ForUpdateToUniqueResoureceSignature_J10053" checks="TypeName"/>
<suppress files="PatchSetAccessTypeCategory_J10061" checks="TypeName"/>
<suppress files="PatchTagModulePermission_J10005" checks="TypeName"/>
</suppressions>
3 changes: 3 additions & 0 deletions security-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<name>Security Admin Web Application</name>
<description>security-admin-tool java web application</description>
<properties>
<checkstyle.failOnViolation>true</checkstyle.failOnViolation>
<checkstyle.skip>false</checkstyle.skip>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<skipJSTests>false</skipJSTests>
</properties>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -7,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,83 +30,60 @@
import org.apache.ranger.plugin.store.EmbeddedServiceDefsUtil;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;

public class AccessAuditsService {
protected List<SortField> sortFields = new ArrayList<SortField>();
protected List<SearchField> searchFields;
protected List<SortField> sortFields = new ArrayList<>();
protected List<SearchField> searchFields = new ArrayList<>();

@Autowired
protected
RESTErrorUtil restErrorUtil;
protected RESTErrorUtil restErrorUtil;

@Autowired
protected
RangerDaoManager daoManager;
protected RangerDaoManager daoManager;

public AccessAuditsService() {
searchFields = new ArrayList<SearchField>();
searchFields.add(new SearchField("id", "id",
SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("accessType", "access",
SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("aclEnforcer", "enforcer",
SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("agentId", "agent",
SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("repoName", "repo",
SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("sessionId", "sess",
SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("requestUser", "reqUser",
SearchField.DATA_TYPE.STR_LIST, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("excludeUser", "exlUser",
SearchField.DATA_TYPE.STR_LIST, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("requestData", "reqData", SearchField.DATA_TYPE.STRING,
SearchField.SEARCH_TYPE.PARTIAL));
searchFields.add(new SearchField("resourcePath", "resource", SearchField.DATA_TYPE.STRING,
SearchField.SEARCH_TYPE.PARTIAL));
searchFields.add(new SearchField("clientIP", "cliIP",
SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));

searchFields.add(new SearchField("auditType", "logType",
SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("accessResult", "result",
SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("id", "id", SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("accessType", "access", SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("aclEnforcer", "enforcer", SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("agentId", "agent", SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("repoName", "repo", SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("sessionId", "sess", SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("requestUser", "reqUser", SearchField.DATA_TYPE.STR_LIST, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("excludeUser", "exlUser", SearchField.DATA_TYPE.STR_LIST, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("requestData", "reqData", SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.PARTIAL));
searchFields.add(new SearchField("resourcePath", "resource", SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.PARTIAL));
searchFields.add(new SearchField("clientIP", "cliIP", SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));

searchFields.add(new SearchField("auditType", "logType", SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("accessResult", "result", SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
// searchFields.add(new SearchField("assetId", "obj.assetId",
// SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("policyId", "policy",
SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("repoType", "repoType",
SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("policyId", "policy", SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("repoType", "repoType", SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
/* Note; search fields starting with '-' denotes exclude conditions,
* it should be handled manually if audit destination does not support the same.
* solr support this way while cloudwatch does not.
*/
searchFields.add(new SearchField("-repoType", "-repoType",
SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("-requestUser", "-reqUser",
SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("resourceType", "resType",
SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("reason", "reason",
SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("action", "action",
SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));

searchFields.add(new SearchField("startDate", "evtTime",
SearchField.DATA_TYPE.DATE, SearchField.SEARCH_TYPE.GREATER_EQUAL_THAN));
searchFields.add(new SearchField("endDate", "evtTime", SearchField.DATA_TYPE.DATE,
SearchField.SEARCH_TYPE.LESS_EQUAL_THAN));
searchFields.add(new SearchField("-repoType", "-repoType", SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("-requestUser", "-reqUser", SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("resourceType", "resType", SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("reason", "reason", SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("action", "action", SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));

searchFields.add(new SearchField("startDate", "evtTime", SearchField.DATA_TYPE.DATE, SearchField.SEARCH_TYPE.GREATER_EQUAL_THAN));
searchFields.add(new SearchField("endDate", "evtTime", SearchField.DATA_TYPE.DATE, SearchField.SEARCH_TYPE.LESS_EQUAL_THAN));

searchFields.add(new SearchField("tags", "tags", SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.PARTIAL));
searchFields.add(new SearchField("cluster", "cluster",
SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("zoneName", "zoneName",
SearchField.DATA_TYPE.STR_LIST, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("agentHost", "agentHost",
SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.PARTIAL));

sortFields.add(new SortField("eventTime", "evtTime", true,
SortField.SORT_ORDER.DESC));
searchFields.add(new SearchField("cluster", "cluster", SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("zoneName", "zoneName", SearchField.DATA_TYPE.STR_LIST, SearchField.SEARCH_TYPE.FULL));
searchFields.add(new SearchField("agentHost", "agentHost", SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.PARTIAL));

sortFields.add(new SortField("eventTime", "evtTime", true, SortField.SORT_ORDER.DESC));
sortFields.add(new SortField("policyId", "policy", false, SORT_ORDER.ASC));
sortFields.add(new SortField("requestUser", "reqUser", false, SORT_ORDER.ASC));
sortFields.add(new SortField("resourceType", "resType", false, SORT_ORDER.ASC));
Expand All @@ -120,13 +97,16 @@ public AccessAuditsService() {
protected void updateUserExclusion(Map<String, Object> paramList) {
String val = (String) paramList.get("excludeServiceUser");

if (val != null && Boolean.valueOf(val.trim())) {
if (val != null && Boolean.parseBoolean(val.trim())) {
// add param to negate requestUsers which will be added as filter query
List<String> excludeUsersList = getExcludeUsersList();

if (CollectionUtils.isNotEmpty(excludeUsersList)) {
Object oldUserExclusions = paramList.get("-requestUser");
if (oldUserExclusions instanceof Collection && (!((Collection<?>)oldUserExclusions).isEmpty())) {
excludeUsersList.addAll((Collection<String>)oldUserExclusions);

if (oldUserExclusions instanceof Collection && (!((Collection<?>) oldUserExclusions).isEmpty())) {
excludeUsersList.addAll((Collection<String>) oldUserExclusions);

paramList.put("-requestUser", excludeUsersList);
} else {
paramList.put("-requestUser", excludeUsersList);
Expand All @@ -137,32 +117,38 @@ protected void updateUserExclusion(Map<String, Object> paramList) {

private List<String> getExcludeUsersList() {
//for excluding serviceUsers using existing property in ranger-admin-site
List<String> excludeUsersList = new ArrayList<String>(getServiceUserList());
List<String> excludeUsersList = new ArrayList<>(getServiceUserList());

//for excluding additional users using new property in ranger-admin-site
String additionalExcludeUsers = PropertiesUtil.getProperty("ranger.accesslogs.exclude.users.list");
List<String> additionalExcludeUsersList = null;
String additionalExcludeUsers = PropertiesUtil.getProperty("ranger.accesslogs.exclude.users.list");
List<String> additionalExcludeUsersList;

if (StringUtils.isNotBlank(additionalExcludeUsers)) {
additionalExcludeUsersList = new ArrayList<>(Arrays.asList(StringUtils.split(additionalExcludeUsers, ",")));

for (String serviceUser : additionalExcludeUsersList) {
if (StringUtils.isNotBlank(serviceUser) && !excludeUsersList.contains(serviceUser.trim())) {
excludeUsersList.add(serviceUser);
}
}
}

return excludeUsersList;
}

private List<String> getServiceUserList() {
String components = EmbeddedServiceDefsUtil.DEFAULT_BOOTSTRAP_SERVICEDEF_LIST;
List<String> serviceUsersList = new ArrayList<String>();
List<String> componentNames = Arrays.asList(StringUtils.split(components,","));
for(String componentName : componentNames) {
String serviceUser = PropertiesUtil.getProperty("ranger.plugins."+componentName+".serviceuser");
if(StringUtils.isNotBlank(serviceUser)) {
String components = EmbeddedServiceDefsUtil.DEFAULT_BOOTSTRAP_SERVICEDEF_LIST;
List<String> serviceUsersList = new ArrayList<>();
String[] componentNames = StringUtils.split(components, ",");

for (String componentName : componentNames) {
String serviceUser = PropertiesUtil.getProperty("ranger.plugins." + componentName + ".serviceuser");

if (StringUtils.isNotBlank(serviceUser)) {
serviceUsersList.add(serviceUser);
}
}

return serviceUsersList;
}
}
Loading