Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

MOSIP-38181: Added length validation for policy data #1059

Merged
merged 2 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pmp-revamp-ui/public/i18n/ara.json
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@
"upload": "تحميل",
"uploadFileError": "يرجى اختيار ملف JSON صالح",
"jsonParseError": "يرجى تقديم بيانات JSON صالحة",
"policyDatalengthExceedError": "لا ينبغي أن تتجاوز بيانات السياسة أكثر من 5120 حرفًا.",
"uploadPolicyDataFile": "تحميل بيانات السياسة",
"uploadPolicyDataFileDesc": "يُسمح بتحميل ملفات بتنسيق .json فقط",
"fileUploadSuccessMsg": "تم تحميل بيانات السياسة بنجاح",
Expand Down Expand Up @@ -1084,6 +1085,7 @@
"PMS_POL_069": "تم ربط سياسات نشطة أو مسودة بمجموعة السياسات.",
"PMS_POL_070": "توجد سياسات مسودة ضمن مجموعة السياسات.",
"PMS_POL_071": "خطأ أثناء إلغاء تفعيل مجموعة السياسات.",
"PMS_POL_072": "السياسة المحددة ليست في حالة التنشيط",
"KER-PCM-006": "لم يتم العثور على شهادات CA الجذر/CA المتوسطة.",
"KER-PCM-008": "اسم المنظمة الشريكة غير متطابق",
"KER-PCM-015": "الشهادة الموقعة ذاتيًا غير مسموح بها كشريك.",
Expand Down
2 changes: 2 additions & 0 deletions pmp-revamp-ui/public/i18n/eng.json
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,7 @@
"upload": "Upload",
"uploadFileError": "Please select a valid JSON file",
"jsonParseError": "Please provide valid JSON data",
"policyDatalengthExceedError": "Policy data should not exceed more than 5120 characters.",
"uploadPolicyDataFile": "Upload Policy Data",
"uploadPolicyDataFileDesc": "Only .json file format is allowed for upload",
"fileUploadSuccessMsg": "Policy data has been uploaded successfully",
Expand Down Expand Up @@ -1080,6 +1081,7 @@
"PMS_POL_069": "Active or draft policies are associated with the policy group",
"PMS_POL_070": "Draft policies exist under the policy group.",
"PMS_POL_071": "Error while deactivating policy group",
"PMS_POL_072": "The selected policy is not in activated status",
"KER-PCM-006": "Root CA/Intermediate CA Certificates not found.",
"KER-PCM-015": "Self Signed Certificate not allowed as partner.",
"KER-PCM-003": "The certificate already exists. Please upload another certificate",
Expand Down
2 changes: 2 additions & 0 deletions pmp-revamp-ui/public/i18n/fra.json
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@
"upload": "Télécharger",
"uploadFileError": "Veuillez sélectionner un fichier JSON valide",
"jsonParseError": "Veuillez fournir des données JSON valides",
"policyDatalengthExceedError": "Les données de politique ne doivent pas dépasser 5120 caractères.",
"uploadPolicyDataFile": "Télécharger les données de la politique",
"uploadPolicyDataFileDesc": "Seul le format de fichier .json est autorisé pour le téléchargement",
"fileUploadSuccessMsg": "Les données de la politique ont été téléchargées avec succès",
Expand Down Expand Up @@ -1085,6 +1086,7 @@
"PMS_POL_069": "Des politiques actives ou en brouillon sont associées au groupe de politiques.",
"PMS_POL_070": "Des politiques en brouillon existent dans le groupe de politiques.",
"PMS_POL_071": "Erreur lors de la désactivation du groupe de politiques.",
"PMS_POL_072": "La politique sélectionnée n'est pas en statut activé",
"KER-PCM-006": "Certificats d'autorité de certification racine/autorité de certification intermédiaire introuvables.",
"KER-PCM-015": "Certificat auto-signé non autorisé en tant que partenaire.",
"KER-PCM-003": "Le certificat existe déjà. Veuillez télécharger un autre certificat.",
Expand Down
6 changes: 6 additions & 0 deletions pmp-revamp-ui/src/pages/admin/policyManager/CreatePolicy.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ function CreatePolicy() {
let parsedPolicyData;
try {
parsedPolicyData = JSON.parse(policyData);
if (JSON.stringify(parsedPolicyData).length > 5120) {
setErrorMsg(t('createPolicy.policyDatalengthExceedError'));
setIsSubmitClicked(false);
setDataLoaded(true);
return;
};
if (Array.isArray(parsedPolicyData) || parsedPolicyData === null) {
throw new Error("Parsed data is not a valid JSON object");
}
Expand Down
Loading