Skip to content

Feature/utc timestamp validation#317

Merged
1nonlypiece merged 5 commits into
Disciplr-Org:mainfrom
Praxhant97:feature/utc-timestamp-validation
May 1, 2026
Merged

Feature/utc timestamp validation#317
1nonlypiece merged 5 commits into
Disciplr-Org:mainfrom
Praxhant97:feature/utc-timestamp-validation

Conversation

@Praxhant97
Copy link
Copy Markdown
Contributor

Closes #233

Copilot AI review requested due to automatic review settings April 29, 2026 07:52
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 29, 2026

@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! 🚀

Learn more about application limits

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 centralized utcTimestampSchema to enforce “timezone required” + normalize to UTC Z.
  • Apply UTC timestamp schema to vault validation and job enqueue payloads; add tests for edge cases and schema behavior.
  • Introduce privacyLogger middleware 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 thread docs/privacy-logging.md
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 thread docs/privacy-logging.md
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 thread docs/TIMEZONE_CONTRACT.md
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 thread src/lib/validation.ts
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
@1nonlypiece 1nonlypiece merged commit 3dc84b7 into Disciplr-Org:main May 1, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add consistent UTC timestamp parsing and validation across request payloads

3 participants