🛡️ Shield: Robust numeric timestamp parsing#720
Conversation
test(utils): add tests for numeric timestamp parsing docs(shield): journal numeric timestamp fix Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
test(utils): add tests for numeric timestamp parsing docs(shield): journal numeric timestamp fix Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
test(utils): add tests for numeric timestamp parsing docs(shield): journal numeric timestamp fix Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
🛑 Vulnerability: The
parse_datetimevalidator implicitly assumed input timestamps would be strings (ISO format) orNone. However, numeric timestamps (int/float seconds since epoch) are a valid data type in Python and potentially from API responses, but were being returned as-is (raw numbers) instead of converted todatetimeobjects. This bypasses type safety and could cause downstream AttributeErrors when methods like.strftime()are called on an integer.🛡️ Defense: Updated
parse_datetimeinsrc/imednet/utils/validators.pyto explicitly detectintandfloattypes and convert them to timezone-aware UTCdatetimeobjects usingdatetime.fromtimestamp(v, tz=timezone.utc).🔬 Verification: Created
tests/unit/test_parse_datetime_robustness.pywhich validates:1609459200) -> UTC datetime1609459200.5) -> UTC datetime with microseconds📊 Impact: Fixes a potential "sad path" crash where numeric timestamps would be passed through as integers, ensuring 100% of outputs from
parse_datetimeare validdatetimeobjects (or the sentinel).PR created automatically by Jules for task 13020613294477168326 started by @fderuiter