Skip to content

Commit

Permalink
MOSIP-36036: Sonar bugs, security hotspots, duplications for UI code
Browse files Browse the repository at this point in the history
Signed-off-by: Anil_Kumar_Majji <[email protected]>
  • Loading branch information
Anil-kumar-Majji committed Jan 3, 2025
1 parent 5666b0e commit ce87c25
Show file tree
Hide file tree
Showing 44 changed files with 313 additions and 305 deletions.
4 changes: 2 additions & 2 deletions pmp-revamp-ui/src/nav/HeaderNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function HeaderNav({ open, setOpen }) {
<div className={`flex items-center ${isLoginLanguageRTL ? "pr-5" : "pl-6"}`}>
<img src={process.env.PUBLIC_URL + '/mosip_icon.svg'} alt="Mosip Icon" className="w-8 h-8" />
<div id='header_hamburger_open_sidenav' className="p-9 cursor-pointer">
<img id=' hamburger_icon' src={hamburgerIcon} className="min-w-5 w-5 h-5" alt="" onClick={() => setOpen(!open)} tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => setOpen(!open))} />
<img role='button' id=' hamburger_icon' src={hamburgerIcon} className="min-w-5 w-5 h-5" alt="" onClick={() => setOpen(!open)} tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => setOpen(!open))} />
</div>
</div>
)}
Expand All @@ -54,7 +54,7 @@ function HeaderNav({ open, setOpen }) {
<img src={side_menu_title} alt="" className="w-32 h-10" />
</div>
<div id='header_hamburger_close_sidenav' className="cursor-pointer" >
<img id=' hamburger_icon' src={hamburgerIcon} className="min-w-5" alt="" onClick={() => setOpen(!open)} tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => setOpen(!open))} />
<img role='button' id=' hamburger_icon' src={hamburgerIcon} className="min-w-5" alt="" onClick={() => setOpen(!open)} tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => setOpen(!open))} />
</div>
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ function AdminApiKeysList () {
const submenuRef = useRef([]);

const tableHeaders = [
{ id: 1, headerNameKey: 'oidcClientsList.partnerId' },
{ id: 2, headerNameKey: 'oidcClientsList.orgName' },
{ id: 3, headerNameKey: "oidcClientsList.policyGroup" },
{ id: 4, headerNameKey: "oidcClientsList.policyName" },
{ id: 5, headerNameKey: "apiKeysList.apiKeyName" },
{ id: 6, headerNameKey: "oidcClientsList.createdDate" },
{ id: 7, headerNameKey: "oidcClientsList.status" },
{ id: 8, headerNameKey: 'oidcClientsList.action' }
{ id: 1, keyName: 'partnerId', headerNameKey: 'oidcClientsList.partnerId' },
{ id: 2, keyName: 'orgName', headerNameKey: 'oidcClientsList.orgName' },
{ id: 3, keyName: 'policyGroupName', headerNameKey: "oidcClientsList.policyGroup" },
{ id: 4, keyName: 'policyName', headerNameKey: "oidcClientsList.policyName" },
{ id: 5, keyName: 'apiKeyLabel', headerNameKey: "apiKeysList.apiKeyName" },
{ id: 6, keyName: 'createdDateTime', headerNameKey: "oidcClientsList.createdDate" },
{ id: 7, keyName: 'status', headerNameKey: "oidcClientsList.status" },
{ id: 8, keyName: 'action', headerNameKey: 'oidcClientsList.action' }
];

useEffect(() => {
Expand All @@ -84,10 +84,7 @@ function AdminApiKeysList () {
queryParams.append('pageNo', effectivePageNo);
setResetPageNo(false);

const filterAttributesKeys = [
'partnerId', 'orgName', 'policyGroupName',
'policyName', 'apiKeyLabel', 'status'
];
const filterAttributesKeys = ['partnerId', 'orgName', 'policyGroupName', 'policyName', 'apiKeyLabel', 'status'];

filterAttributesKeys.forEach(key => {
if (filterAttributes[key]) {
Expand Down Expand Up @@ -263,9 +260,9 @@ function AdminApiKeysList () {
<th key={header.id} className="py-4 text-sm font-semibold text-[#6F6E6E] w-[15%]">
<div className={`mx-2 flex gap-x-0 items-center ${isLoginLanguageRTL ? "text-right" : "text-left"}`}>
{t(header.headerNameKey)}
{(header.id !== "action") && (
{(header.keyName !== "action") && (
<SortingIcon
headerId={header.id}
headerId={header.keyName}
sortDescOrder={sortDescOrder}
sortAscOrder={sortAscOrder}
order={order}
Expand Down Expand Up @@ -297,18 +294,18 @@ function AdminApiKeysList () {
</td>
<td className="text-center">
<div ref={(el) => (submenuRef.current[index] = el)}>
<p id={"api_key_list_action_view" + (index + 1)} onClick={() => setActionId(index === actionId ? null : index)} className={`font-semibold mb-0.5 text-[#191919] cursor-pointer text-center`}
<p role='button' id={"api_key_list_action_view" + (index + 1)} onClick={() => setActionId(index === actionId ? null : index)} className={`font-semibold mb-0.5 text-[#191919] cursor-pointer text-center`}
tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => setActionId(index === actionId ? null : index))}>
...
</p>
{actionId === index && (
<div className={`absolute w-[7%] z-50 bg-white text-xs font-semibold rounded-lg shadow-md border min-w-fit ${isLoginLanguageRTL ? "left-10 text-right" : "right-11 text-left"}`}>
<div className="flex justify-between hover:bg-gray-100" onClick={() => viewApiKeyRequestDetails(apiKey)} tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => viewApiKeyRequestDetails(apiKey))}>
<div role='button' className="flex justify-between hover:bg-gray-100" onClick={() => viewApiKeyRequestDetails(apiKey)} tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => viewApiKeyRequestDetails(apiKey))}>
<p id="api_key_list_view_btn" className={`py-1.5 px-4 cursor-pointer text-[#3E3E3E] ${isLoginLanguageRTL ? "pl-10" : "pr-10"}`}>{t("partnerList.view")}</p>
<img src={viewIcon} alt="" className={`${isLoginLanguageRTL ? "pl-2" : "pr-2"}`} />
</div>
<hr className="h-px bg-gray-100 border-0 mx-1" />
<div className={`flex justify-between hover:bg-gray-100 ${apiKey.status === 'activated' ? 'cursor-pointer' : 'cursor-default'}`} onClick={() => deactivateApiKey(apiKey)} tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => deactivateApiKey(apiKey))}>
<div role='button' className={`flex justify-between hover:bg-gray-100 ${apiKey.status === 'activated' ? 'cursor-pointer' : 'cursor-default'}`} onClick={() => deactivateApiKey(apiKey)} tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => deactivateApiKey(apiKey))}>
<p id="api_key_list_deactivate_btn" className={`py-1.5 px-4 ${isLoginLanguageRTL ? "pl-10" : "pr-10"} ${apiKey.status === 'activated' ? "text-[#3E3E3E]" : "text-[#A5A5A5]"}`}>{t("partnerList.deActivate")}</p>
<img src={apiKey.status === 'activated' ? deactivateIcon : disableDeactivateIcon} alt="" className={`${isLoginLanguageRTL ? "pl-2" : "pr-2"}`} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ function AdminOidcClientsList () {
}, [submenuRef]);

const tableHeaders = [
{ id: 1, headerNameKey: 'oidcClientsList.partnerId' },
{ id: 2, headerNameKey: 'oidcClientsList.orgName' },
{ id: 3, headerNameKey: "oidcClientsList.policyGroup" },
{ id: 4, headerNameKey: "oidcClientsList.policyName" },
{ id: 5, headerNameKey: "oidcClientsList.oidcClientName" },
{ id: 6, headerNameKey: "oidcClientsList.createdDate" },
{ id: 7, headerNameKey: "oidcClientsList.status" },
{ id: 8, headerNameKey: "oidcClientsList.oidcClientId" },
{ id: 9, headerNameKey: 'oidcClientsList.action' }
{ id: 1, keyName: 'partnerId', headerNameKey: 'oidcClientsList.partnerId' },
{ id: 2, keyName: 'orgName', headerNameKey: 'oidcClientsList.orgName' },
{ id: 3, keyName: 'policyGroupName', headerNameKey: "oidcClientsList.policyGroup" },
{ id: 4, keyName: 'policyName', headerNameKey: "oidcClientsList.policyName" },
{ id: 5, keyName: 'clientNameEng', headerNameKey: "oidcClientsList.oidcClientName" },
{ id: 6, keyName: 'createdDateTime', headerNameKey: "oidcClientsList.createdDate" },
{ id: 7, keyName: 'status', headerNameKey: "oidcClientsList.status" },
{ id: 8, keyName: 'clientId', headerNameKey: "oidcClientsList.oidcClientId" },
{ id: 9, keyName: 'action', headerNameKey: 'oidcClientsList.action' }
];

const fetchOidcClientsListData = async () => {
Expand Down Expand Up @@ -290,9 +290,9 @@ function AdminOidcClientsList () {
<th key={header.id} className="py-4 text-sm font-semibold text-[#6F6E6E] w-[15%]">
<div className={`mx-2 flex gap-x-0 items-center ${isLoginLanguageRTL ? "text-right" : "text-left"}`}>
{t(header.headerNameKey)}
{(header.id !== "action") && (header.id !== "clientId") && (header.id !== "clientNameEng") && (
{(header.keyName !== "action") && (header.keyName !== "clientId") && (header.keyName !== "clientNameEng") && (
<SortingIcon
headerId={header.id}
headerId={header.keyName}
sortDescOrder={sortDescOrder}
sortAscOrder={sortAscOrder}
order={order}
Expand Down Expand Up @@ -337,20 +337,20 @@ function AdminOidcClientsList () {
</td>
<td className="text-center">
<div ref={(el) => (submenuRef.current[index] = el)}>
<p id={"oidc_client_list_action_view" + (index + 1)} onClick={() => setActionId(index === actionId ? null : index)} className={`font-semibold mb-0.5 text-[#191919] cursor-pointer text-center`}
<p role='button' id={"oidc_client_list_action_view" + (index + 1)} onClick={() => setActionId(index === actionId ? null : index)} className={`font-semibold mb-0.5 text-[#191919] cursor-pointer text-center`}
tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => setActionId(index === actionId ? null : index))}>
...
</p>
{actionId === index && (
<div className={`absolute w-[7%] z-50 bg-white text-xs font-semibold rounded-lg shadow-md border min-w-fit ${isLoginLanguageRTL ? "left-10 text-right" : "right-11 text-left"}`}>
<div className="flex justify-between hover:bg-gray-100" onClick={() => viewOidcClientDetails(client)} tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => viewOidcClientDetails(client))}>
<div role='button' className="flex justify-between hover:bg-gray-100" onClick={() => viewOidcClientDetails(client)} tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => viewOidcClientDetails(client))}>
<p id="oidc_clients_list_view_btn" className={`py-1.5 px-4 cursor-pointer text-[#3E3E3E] ${isLoginLanguageRTL ? "pl-10" : "pr-10"}`}>{t("partnerList.view")}</p>
<img src={viewIcon} alt="" className={`${isLoginLanguageRTL ? "pl-2" : "pr-2"}`} />
</div>
<hr className="h-px bg-gray-100 border-0 mx-1" />
<div className={`flex justify-between hover:bg-gray-100 ${client.status === 'ACTIVE' ? 'cursor-pointer' : 'cursor-default'}`} onClick={() => deactivateOidcClient(client)} tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => deactivateOidcClient(client))}>
<div role='button' className={`flex justify-between hover:bg-gray-100 ${client.status === 'ACTIVE' ? 'cursor-pointer' : 'cursor-default'}`} onClick={() => deactivateOidcClient(client)} tabIndex="0" onKeyDown={(e) => onPressEnterKey(e, () => deactivateOidcClient(client))}>
<p id="oidc_clients_list_deactivate_btn" className={`py-1.5 px-4 ${isLoginLanguageRTL ? "pl-10" : "pr-10"} ${client.status === 'ACTIVE' ? "text-[#3E3E3E]" : "text-[#A5A5A5]"}`}>{t("partnerList.deActivate")}</p>
<img src={client.status === 'ACTIVE' ?deactivateIcon : disableDeactivateIcon} alt="" className={`${isLoginLanguageRTL ? "pl-2" : "pr-2"}`} />
<img src={client.status === 'ACTIVE' ? deactivateIcon : disableDeactivateIcon} alt="" className={`${isLoginLanguageRTL ? "pl-2" : "pr-2"}`} />
</div>
{showDeactivatePopup && (
<DeactivatePopup closePopUp={closeDeactivatePopup} onClickConfirm={(deactivationResponse) => onClickConfirmDeactivate(deactivationResponse, client)} popupData={client} request={deactivateRequest} headerMsg='deactivateOidc.header' descriptionMsg='deactivateOidc.description' headerKeyName={client.clientNameEng} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ function ViewAdminOidcClientDetails() {
</div>
</div>

<div id="oidc_client_details_copy_id" className={`${oidcClientDetails.status === "ACTIVE" ? 'bg-[#F0F5FF] border-[#BED3FF] cursor-pointer hover:shadow-md' : 'bg-gray-200 border-gray-400'} border h-[4%] w-[15%] max-[450px]:w-[40%] max-[800px]:w-[25%] ${isLoginLanguageRTL ? "pr-[3%] pl-[1.5%]" : "pl-[3%] pr-[1%]"} py-[0.5%] rounded-md text-right`}
<div role='button' id="oidc_client_details_copy_id" className={`${oidcClientDetails.status === "ACTIVE" ? 'bg-[#F0F5FF] border-[#BED3FF] cursor-pointer hover:shadow-md' : 'bg-gray-200 border-gray-400'} border h-[4%] w-[15%] max-[450px]:w-[40%] max-[800px]:w-[25%] ${isLoginLanguageRTL ? "pr-[3%] pl-[1.5%]" : "pl-[3%] pr-[1%]"} py-[0.5%] rounded-md text-right`}
tabIndex={oidcClientDetails.status === "ACTIVE" && "0"} onKeyDown={(e) => onPressEnterKey(e, () => copyClientId(selectedClientData, selectedClientData.clientId, setCopied))}>
<p className="text-sm font-semibold text-[#333333]">{t('viewOidcClientDetails.oidcClientId')}</p>
<div className="flex space-x-1 items-center">
<p className={`text-md font-bold ${selectedClientData.status === "ACTIVE" ? 'text-[#1447B2]' : 'text-gray-400'} truncate`}>
{selectedClientData.clientId}
</p>
{selectedClientData.status === "ACTIVE" ? (
<img id="oidc_client_details_copy_id_icon" src={content_copy_icon} alt="" onClick={() => copyClientId(selectedClientData, selectedClientData.clientId, setCopied)} />
<img id="oidc_client_details_copy_id_icon" src={content_copy_icon} alt="" onClick={() => copyClientId(selectedClientData, selectedClientData.clientId, setCopied)} role='button'/>
) : (
<img src={disabled_copy_icon} alt="" />
)}
Expand Down
Loading

0 comments on commit ce87c25

Please sign in to comment.