Skip to content

fix(scripts): centralize ISO 8601 timestamp regex in CIHelpers#1343

Open
MauroDruwel wants to merge 1 commit intomicrosoft:mainfrom
MauroDruwel:fix/centralize-timestamp-regex
Open

fix(scripts): centralize ISO 8601 timestamp regex in CIHelpers#1343
MauroDruwel wants to merge 1 commit intomicrosoft:mainfrom
MauroDruwel:fix/centralize-timestamp-regex

Conversation

@MauroDruwel
Copy link
Copy Markdown

Pull Request

Description

Add Get-StandardTimestampPattern to CIHelpers.psm1 returning the canonical
regex for validating Get-StandardTimestamp output. Replace all standalone
hardcoded ISO 8601 timestamp patterns across five test files with calls to this
function, eliminating duplication and drift.

Three distinct regex variants had already emerged across the test suite:

Variant Where Risk
\.\d+Z$ CIHelpers, SecurityHelpers, FrontmatterValidation Canonical
\.\d{3,7}Z$ SecurityClasses Silently rejects valid timestamps with >7 fractional digits
.*Z$ Invoke-YamlLint Matches anything before Z, defeats validation purpose

The new function returns a single source of truth so all assertions stay in sync
automatically if the timestamp format changes.

Relationship to #1314

This PR was born from the review discussion on #1314, filed separately as #1333.

#1314 This PR
What Renames JSON keys timestampTimestamp Centralizes the regex that validates timestamp values
Scope 4 linting scripts + 5 test files CIHelpers.psm1 + 5 test files
File overlap None None
Merge order Independent Independent

Both PRs are needed — they address different layers of the same standardization
effort (#1003). #1314 fixes how timestamps are named in JSON output; this PR
fixes how timestamps are validated in tests. Neither blocks the other and they
can merge in any order without conflicts.

Note: FrontmatterValidation.Tests.ps1 still uses lowercase
$hash['timestamp'] — that key casing is #1314's scope, intentionally left
untouched here.

Related Issue(s)

Closes #1333

Type of Change

Code & Documentation:

  • Bug fix (non-breaking change fixing an issue)

Other:

  • Script/automation (.ps1, .sh, .py)

Testing

  • Replaced regex strings with (Get-StandardTimestampPattern) calls in 5 test files
  • Added 2 new verification tests in CIHelpers.Tests.ps1:
    • Get-StandardTimestampPattern returns a non-empty string
    • Pattern matches actual Get-StandardTimestamp output (cross-validation)
  • Added explicit CIHelpers module imports to 3 test files that lacked direct
    access (SecurityClasses, SecurityHelpers, FrontmatterValidation)

Files Changed

Module (new function + export):

  • scripts/lib/Modules/CIHelpers.psm1Get-StandardTimestampPattern function and Export-ModuleMember entry

Tests (hardcoded regex → function call):

  • scripts/tests/lib/CIHelpers.Tests.ps1 — replaced regex; added Describe 'Get-StandardTimestampPattern' block
  • scripts/tests/linting/FrontmatterValidation.Tests.ps1 — replaced 2 regexes; added CIHelpers import
  • scripts/tests/linting/Invoke-YamlLint.Tests.ps1 — replaced 1 regex (already imported CIHelpers)
  • scripts/tests/security/SecurityClasses.Tests.ps1 — replaced 1 regex; added CIHelpers import
  • scripts/tests/security/SecurityHelpers.Tests.ps1 — replaced 1 regex; added CIHelpers import

Checklist

Required Checks

  • Documentation is updated (if applicable)
  • Files follow existing naming conventions
  • Changes are backwards compatible (if applicable)
  • Tests added for new functionality (if applicable)

Required Automated Checks

  • Markdown linting: npm run lint:md
  • Spell checking: npm run spell-check
  • Frontmatter validation: npm run lint:frontmatter
  • Skill structure validation: npm run validate:skills
  • Link validation: npm run lint:md-links
  • PowerShell analysis: npm run lint:ps
  • Plugin freshness: npm run plugin:generate
  • Docusaurus tests: npm run docs:test

Security Considerations

  • This PR does not contain any sensitive or NDA information
  • Any new dependencies have been reviewed for security issues
  • Security-related scripts follow the principle of least privilege

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MauroDruwel MauroDruwel requested a review from a team as a code owner April 11, 2026 18:50
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.

Centralize ISO 8601 timestamp regex pattern in CIHelpers

1 participant