Thanks to visit codestin.com
Credit goes to github.com

Skip to content

test(rust-audit): cover iso8601 civil-date conversion with fixed-time cases#2163

Merged
imran-siddique merged 1 commit into
microsoft:mainfrom
aegis-initiative:fix/rust-audit-iso8601-frozen-time-test
May 12, 2026
Merged

test(rust-audit): cover iso8601 civil-date conversion with fixed-time cases#2163
imran-siddique merged 1 commit into
microsoft:mainfrom
aegis-initiative:fix/rust-audit-iso8601-frozen-time-test

Conversation

@finnoybu

Copy link
Copy Markdown
Contributor

Summary

agent-governance-rust/agentmesh/src/audit.rs re-implements the Howard Hinnant civil-from-days algorithm inside iso8601_now to avoid pulling in chrono. The only existing test for it asserted shape (length and delimiter positions) — the actual era / day-of-era arithmetic was unverified, so a regression in the date math would silently produce wrong timestamps in every audit entry.

Change

  • Factor the formatting body into a pure iso8601_from_unix_secs(secs: u64) -> String helper. iso8601_now() still reads SystemTime::now() and produces identical output.
  • Add test_iso8601_from_unix_secs_known_values asserting eight reference points:
    • Unix epoch (1970-01-01T00:00:00Z)
    • 2000-01-01 (divisible-by-400 century year)
    • 2000-02-29 and 2024-02-29 (both kinds of leap year)
    • 2024-03-01 (day after leap day — guards off-by-one in mp)
    • 2024-12-31T23:59:59 (last second of a leap year)
    • 1e9 seconds (2001-09-09T01:46:40Z)
    • 1.7e9 seconds (2023-11-14T22:13:20Z)

Reference timestamps cross-checked against DateTimeOffset.FromUnixTimeSeconds.

Tests

  • cargo test -p agentmesh --lib audit:: — 27 passed, 0 failed.

Test plan

  • New test fails if any constant in the civil-date arithmetic (719_468, 146_097, 36524, 1460, the mp formula) is perturbed
  • Existing test_iso8601_now_format shape check still passes
  • No behavioural change to iso8601_now()

Surfaced during independent audit conducted by @finnoybu (Ken Tannenbaum, AEGIS Initiative); [LOW, Rust].

… cases

`audit::iso8601_now` re-implements the Howard Hinnant civil-from-days
algorithm to avoid a chrono dependency. Until now it was only smoke-tested
for format shape (length and delimiter positions) — the actual date math
was unverified, so a regression in the era / day-of-era arithmetic would
silently produce wrong timestamps in every audit entry.

Factor the formatting body into a pure `iso8601_from_unix_secs(secs)`
helper so it can be tested with known inputs, and assert eight reference
points covering edges that exercise the algorithm:

  - Unix epoch (1970-01-01)
  - 2000-01-01 (divisible-by-400 century year)
  - 2000-02-29 and 2024-02-29 (both kinds of leap year)
  - 2024-03-01 (day after leap day — guards off-by-one in `mp`)
  - 2024-12-31T23:59:59 (last second of a leap year)
  - 1e9 and 1.7e9 seconds (common reference points)

No behavioural change — `iso8601_now()` still reads `SystemTime::now()`
and produces the same output.
@github-actions github-actions Bot added the size/M Medium PR (< 200 lines) label May 12, 2026
@github-actions

Copy link
Copy Markdown
🤖 AI Agent: test-generator — `agent-governance-rust/agentmesh/src/audit.rs`

agent-governance-rust/agentmesh/src/audit.rs

  • test_iso8601_from_unix_secs_known_values -- validates correct ISO-8601 formatting for various significant Unix timestamps.

@github-actions

Copy link
Copy Markdown
🤖 AI Agent: security-scanner — View details

No security issues found.

@github-actions

Copy link
Copy Markdown
🤖 AI Agent: docs-sync-checker — Docs Sync

Docs Sync

  • iso8601_now() in audit.rs -- missing docstring
  • README.md -- section on date formatting needs update
  • CHANGELOG.md -- missing entry for behavioral changes in iso8601_now()

@github-actions

Copy link
Copy Markdown
🤖 AI Agent: code-reviewer — View details

TL;DR: 0 blockers, 0 warnings. No issues found. Clean change.

@github-actions

Copy link
Copy Markdown
🤖 AI Agent: breaking-change-detector — API Compatibility

API Compatibility

Severity Change Impact
Potentially Breaking The iso8601_now function now delegates to iso8601_from_unix_secs, which could introduce discrepancies if the implementation of iso8601_from_unix_secs has any unintended side effects or errors in date calculations. May affect any existing functionality relying on iso8601_now if the new implementation does not match expected behavior.

@github-actions

Copy link
Copy Markdown

🟡 Contributor Check: MEDIUM

Check Result
Profile MEDIUM
Credential NONE
Overall MEDIUM

Automated check by AGT Contributor Check.

@github-actions github-actions Bot added the needs-review:MEDIUM Contributor check flagged MEDIUM risk label May 12, 2026
@github-actions

Copy link
Copy Markdown

PR Review Summary

Check Status Details
🔍 Code Review ✅ Passed No issues found
🛡️ Security Scan ✅ Passed No issues found
🔄 Breaking Changes ✅ Completed Analysis complete
📝 Docs Sync ✅ Completed Analysis complete
🧪 Test Coverage ✅ Completed Analysis complete

Verdict: ✅ Ready for human review

@imran-siddique imran-siddique merged commit 8d0982d into microsoft:main May 12, 2026
13 of 14 checks passed
MohammadHaroonAbuomar pushed a commit to MohammadHaroonAbuomar/agt-acs that referenced this pull request Jun 1, 2026
… cases (microsoft#2163)

`audit::iso8601_now` re-implements the Howard Hinnant civil-from-days
algorithm to avoid a chrono dependency. Until now it was only smoke-tested
for format shape (length and delimiter positions) — the actual date math
was unverified, so a regression in the era / day-of-era arithmetic would
silently produce wrong timestamps in every audit entry.

Factor the formatting body into a pure `iso8601_from_unix_secs(secs)`
helper so it can be tested with known inputs, and assert eight reference
points covering edges that exercise the algorithm:

  - Unix epoch (1970-01-01)
  - 2000-01-01 (divisible-by-400 century year)
  - 2000-02-29 and 2024-02-29 (both kinds of leap year)
  - 2024-03-01 (day after leap day — guards off-by-one in `mp`)
  - 2024-12-31T23:59:59 (last second of a leap year)
  - 1e9 and 1.7e9 seconds (common reference points)

No behavioural change — `iso8601_now()` still reads `SystemTime::now()`
and produces the same output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review:MEDIUM Contributor check flagged MEDIUM risk size/M Medium PR (< 200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants