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

Refactor: Dynamically Set Start Date & Enhance Credential Validation #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pvonleh
Copy link
Contributor

@pvonleh pvonleh commented Feb 2, 2025

This pull request makes several improvements to the audit export client:

Dynamic Start Date:
The start date is now automatically calculated as 30 days before the current UTC time instead of a hard-coded static date. This change ensures that the script always fetches recent audit data without requiring manual updates to the configuration.

Enhanced Configuration Loading:
The configuration loader now checks for file existence, emptiness, and preserves key casing. It logs clear error messages if any required keys (API_TOKEN and API_TOKEN_ID) are missing or empty.

Improved Credential Validation:
The credential validation function has been updated to use the dynamically calculated start date (or a fixed date window based on it) so that the request parameters (query string and headers) are consistent. This helps ensure that the signature is generated correctly and prevents misleading 403 responses.

Robust Error Handling & Logging:
The script now logs detailed messages during retries and stops further retries immediately for 403 errors. A global error flag or immediate exception raising can be implemented to prevent false success messages when errors occur.

Terminal Print Message:
Commented the print statement displayed at the end of the script execution. This will provide a cleaner terminal. Once uncommented, the print statements also provides clearer guidance on locating the audit log. The updated message now explicitly instructs users to check the audit_output path and ensures they understand that the audit data corresponds with the date file.

These changes improve the flexibility and robustness of the audit export client, making it easier to maintain and ensuring that only valid credentials are used to fetch data.

@pvonleh pvonleh changed the title Error handling logic + clear comments Refactor: Dynamically Set Start Date & Enhance Credential Validation Feb 2, 2025
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.

1 participant