From 0fdc598111eb5b3871c216e6825c5c713dea6605 Mon Sep 17 00:00:00 2001 From: Brijesh Bhalala Date: Fri, 23 Feb 2024 19:34:04 +0530 Subject: [PATCH] RANGER-4700: Audit logs for Masking policy is missing data mask type entry --- .../views/AuditEvent/AdminLogs/PolicyLogs.jsx | 124 +++++++++++++----- 1 file changed, 88 insertions(+), 36 deletions(-) diff --git a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminLogs/PolicyLogs.jsx b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminLogs/PolicyLogs.jsx index 2ea9816ef2..36dffc0cc2 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminLogs/PolicyLogs.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminLogs/PolicyLogs.jsx @@ -175,6 +175,26 @@ export const PolicyLogs = ({ data, reportdata }) => { ); const createMaskPolicyNew = createMaskPolicy.map((newval) => newval.newValue); + const getDataMaskType = (dataMaskLabel, dataMaskInfo) => { + let maskType = dataMaskInfo?.dataMaskType; + + if (!isEmpty(dataMaskLabel)) { + if (dataMaskLabel == "Custom") { + maskType = dataMaskLabel + " : " + dataMaskInfo?.valueExpr; + } else { + maskType = dataMaskLabel; + } + } else { + if (dataMaskInfo.dataMaskType == "CUSTOM") { + maskType = dataMaskInfo.dataMaskType + " : " + dataMaskInfo?.valueExpr; + } else { + maskType = dataMaskInfo.dataMaskType; + } + } + + return maskType; + }; + /* CREATE END */ /* UPDATE LOGS VARIABLES */ @@ -1055,12 +1075,12 @@ export const PolicyLogs = ({ data, reportdata }) => { return (
- {DataMasklabel} + {getDataMaskType(DataMasklabel, dataMaskInfo)}
); } else { - return DataMasklabel; + return getDataMaskType(DataMasklabel, dataMaskInfo); } } if (dataMaskInfo) { @@ -1080,7 +1100,7 @@ export const PolicyLogs = ({ data, reportdata }) => { ); } else { - return dataMaskInfo.dataMaskType; + return getDataMaskType(DataMasklabel, dataMaskInfo); } } }; @@ -1208,6 +1228,13 @@ export const PolicyLogs = ({ data, reportdata }) => { )} + {newPolicyItemsDiff.length - 1 != index && ( + + +
+ + + )} ) ) @@ -1389,12 +1416,12 @@ export const PolicyLogs = ({ data, reportdata }) => { return (
- {DataMasklabel} + {getDataMaskType(DataMasklabel, dataMaskInfo)}
); } else { - return DataMasklabel; + return getDataMaskType(DataMasklabel, dataMaskInfo); } } if (dataMaskInfo) { @@ -1409,12 +1436,12 @@ export const PolicyLogs = ({ data, reportdata }) => { return (
- {dataMaskInfo.dataMaskType} + {getDataMaskType(DataMasklabel, dataMaskInfo)}
); } else { - return dataMaskInfo.dataMaskType; + return getDataMaskType(DataMasklabel, dataMaskInfo); } } }; @@ -1525,7 +1552,6 @@ export const PolicyLogs = ({ data, reportdata }) => { )} - {policy.attributeName == "Masked Policy Items" && ( @@ -1544,6 +1570,13 @@ export const PolicyLogs = ({ data, reportdata }) => { )} + {oldPolicyItemsDiff.length - 1 != index && ( + + +
+ + + )} ) ) @@ -1945,7 +1978,8 @@ export const PolicyLogs = ({ data, reportdata }) => { {action == "create" && !isEmpty(createConditionNew) && !isUndefined(createConditionNew) && - createConditionNew != 0 && ( + createConditionNew != 0 && + createConditionNew != "[]" && ( <>
Policy Conditions: @@ -2442,7 +2476,7 @@ export const PolicyLogs = ({ data, reportdata }) => { {createMaskPolicyNew.map((policyitem) => { return ( !isEmpty(policyitem) && - JSON.parse(policyitem).map((policy) => ( + JSON.parse(policyitem).map((policy, index) => ( @@ -2498,16 +2532,21 @@ export const PolicyLogs = ({ data, reportdata }) => { )} - {!isEmpty(policy.DataMasklabel) && ( + {!isEmpty(policy.dataMaskInfo) && ( - {`Data Mask Types`} - {!isEmpty(policy.DataMasklabel) - ? `: ${policy.DataMasklabel} ` - : ""} + {`Data Mask Types: `} + {getDataMaskType( + policy.DataMasklabel, + policy.dataMaskInfo + )} )} -
+ {JSON.parse(policyitem).length - 1 != index && ( + +
+ + )} )) ); @@ -2673,7 +2712,7 @@ export const PolicyLogs = ({ data, reportdata }) => { updateMaskPolicy != 0 && ( <>
- Mask Policy Items: + Masking Policy Items:
@@ -3092,7 +3131,7 @@ export const PolicyLogs = ({ data, reportdata }) => { {deletemaskPolicyOld.map((policyitem) => { return ( !isEmpty(policyitem) && - JSON.parse(policyitem).map((policy) => ( + JSON.parse(policyitem).map((policy, index) => ( @@ -3148,15 +3187,21 @@ export const PolicyLogs = ({ data, reportdata }) => { )} - {policy.DataMasklabel && - policy.DataMasklabel.length > 0 && ( - - {`Data Mask Types`} - {`: ${policy.DataMasklabel} `} - - )} + {!isEmpty(policy.dataMaskInfo) && ( + + {`Data Mask Types: `} + {getDataMaskType( + policy.DataMasklabel, + policy.dataMaskInfo + )} + + )} -
+ {JSON.parse(policyitem).length - 1 != index && ( + +
+ + )} )) ); @@ -3708,7 +3753,7 @@ export const PolicyLogs = ({ data, reportdata }) => { {importdelmaskpolicyold.map((policyitem) => { return ( !isEmpty(policyitem) && - JSON.parse(policyitem).map((policy) => ( + JSON.parse(policyitem).map((policy, index) => ( @@ -3764,15 +3809,21 @@ export const PolicyLogs = ({ data, reportdata }) => { )} - {policy.DataMasklabel && - policy.DataMasklabel.length > 0 && ( - - {`Data Mask Types`} - {`: ${policy.DataMasklabel} `} - - )} + {!isEmpty(policy.dataMaskInfo) && ( + + {`Data Mask Types: `} + {getDataMaskType( + policy.DataMasklabel, + policy.dataMaskInfo + )} + + )} -
+ {JSON.parse(policyitem).length - 1 != index && ( + +
+ + )} )) ); @@ -3785,7 +3836,8 @@ export const PolicyLogs = ({ data, reportdata }) => { {action == "Import Delete" && !isEmpty(importPolicyConditionOld) && !isUndefined(importPolicyConditionOld) && - importPolicyConditionOld != 0 && ( + importPolicyConditionOld != 0 && + importPolicyConditionOld != "[]" && ( <>
Policy Conditions: