Feature/utc timestamp validation#317
Merged
1nonlypiece merged 5 commits intoMay 1, 2026
Merged
Conversation
|
@Praxhant97 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
There was a problem hiding this comment.
Pull request overview
Implements consistent UTC timestamp validation/normalization (timezone required; normalize to Z) across request payload schemas, and extends timestamp test coverage. The PR also adds a new privacy-logging middleware with redaction rules plus documentation/tests.
Changes:
- Add
hasTimezoneDesignator()and use centralizedutcTimestampSchemato enforce “timezone required” + normalize to UTCZ. - Apply UTC timestamp schema to vault validation and job enqueue payloads; add tests for edge cases and schema behavior.
- Introduce
privacyLoggermiddleware with recursive redaction + IP masking, along with docs and tests.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/timestamps.ts | Adds timezone-designator helper used by centralized validation. |
| src/lib/validation.ts | Introduces utcTimestampSchema that enforces timezone + normalizes to UTC. |
| src/services/vaultValidation.ts | Switches vault/milestone timestamps to utcTimestampSchema and tightens verifier validation. |
| src/routes/jobs.ts | Validates/normalizes deadlineIso via utcTimestampSchema on enqueue requests. |
| src/tests/timestamps.test.ts | Adds coverage for invalid time parts, timezone designator helper, schema normalization, and day-boundary helpers. |
| src/tests/deadline.test.ts | Adds regression coverage for deadline expiry when input timestamp has an offset. |
| src/middleware/privacy-logger.ts | Adds request logging with recursive redaction and IP masking (now global middleware). |
| src/tests/privacy-logger.test.ts | Adds unit/integration tests for redaction, IP masking, and middleware logging. |
| docs/privacy-logging.md | Documents privacy logging/redaction policy. |
| docs/TIMEZONE_CONTRACT.md | Adds request payload examples and expected validation error excerpt. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
62
to
67
| // Simple body masking for PII fields identified in PRIVACY.md | ||
| const sanitizedBody = sanitizeBody(req.body) | ||
| const sanitizedBody = redact(req.body) | ||
| const sanitizedHeaders = redact(req.headers) | ||
|
|
||
| console.log(`[${timestamp}] [IP: ${maskedIp}] ${method} ${url} - Body: ${JSON.stringify(sanitizedBody)}`) | ||
| console.log(`[${timestamp}] [IP: ${maskedIp}] ${method} ${url} - Headers: ${JSON.stringify(sanitizedHeaders)} - Body: ${JSON.stringify(sanitizedBody)}`) | ||
|
|
Comment on lines
+4
to
+9
| Disciplr is committed to protecting user data. To ensure that sensitive Personally Identifiable Information (PII) and credentials are never written to long-term storage via logs, we have implemented a dedicated `privacy-logger` middleware. | ||
|
|
||
| ## Redaction Policy | ||
|
|
||
| Any field containing the following keys (case-insensitive) will have its value redacted and replaced with `***REDACTED***` in our application and audit logs: | ||
| - `email` |
Comment on lines
+1
to
+6
| # Privacy Logging Guidelines | ||
|
|
||
| ## Overview | ||
| Disciplr is committed to protecting user data. To ensure that sensitive Personally Identifiable Information (PII) and credentials are never written to long-term storage via logs, we have implemented a dedicated `privacy-logger` middleware. | ||
|
|
||
| ## Redaction Policy |
Comment on lines
+24
to
+36
| ## Request examples | ||
|
|
||
| ### Valid payloads (timezone required) | ||
|
|
||
| ```json | ||
| { | ||
| "startDate": "2026-06-01T09:00:00Z", | ||
| "endDate": "2026-06-30T17:00:00+02:00", | ||
| "milestones": [ | ||
| { | ||
| "title": "Kickoff", | ||
| "dueDate": "2026-06-07T12:00:00-04:00", | ||
| "amount": "100" |
Comment on lines
+28
to
+33
| export const utcTimestampSchema = z | ||
| .string({ error: 'required' }) | ||
| .superRefine((value, ctx) => { | ||
| if (!hasTimezoneDesignator(value)) { | ||
| ctx.addIssue({ | ||
| code: 'custom', |
Comment on lines
+35
to
+44
| if (typeof value === 'object') { | ||
| const result: Record<string, any> = {} | ||
| for (const [k, v] of Object.entries(value)) { | ||
| if (shouldRedact(k)) { | ||
| result[k] = '***REDACTED***' | ||
| } else { | ||
| result[k] = redact(v) | ||
| } | ||
| } | ||
| return result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #233