Skip to content
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

CBG-4117: Add type checking to mandatory audit fields during event validation #7011

Merged
merged 5 commits into from
Jul 25, 2024

Conversation

bbrks
Copy link
Member

@bbrks bbrks commented Jul 24, 2024

CBG-4117

Previously #6987

Ensures that the type for the field in the event declaration matches the one actually being passed (when validating during devmode)

Caught a few instances of fields not matching their definitions and potential bugs as a result:

  • AuditFieldPayload in some cases was taking either []byte or a struct, instead of string
    • This will affect audit output ([]byte will be a base64 encoded string in JSON)
    • handlePutDbAuditConfig was printing the resulting config, rather than the request payload.
  • Resync "reset" param: string vs. bool for a minor difference in output.
  • Benign changes (don't affect audit output):
    • AuditFieldID switched to uint32 in all places
      • Was a mixture of implicit int and uint64 types, but 32bit uints are plenty to represent audit IDs
    • AuditFieldTimestamp time.Time->string
      • expandFields now writes a RFC3339 formatted timestamp directly, instead of relying on the underlying JSON marshalling of time.Time. Gives us better control of format.

Integration Tests

@bbrks bbrks changed the title Add type checking to mandatory audit fields during event validation CBG-4117: Add type checking to mandatory audit fields during event validation Jul 25, 2024
@bbrks bbrks merged commit 36d1a81 into main Jul 25, 2024
21 checks passed
@bbrks bbrks deleted the type_check_mandatory_fields branch July 25, 2024 17:12
bbrks added a commit that referenced this pull request Jul 26, 2024
… audit fields during event validation (#7011)

* misc audit field type changes

* More audit field type corrections

* Read handlePutDbAuditConfig into bytes before unmarshalling so we can pass it into audit event as raw json

* Type check mandatory field values to ensure consistency with the defined event

* uint -> uint32 for audit ID
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.

2 participants