-
Notifications
You must be signed in to change notification settings - Fork 11
[DNM] Prototype: Validate File Path #196
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces file path validation functionality to ensure that certificate and key file paths are writable before attempting to use them. The implementation adds a utility function to validate file paths and integrates it into the certificate service workflow.
- Adds a new utility function
ValidateFilePathto check if file paths are writable - Integrates path validation into the certificate service's run cycle
- Creates a validator function to check all certificate-related file paths
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pkg/util/validate-file-path.go | New utility function for validating file path writability |
| pkg/certificate/service.go | Integration of path validation into the service run cycle |
| pkg/certificate/path-validator.go | Validator function that checks all certificate-related paths |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #196 +/- ##
========================================
- Coverage 9.50% 9.41% -0.09%
========================================
Files 34 36 +2
Lines 3326 3356 +30
========================================
Hits 316 316
- Misses 2988 3018 +30
Partials 22 22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Warning
Do NOT merge this PR as this PR is only intended for the sample code
Background
The current SIA agent fetches a new certificate from ZTS before attempting to write it to the filesystem. If the file write operation fails for any reason (e.g., incorrect permissions, non-existent directory, full disk), the agent enters a state of inconsistency: the new certificate exists in memory, but the old one remains on disk.
This inconsistency prevents future certificate renewals and requires complex manual intervention, such as deleting files and hard-rebooting the instance, to recover the agent.
What's done?
This PR introduces a robust pre-verification check that runs before the agent requests a certificate from ZTS. This check ensures that the followings are writable:
This PR does not include the following:
If file path is not ready, it will output the following as a log:
Assignees
Assigneesis setType of changes
labelsof the following that fits:bug: Bug fixdependencies: Dependency upgradesdocumentation: Documentation changesenhancement: New Featuregood first issue: First contributionlogging: Log changesrefactor: Refactoring (no functional changes, no api changes)Flags
Checklist
Checklist for maintainer