-
Notifications
You must be signed in to change notification settings - Fork 255
PII ISSUE FIXES [MOSIP-44379] #1029
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
base: develop
Are you sure you want to change the base?
Changes from 9 commits
0e6db31
2ddcb71
55d3b45
8011dd7
7391018
88a346e
37549af
7ddd9b3
b8466ce
e7fda69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| -- ================================================================================================ | ||
| -- MOSIP Pre-Registration PII Security: Canonical User Registry Table | ||
| -- Purpose: Centralized surrogate user ID mapping for cr_by/upd_by/cr_appuser_id | ||
| -- ================================================================================================ | ||
| -- This table eliminates plaintext PII replication across the tables | ||
| -- Stores: hash(authUserId) -> UUID surrogate mapping + encrypted original for notifications/audit | ||
| -- Usage: | ||
| -- 1. Resolve: hash(authUserId) -> user_id (fast lookup) | ||
| -- 2. Store: user_id in cr_by/upd_by/cr_appuser_id/contact_info fields(instead of plaintext) | ||
| -- 3. Recover: decrypt from user_details for notifications/audit | ||
|
|
||
| -- ========== CREATE TABLE: Canonical User Registry ========== | ||
|
|
||
| CREATE TABLE IF NOT EXISTS prereg.user_details ( | ||
| user_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | ||
| identifier_hash VARCHAR(128) NOT NULL UNIQUE, | ||
| identifier_encrypted TEXT | ||
| ); | ||
|
Comment on lines
+14
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check if there are any other DDL or migration scripts that might populate this table with null values
echo "=== Searching for user_details references in migration/ddl scripts ==="
find . -path "*/db_scripts/*" -name "*.sql" -exec grep -l "user_details" {} \;
echo -e "\n=== Checking entity definition for nullable annotations ==="
cat pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/common/entity/UserDetails.java 2>/dev/null | head -50Repository: mosip/pre-registration Length of output: 1266 🏁 Script executed: # Examine the actual DDL file to confirm NOT NULL constraints
echo "=== Full DDL for user_details table ==="
cat db_scripts/mosip_prereg/ddl/user_details.sqlRepository: mosip/pre-registration Length of output: 1764 🏁 Script executed: # Find and examine UserDetailsService to verify repair logic
echo "=== Searching for UserDetailsService ==="
find . -name "UserDetailsService.java" -type f
echo -e "\n=== Checking for repair/null-handling logic ==="
find . -name "UserDetailsService.java" -type f -exec cat {} \; 2>/dev/null | head -300Repository: mosip/pre-registration Length of output: 12086 🏁 Script executed: # Check the main DDL file for any additional constraints or migration info
echo "=== Checking main DDL file ==="
grep -A 20 -B 5 "user_details" db_scripts/mosip_prereg/ddl.sql 2>/dev/null || echo "Pattern not found or file structure differs"Repository: mosip/pre-registration Length of output: 336 DDL NOT NULL constraints conflict with repair logic and partial index design. The DDL declares This contradiction creates a runtime risk: if the repair logic encounters an existing row with null values, the UPDATE will fail due to the NOT NULL constraint. Resolve this by either:
If migrating legacy data, ensure migration scripts populate these fields before applying the NOT NULL constraints. 🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| -- ========== CREATE INDEXES ========== | ||
|
|
||
| -- Primary: UNIQUE constraint covers 99% of lookups | ||
| CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_prereg_user_details_hash | ||
| ON prereg.user_details(identifier_hash); | ||
|
|
||
| -- Composite for active user lookups + joins | ||
| CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_prereg_user_details_active | ||
| ON prereg.user_details(user_id) WHERE identifier_encrypted IS NOT NULL; | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| -- ================================================================================================ | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add cols like cr_dt etc