Skip to content

feat: add configuration validation feature#89

Merged
soulteary merged 1 commit intomainfrom
prom-metrics
Jan 6, 2026
Merged

feat: add configuration validation feature#89
soulteary merged 1 commit intomainfrom
prom-metrics

Conversation

@soulteary
Copy link
Copy Markdown
Owner

  • Introduced a new feature to validate configuration files before application startup, enhancing error handling and user feedback.
  • Added new constants for configuration validation messages in both English and Chinese locales.
  • Updated CLI flags to include a --validate-config option, allowing users to validate configurations easily.
  • Enhanced the main application logic to perform validation checks and report errors if any are found.

- Introduced a new feature to validate configuration files before application startup, enhancing error handling and user feedback.
- Added new constants for configuration validation messages in both English and Chinese locales.
- Updated CLI flags to include a `--validate-config` option, allowing users to validate configurations easily.
- Enhanced the main application logic to perform validation checks and report errors if any are found.
@soulteary soulteary merged commit 0d96ff8 into main Jan 6, 2026
2 checks passed
// 使用跨平台方法:尝试创建临时文件来检查写入权限
func isWritable(path string) bool {
testFile := filepath.Join(path, ".webhook_write_test")
f, err := os.Create(testFile)

Check failure

Code scanning / gosec

Potential file inclusion via variable Error

Potential file inclusion via variable
// isReadable 检查文件是否可读
func isReadable(path string) bool {
// 尝试打开文件进行读取
f, err := os.Open(path)

Check failure

Code scanning / gosec

Potential file inclusion via variable Error

Potential file inclusion via variable
Comment thread internal/i18n/id.go
MSG_WEBHOOK_VERSION = "WEBHOOK_VERSION"
MSG_SETUID_OR_SETGID_ERROR = "ERROR_SETUID_OR_SETGID"
MSG_SERVER_IS_STARTING = "SERVER_IS_STARTING"
MSG_CONFIG_VALIDATION_PASSED = "CONFIG_VALIDATION_PASSED"

Check failure

Code scanning / gosec

Potential hardcoded credentials Error

Potential hardcoded credentials
if err != nil {
return false
}
f.Close()

Check warning

Code scanning / gosec

Errors unhandled Warning

Errors unhandled
return false
}
f.Close()
os.Remove(testFile)

Check warning

Code scanning / gosec

Errors unhandled Warning

Errors unhandled
if err != nil {
return false
}
f.Close()

Check warning

Code scanning / gosec

Errors unhandled Warning

Errors unhandled
@soulteary soulteary deleted the prom-metrics branch January 7, 2026 16:19
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