Added support for schema creation and existance checking#301
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR extends the WorkOS PHP SDK's audit logs functionality by adding comprehensive schema management capabilities. The changes introduce three new methods to the AuditLogs class:
createSchema()- Creates new audit log action schemas with validationschemaExists()- Checks if a schema exists by attempting to fetch it and catching 404 exceptionslistActions()- Lists available audit log actions with pagination support (before/after cursors and ordering)
Additionally, the PR adds input validation to the existing getExport() method to prevent path traversal attacks. The validation uses regex patterns to allow only safe characters (alphanumeric, dots, underscores, hyphens) in action names and export IDs.
The implementation follows existing patterns in the codebase, using the same request/response handling approach as other audit log methods. The schemaExists() method uses exception handling to determine existence rather than a dedicated endpoint, catching NotFoundException when schemas don't exist and returning a boolean result.
Comprehensive test coverage has been added for all new methods, including both success scenarios and error cases (like 404 responses). The tests follow the established patterns with proper mocking, fixtures, and assertions, ensuring the new schema management features integrate seamlessly with the existing audit logs functionality.
Confidence score: 4/5
- This PR is generally safe to merge but requires attention to input validation patterns
- Score reflects solid implementation following existing patterns, but input validation could be more robust
- Pay close attention to the input validation regex patterns in
lib/AuditLogs.php
Context used:
Rule - All user inputs must be validated before processing (link)
2 files reviewed, no comments
|
Thank you so much for contributing to this SDK! The changes look good to me! However, it looks like a test is failing due to a linting error. Can you fix it, and I'd be happy to approve? Let me know if you don't have time, and I can give it a shot. |
1) lib/AuditLogs.php (no_trailing_whitespace_in_comment)
Description
Add additional method to handle schema creation, schema existence checks, and listing actions.