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

feat(api): anonymise newfields not specified by default #4351

Merged
merged 17 commits into from
Nov 13, 2024
Merged
39 changes: 38 additions & 1 deletion api/src/anonymization/PlanDeTransport/ligneBus.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
const { generateRandomName, generateBirthdate, generateRandomEmail, generateNewPhoneNumber } = require("../../utils/anonymise");
const { anonymizeNonDeclaredFields } = require("../../utils/anonymise-model-fields");

function anonymize(itemToAnonymize) {
const whitelist = [
"_id.$oid",
"cohort",
"cohortId",
"busId",
"departuredDate.$date",
"returnDate.$date",
"youngCapacity",
"totalCapacity",
"followerCapacity",
"youngSeatsTaken",
"travelTime",
"lunchBreak",
"lunchBreakReturn",
"sessionId",
"centerId",
"centerArrivalTime",
"centerDepartureTime",
"classeId",
"meetingPointsIds",
"team.lastName",
"team.firstName",
"team.birthdate",
"team.mail",
"team.phone",
"delayedForth",
"delayedBack",
"mergedBusIds",
"createdAt.$date",
"updatedAt.$date",
"deletedAt.$date",
"__v",
];
const item = anonymizeNonDeclaredFields(itemToAnonymize, whitelist);

function anonymize(item) {
item.team &&
(item.team = item.team.map((t) => {
t.lastName && (t.lastName = generateRandomName());
Expand All @@ -10,6 +46,7 @@ function anonymize(item) {
t.phone && (t.phone = generateNewPhoneNumber());
return t;
}));

return item;
}

Expand Down
34 changes: 33 additions & 1 deletion api/src/anonymization/PlanDeTransport/modificationBus.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
const { starify } = require("../../utils/anonymise");
const { anonymizeNonDeclaredFields } = require("../../utils/anonymise-model-fields");

function anonymize(itemToAnonymize) {
const whitelist = [
"_id.$oid",
"cohort",
"cohortId",
"lineId",
"lineName",
"requestMessage",
"requestUserId",
"requestUserName",
"requestUserRole",
"tagIds",
"status",
"statusUserId",
"statusUserName",
"statusDate.$date",
"opinion",
"opinionUserId",
"opinionUserName",
"opinionDate.$date",
"messages.message",
"messages.userId",
"messages.userName",
"messages.date.$date",
"createdAt.$date",
"updatedAt.$date",
"deletedAt.$date",
"__v",
];
const item = anonymizeNonDeclaredFields(itemToAnonymize, whitelist);

function anonymize(item) {
item.requestMessage && (item.requestMessage = starify(item.requestMessage));
item.requestUserName && (item.requestUserName = starify(item.requestUserName));
item.statusUserName && (item.statusUserName = starify(item.statusUserName));
Expand All @@ -11,6 +42,7 @@ function anonymize(item) {
message.userName = starify(message.userName);
return message;
}));

return item;
}

Expand Down
41 changes: 40 additions & 1 deletion api/src/anonymization/application.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,45 @@
const { starify } = require("../utils/anonymise");
const { anonymizeNonDeclaredFields } = require("../utils/anonymise-model-fields");

function anonymize(itemToAnonymize) {
const whitelist = [
"_id.$oid",
"apiEngagementId",
"youngId",
"youngFirstName",
"youngLastName",
"youngEmail",
"youngBirthdateAt",
"youngCity",
"youngDepartment",
"youngCohort",
"cohortId",
"missionId",
"isJvaMission",
"missionName",
"missionDepartment",
"missionRegion",
"missionDuration",
"structureId",
"tutorId",
"contractId",
"contractStatus",
"tutorName",
"priority",
"hidden",
"status",
"statusComment",
"contractAvenantFiles",
"justificatifsFiles",
"feedBackExperienceFiles",
"othersFiles",
"filesType",
"createdAt.$date",
"updatedAt.$date",
];

const item = anonymizeNonDeclaredFields(itemToAnonymize, whitelist);

function anonymize(item) {
item.youngEmail && (item.youngEmail = "*****@*******.***");
item.youngFirstName && (item.youngFirstName = starify(item.youngFirstName));
item.youngLastName && (item.youngLastName = starify(item.youngLastName));
Expand Down
40 changes: 39 additions & 1 deletion api/src/anonymization/cohesionCenter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,44 @@
function anonymize(item) {
const { anonymizeNonDeclaredFields } = require("../utils/anonymise-model-fields");

function anonymize(itemToAnonymize) {
const whitelist = [
"_id.$oid",
"name",
"code2022",
"address",
"city",
"zip",
"department",
"region",
"addressVerified",
"placesTotal",
"pmr",
"cohorts",
"cohortIds",
"academy",
"typology",
"domain",
"complement",
"centerDesignation",
"placesLeft",
"outfitDelivered",
"observations",
"waitingList",
"COR",
"code",
"country",
"departmentCode",
"sessionStatus",
"createdAt.$date",
"updatedAt.$date",
"__v",
];

const item = anonymizeNonDeclaredFields(itemToAnonymize, whitelist);

item.code2022 && (item.code2022 = "02022");
item.code && (item.code = "00000");

return item;
}

Expand Down
80 changes: 79 additions & 1 deletion api/src/anonymization/contract.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,84 @@
const { generateBirthdate, generateNewPhoneNumber, starify, STAR_EMAIL } = require("../utils/anonymise");
const { anonymizeNonDeclaredFields } = require("../utils/anonymise-model-fields");

function anonymize(itemToAnonymize) {
const whitelist = [
"_id.$oid",
"youngId",
"structureId",
"applicationId",
"missionId",
"tutorId",
"isYoungAdult",
"parent1Token",
"projectManagerToken",
"structureManagerToken",
"parent2Token",
"youngContractToken",
"parent1Status",
"projectManagerStatus",
"structureManagerStatus",
"parent2Status",
"youngContractStatus",
"parent1ValidationDate.$date",
"projectManagerValidationDate.$date",
"structureManagerValidationDate.$date",
"parent2ValidationDate.$date",
"youngContractValidationDate",
"invitationSent",
"youngFirstName",
"youngLastName",
"youngBirthdate",
"youngAddress",
"youngCity",
"youngDepartment",
"youngEmail",
"youngPhone",
"parent1FirstName",
"parent1LastName",
"parent1Address",
"parent1City",
"parent1Department",
"parent1Phone",
"parent1Email",
"parent2FirstName",
"parent2LastName",
"parent2Address",
"parent2City",
"parent2Department",
"parent2Phone",
"parent2Email",
"missionName",
"missionObjective",
"missionAction",
"missionStartAt",
"missionEndAt",
"missionAddress",
"missionCity",
"missionZip",
"missionDuration",
"missionFrequence",
"date",
"projectManagerFirstName",
"projectManagerLastName",
"projectManagerRole",
"projectManagerEmail",
"structureManagerFirstName",
"structureManagerLastName",
"structureManagerRole",
"structureManagerEmail",
"tutorFirstName",
"tutorLastName",
"tutorRole",
"tutorEmail",
"structureSiret",
"structureName",
"createdAt.$date",
"updatedAt.$date",
"__v",
];
const item = anonymizeNonDeclaredFields(itemToAnonymize, whitelist);

function anonymize(item) {
item.tutorFirstName && (item.tutorFirstName = starify(item.tutorFirstName));
item.tutorLastName && (item.tutorLastName = starify(item.tutorLastName));
item.tutorEmail && (item.tutorEmail = STAR_EMAIL);
Expand Down
34 changes: 33 additions & 1 deletion api/src/anonymization/departmentService.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
const { generateAddress, generateRandomName, generateRandomEmail, generateNewPhoneNumber } = require("../utils/anonymise");
const { anonymizeNonDeclaredFields } = require("../utils/anonymise-model-fields");

function anonymize(itemToAnonymize) {
const whitelist = [
"_id.$oid",
"contacts.cohort",
"contacts.cohortId",
"contacts.contactName",
"contacts.contactPhone",
"contacts.contactMail",
"department",
"region",
"directionName",
"serviceName",
"serviceNumber",
"address",
"complementAddress",
"zip",
"city",
"description",
"contactName",
"contactPhone",
"contactMail",
"representantEtat.firstName",
"representantEtat.lastName",
"representantEtat.mobile",
"representantEtat.email",
"representantEtat.role",
"createdAt.$date",
"updatedAt.$date",
"__v",
];
const item = anonymizeNonDeclaredFields(itemToAnonymize, whitelist);

function anonymize(item) {
item.email && (item.email = generateRandomEmail());
item.contactPhone && (item.contactPhone = generateNewPhoneNumber());
item.address && (item.address = generateAddress());
Expand Down
32 changes: 31 additions & 1 deletion api/src/anonymization/meetingPoint.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,38 @@
const { generateAddress, starify } = require("../utils/anonymise");
const { anonymizeNonDeclaredFields } = require("../utils/anonymise-model-fields");

function anonymize(itemToAnonymize) {
const whitelist = [
"_id.$oid",
"isValid",
"cohort",
"cohortId",
"busId",
"busExcelId",
"centerId",
"centerCode",
"departureAddress",
"departureZip",
"departureCity",
"departureDepartment",
"departureRegion",
"hideDepartmentInConvocation",
"departureAt.$date",
"departureAtString",
"realDepartureAtString",
"returnAt.$date",
"returnAtString",
"realReturnAtString",
"createdAt.$date",
"updatedAt.$date",
"deletedAt.$date",
"__v",
];
const item = anonymizeNonDeclaredFields(itemToAnonymize, whitelist);

function anonymize(item) {
item.departureAddress && (item.departureAddress = generateAddress());
item.centerCode && (item.centerCode = starify(item.centerCode));

return item;
}

Expand Down
Loading
Loading