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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
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: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"aws-sdk": "^2.1248.0",
"bcryptjs": "^2.4.3",
"body-parser": "^1.20.3",
"bson": "^6.7.0",
"bson": "^4.7.2",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi avoir downgradé la version de bson ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'avais des erreurs avec la version upgrade je peux retest vu les modifs qu'il y a eu sur la PR depuis le temps

"bullmq": "^5.10.0",
"config": "^3.3.11",
"cookie-parser": "^1.4.6",
Expand Down
40 changes: 39 additions & 1 deletion api/src/anonymization/PlanDeTransport/ligneBus.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,43 @@
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",
"returnDate",
"youngCapacity",
"totalCapacity",
"followerCapacity",
"youngSeatsTaken",
"travelTime",
"lunchBreak",
"lunchBreakReturn",
"sessionId",
"centerId",
"centerArrivalTime",
"centerDepartureTime",
"classeId",
"meetingPointsIds",
"team",
"team.lastName",
"team.firstName",
"team.birthdate",
"team.mail",
"team.phone",
"delayedForth",
"delayedBack",
"mergedBusIds",
"createdAt",
"updatedAt",
"deletedAt",
"__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 +47,7 @@ function anonymize(item) {
t.phone && (t.phone = generateNewPhoneNumber());
return t;
}));

return item;
}

Expand Down
35 changes: 34 additions & 1 deletion api/src/anonymization/PlanDeTransport/modificationBus.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
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",
"opinion",
"opinionUserId",
"opinionUserName",
"opinionDate",
"messages",
"messages.message",
"messages.userId",
"messages.userName",
"messages.date",
"createdAt",
"updatedAt",
"deletedAt",
"__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 +43,7 @@ function anonymize(item) {
message.userName = starify(message.userName);
return message;
}));

return item;
}

Expand Down
42 changes: 41 additions & 1 deletion api/src/anonymization/application.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
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",
"updatedAt",
"__v",
];

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",
"updatedAt",
"__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",
"projectManagerValidationDate",
"structureManagerValidationDate",
"parent2ValidationDate",
"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",
"updatedAt",
"__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
36 changes: 35 additions & 1 deletion api/src/anonymization/departmentService.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
const { generateAddress, generateRandomName, generateRandomEmail, generateNewPhoneNumber } = require("../utils/anonymise");
const { anonymizeNonDeclaredFields } = require("../utils/anonymise-model-fields");

function anonymize(itemToAnonymize) {
const whitelist = [
"_id.$oid",
"contacts",
"contacts.cohort",
"contacts.cohortId",
"contacts.contactName",
"contacts.contactPhone",
"contacts.contactMail",
"department",
"region",
"directionName",
"serviceName",
"serviceNumber",
"address",
"complementAddress",
"zip",
"city",
"description",
"contactName",
"contactPhone",
"contactMail",
"representantEtat",
"representantEtat.firstName",
"representantEtat.lastName",
"representantEtat.mobile",
"representantEtat.email",
"representantEtat.role",
"createdAt",
"updatedAt",
"__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",
"departureAtString",
"realDepartureAtString",
"returnAt",
"returnAtString",
"realReturnAtString",
"createdAt",
"updatedAt",
"deletedAt",
"__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