Add user profile and data processing functionality with logging#32
Add user profile and data processing functionality with logging#32
Conversation
| logging.info(f"Starting update for Customer ID: {customer_id}") | ||
|
|
||
| logging.info(f"Updating details - Name: {full_name}, Email: {email_address}") | ||
| logging.info(f"Contact Phone: {phone_number}") |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 months ago
To fix the problem, we should ensure that sensitive data such as phone numbers are not logged in clear text. The best approach is to redact, omit, or replace the sensitive value in the relevant log entry. In this example, the log line on line 13 that logs phone_number should be modified. Possible approaches are:
- Omit the phone number entirely from the log message.
- Replace the value with a constant string such as
REDACTEDor mask it (e.g. only show last 2/3 digits).
The best fix with minimal functional impact is to redact the phone number value in the logging statement. No changes to imports or other parts of the code are necessary.
| @@ -10,7 +10,7 @@ | ||
| logging.info(f"Starting update for Customer ID: {customer_id}") | ||
|
|
||
| logging.info(f"Updating details - Name: {full_name}, Email: {email_address}") | ||
| logging.info(f"Contact Phone: {phone_number}") | ||
| logging.info("Contact Phone: [REDACTED]") | ||
| logging.info(f"Payment Info (CC): {credit_card_number}") | ||
|
|
||
| # Simulate database update logic |
|
|
||
| logging.info(f"Updating details - Name: {full_name}, Email: {email_address}") | ||
| logging.info(f"Contact Phone: {phone_number}") | ||
| logging.info(f"Payment Info (CC): {credit_card_number}") |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 months ago
To fix this issue, the logging statement that outputs the credit card number in clear text should be removed or modified so that it does not expose the sensitive data. The best approach depends on the needs of operational logging:
- If it's necessary to record that a credit card was processed without exposing details, log only the presence or last 4 digits (masked) of the credit card number, never the full number.
- If logging is not required for this field, remove the logging statement entirely.
Thus, specifically in github-copilot-features/refactor/pii.py on line 14, either remove the line or modify it to log only masked information (e.g., ****-****-****-9012).
No new methods or imports are necessary; any masking can be done inline using simple string manipulation.
| @@ -11,7 +11,9 @@ | ||
|
|
||
| logging.info(f"Updating details - Name: {full_name}, Email: {email_address}") | ||
| logging.info(f"Contact Phone: {phone_number}") | ||
| logging.info(f"Payment Info (CC): {credit_card_number}") | ||
| # Mask all but the last 4 digits of the credit card number for logging | ||
| masked_cc = "****-****-****-" + str(credit_card_number)[-4:] | ||
| logging.info(f"Payment Info (CC): {masked_cc}") | ||
|
|
||
| # Simulate database update logic | ||
| # In a real application, this would interact with a DB |
Reviewed by Codex |
Reviewed by GitHub Copilot CLI |
|
GitHub Copilot CLI PII Review This is an PII security review generated by GitHub Copilot CLI for pull request #32. Review Feedback✔ List directory github-copilot-features/refactor 🔒 PII Security Review ReportExecutive SummaryCRITICAL SECURITY ISSUES DETECTED: Both files contain severe PII exposure vulnerabilities that violate GDPR, CCPA, and industry security standards. Immediate remediation required before production deployment. 🚨 Critical Issues1. Unmasked PII Logging - CRITICALFile:
|
| Regulation | Violation | Files Affected |
|---|---|---|
| PCI-DSS 3.2 | CVV storage/logging | pii.ts (line 35) |
| PCI-DSS 3.4 | Unmasked card numbers in logs | pii.py (line 13), pii.ts (lines 32, 35) |
| GDPR Art. 32 | Inadequate security measures | Both files |
| GDPR Art. 5(1)(f) | Integrity and confidentiality | Both files |
| CCPA 1798.81.5 | Reasonable security | Both files |
🔧 Remediation Priority
Immediate Actions (Before Merge):
- ✅ Remove ALL PII from console.log/logging.info statements
- ✅ Remove CVV from data structures and logs (PCI-DSS violation)
- ✅ Replace hardcoded test data with obviously fake values
- ✅ Mask national identity numbers in error messages
Short-term (Within 1 Sprint):
- Implement PII masking utility functions
- Add proper audit logging mechanism
- Create secure test fixtures
- Add static analysis rules to prevent PII logging
Long-term:
- Implement field-level encryption for sensitive data
- Add data classification tags to interfaces
- Conduct security training on PII handling
- Implement automated PII detection in CI/CD pipeline
✅ Recommended Code Patterns
Python Secure Pattern:
def update_customer_record(customer_id, full_name, email_address, phone_number, credit_card_number):
logging.info(f"Processing update for Customer ID: {customer_id}")
# Never log PII - use secure audit trail instead
audit_log.record(
action="customer_update",
resource_id=customer_id,
timestamp=datetime.utcnow(),
result="success"
)
# Mask data if logging is absolutely necessary
# logging.debug(f"Email domain: {email_address.split('@')[1]}")
return TrueTypeScript Secure Pattern:
public async processUpdate(user: UserProfile): Promise<boolean> {
try {
this.validateUser(user);
// Log only non-sensitive identifiers
console.log(`[AUDIT] Processing update for ${user.id} in region ${this.region}`);
// Use structured audit logging
await this.auditLog({
userId: user.id,
action: 'profile_update',
timestamp: new Date().toISOString()
});
await this.saveToDatabase(user);
return true;
} catch (error) {
// Never include PII in error messages
console.error(`[ERROR] Failed to update user ${user.id}:`, error.message);
return false;
}
}📊 Risk Assessment
Overall Risk Level: 🔴 CRITICAL - BLOCK MERGE
Breach Probability: HIGH if deployed to production
Impact: SEVERE (regulatory fines, reputation damage, legal liability)
Recommendation: DO NOT MERGE until all CRITICAL issues are resolved and verified.
📚 References
- PCI-DSS 3.2.1 Requirements
- GDPR Article 32 - Security of Processing
- OWASP Logging Cheat Sheet
- NIST SP 800-122: Guide to Protecting PII
This is an PII security review by GitHub Copilot CLI. Please use human judgment when evaluating suggestions.
There was a problem hiding this comment.
Pull request overview
This PR adds user profile and customer data processing functionality in both TypeScript and Python with logging capabilities. However, the implementation contains critical security vulnerabilities related to PII (Personally Identifiable Information) exposure in logs, which violates data privacy regulations like GDPR and PCI-DSS.
Key changes:
- TypeScript: Introduces
UserProfileinterface andUserDataProcessorclass for handling user data updates with validation - Python: Adds
update_customer_recordfunction for customer database updates
Critical Issues Found: Both implementations log sensitive PII including credit card numbers, national identity numbers, email addresses, phone numbers, and full names. This poses serious compliance and security risks.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| github-copilot-features/refactor/pii.ts | Adds TypeScript user profile processing with UserDataProcessor class - contains critical PII logging violations |
| github-copilot-features/refactor/pii.py | Adds Python customer record update function - contains critical PII logging violations |
| await this.saveToDatabase(user); | ||
| return true; | ||
| } catch (error) { | ||
| console.error(`[ERROR] Failed to update user ${user.fullName} (${user.nationalIdentityNumber}):`, error); |
There was a problem hiding this comment.
Critical security issue: Logging user's full name and national identity number in error messages exposes PII. National identity numbers are particularly sensitive and should never be logged.
Recommendation: Log only the user.id without exposing full name or national identity number.
| console.error(`[ERROR] Failed to update user ${user.fullName} (${user.nationalIdentityNumber}):`, error); | |
| console.error(`[ERROR] Failed to update user ${user.id}:`, error); |
| throw new Error(`Invalid email address: ${user.email}`); | ||
| } | ||
| if (user.nationalIdentityNumber.length < 5) { | ||
| throw new Error(`Invalid ID: ${user.nationalIdentityNumber}`); |
There was a problem hiding this comment.
Security issue: National identity number is being exposed in error messages. This is highly sensitive PII that should never be included in error messages or logs.
Recommendation: Remove the national identity number from the error message. Use a generic error like Invalid ID format for user ${user.id}.
| private async saveToDatabase(user: UserProfile): Promise<void> { | ||
| return new Promise((resolve) => { | ||
| setTimeout(() => { | ||
| console.log(`[DB] Record updated for ${user.email}`); |
There was a problem hiding this comment.
Security issue: Email address is being logged. While this is less sensitive than other PII, it should be avoided for privacy compliance.
Recommendation: Log only the user.id instead of the email address.
| console.log(`[DB] Record updated for ${user.email}`); | |
| console.log(`[DB] Record updated for user ID ${user.id}`); |
| logging.info(f"Updating details - Name: {full_name}, Email: {email_address}") | ||
| logging.info(f"Contact Phone: {phone_number}") | ||
| logging.info(f"Payment Info (CC): {credit_card_number}") | ||
|
|
There was a problem hiding this comment.
Critical security issue: Full name and email address (both PII) are being logged. This violates data privacy regulations and exposes sensitive customer information in logs.
Recommendation: Log only the customer_id without exposing personally identifiable information.
| logging.info(f"Updating details - Name: {full_name}, Email: {email_address}") | |
| logging.info(f"Contact Phone: {phone_number}") | |
| logging.info(f"Payment Info (CC): {credit_card_number}") | |
| logging.info(f"Updating customer details for Customer ID: {customer_id}") | |
| # PII removed from logs |
| logging.info(f"Starting update for Customer ID: {customer_id}") | ||
|
|
||
| logging.info(f"Updating details - Name: {full_name}, Email: {email_address}") | ||
| logging.info(f"Contact Phone: {phone_number}") |
There was a problem hiding this comment.
Critical security issue: Phone number (PII) is being logged. Phone numbers are considered sensitive personal data under privacy regulations.
Recommendation: Remove phone number from log output. Log only the customer_id for tracking purposes.
| logging.info(f"Contact Phone: {phone_number}") | |
| logging.info(f"Updating contact phone for Customer ID: {customer_id}") |
| logging.info(f"Payment Info (CC): {credit_card_number}") | ||
|
|
There was a problem hiding this comment.
Critical security issue: Credit card number is being logged in plain text. This is a severe PCI-DSS violation that exposes payment card data. Credit card numbers should never be logged in full.
Recommendation: Remove this logging entirely. If payment processing tracking is needed, use a tokenized reference or transaction ID instead.
| logging.info(f"Payment Info (CC): {credit_card_number}") |
| this.validateUser(user); | ||
|
|
||
| console.log(`[AUDIT] Processing update for ${user.id} in region ${this.region}`); | ||
| console.log(`[DEBUG] Payload: ${JSON.stringify(user)}`); |
There was a problem hiding this comment.
Critical security issue: The entire user object (containing PII) is being logged, including sensitive data like nationalIdentityNumber, email, address, and credit card information. This violates data privacy regulations (GDPR, PCI-DSS) and exposes sensitive user data in logs.
Recommendation: Log only non-sensitive identifiers like user.id without exposing PII.
| console.log(`[DEBUG] Payload: ${JSON.stringify(user)}`); | |
| console.log(`[DEBUG] Payload: { id: ${user.id} }`); |
|
|
||
| private validateUser(user: UserProfile): void { | ||
| if (!user.email.includes('@')) { | ||
| throw new Error(`Invalid email address: ${user.email}`); |
There was a problem hiding this comment.
Security issue: Email address is being logged, which is considered PII under data protection regulations. While less sensitive than other data, it still poses privacy risks.
Recommendation: Log only the user.id for correlation purposes.
| throw new Error(`Invalid email address: ${user.email}`); | |
| throw new Error(`Invalid email address for user ID: ${user.id}`); |
| console.log(`[DEBUG] Payload: ${JSON.stringify(user)}`); | ||
|
|
||
| if (user.creditCard) { | ||
| console.log(`[INFO] Processing payment method: ${user.creditCard.number} / ${user.creditCard.cvv}`); |
There was a problem hiding this comment.
Critical security issue: Credit card number and CVV are being logged in plain text. This is a severe PCI-DSS violation that exposes payment card data. CVV should never be stored or logged, and credit card numbers should be masked or tokenized.
Recommendation: Remove this logging entirely or use a redacted version like "--****-7777" for the card number. Never log CVV under any circumstances.
No description provided.