-
Notifications
You must be signed in to change notification settings - Fork 1
Phase 1: Security hardening, validation, logging, and image optimization #1
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: main
Are you sure you want to change the base?
Phase 1: Security hardening, validation, logging, and image optimization #1
Conversation
- CODE_REVIEW_AND_INTEGRATION_PLAN.md: Comprehensive analysis including: - Security vulnerabilities (hardcoded credentials, OAuth exposure) - Missing components (OAuth script was documented but never created) - Architectural weaknesses (legacy SMTP, no connection pooling) - Operational gaps (no logging, no metrics, no bounce handling) - Compliance issues (GDPR/CAN-SPAM gaps) - 10 expanded enhancement ideas with code examples - 12-week phased integration plan with priorities - Send-M365Digest-OAuth.ps1: The missing OAuth authentication script that was referenced in documentation but never implemented. Includes: - OAuth2 client credentials flow - Secure credential loading options (env vars, Key Vault, encrypted files) - Configuration validation - Detailed setup instructions
## Security Improvements
- Removed all hardcoded credentials from Send-M365Digest-BasicAuth.ps1
- Added 4 secure credential methods: Prompt, Environment, CredentialManager, SecureFile
- URLs in templates are now validated (blocks javascript:, data:, vbscript:)
- Non-URL values are HTML-encoded to prevent XSS injection
## New Features - M365DigestEmailModule v1.1.0
- Test-EmailAddress: RFC-compliant email validation
- Test-UrlSafety: URL scheme validation (http/https only)
- Add-FailedRecipient: Tracks failed emails to CSV file
- Set-DigestLogConfig/Write-DigestLog: Structured JSON logging
- Campaign correlation IDs for tracing
## Module Manifest
- Created M365DigestEmailModule.psd1 with:
- Version 1.1.0
- PowerShell 5.1 minimum requirement
- Exported functions list
- Release notes and metadata
## Image Optimization
- Compressed PNG icons from 4.8MB to 90KB total (98% reduction)
- m365_icon.png: 1.6MB -> 42KB
- exchange_icon.png: 1.6MB -> 34KB
- sharepoint_icon.png: 1.6MB -> 14KB
- Resized to 200x200 max (appropriate for email icons)
## Breaking Changes
- Send-HtmlEmail returns hashtable {Success, Error, Email} instead of boolean
- BasicAuth script requires -CredentialMethod parameter (defaults to 'Prompt')
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| $script:LogConfig.LogFilePath = $LogFilePath | ||
| $script:LogConfig.LogLevel = $LogLevel | ||
| $script:LogConfig.JsonFormat = $JsonFormat | ||
| $script:LogConfig.CorrelationId = $CorrelationId ?? [guid]::NewGuid().ToString('N').Substring(0, 8) |
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.
Replace PS7 null-coalescing with PS5-compatible logic
With PowerShell 5.1 (the module’s declared minimum), the line in Set-DigestLogConfig uses the PowerShell 7 ?? null-coalescing operator, which 5.1 cannot parse; this prevents the module from loading at all and causes any consuming script to fail before execution. Use an explicit null check instead of ?? to keep the code compatible with the required runtime.
Useful? React with 👍 / 👎.
Summary
Test plan