Commit Graph

1909 Commits

Author SHA1 Message Date
yusing
54be056530 refactor(rules): improve termination detection and block parsing logic
Refactors the termination detection in the rules DSL to properly handle if-block and if-else-block commands.

Adds new functions `commandsTerminateInPre`, `commandTerminatesInPre`, and `ifElseBlockTerminatesInPre`
to recursively check if command sequences terminate in the pre-phase.

Also improves the Parse function to try block syntax first with proper error handling and fallback to YAML.

Includes test cases for dead code detection with terminating handlers in conditional blocks.
2026-02-24 01:05:54 +08:00
yusing
08de9086c3 fix(rules): buffer log output before writing to stdout/stderr 2026-02-24 00:12:29 +08:00
yusing
1a17f3943a refactor(rules): change default rule from baseline to fallback behavior
The default rule should runs only when no non-default pre rule matches, instead of running first as a baseline.
This follows the old behavior as before the pr is established.:

- Default rules act as fallback handlers that execute only when no matching non-default rule exists in the pre phase
- IfElseBlockCommand now returns early when a condition matches with a nil Do block, instead of falling through to else blocks
- Add nil check for auth handler to allow requests when no auth is configured
- Fix unterminated environment variable parsing to preserve input

Updates tests to verify the new fallback behavior where special rules suppress default rule execution.
2026-02-24 00:11:03 +08:00
yusing
9bb5c54e7c refactor(rules): defer error logging until after FlushRelease
Split error handling into isUnexpectedError predicate and logFlushError
function. Use rm.AppendError() to collect unexpected errors during rule
execution, then log after FlushRelease completes rather than immediately.
Also updates goutils dependency for AppendError method availability.
2026-02-23 23:09:24 +08:00
yusing
faecbab2cb refactor(rules): introduce block DSL, phase-based execution, and flow validation
- add block syntax parser/scanner with nested @blocks and elif/else support
- restructure rule execution into explicit pre/post phases with phase flags
- classify commands by phase and termination behavior
- enforce flow semantics (default rule handling, dead-rule detection)
- expand HTTP flow coverage with block + YAML parity tests and benches
- refresh rules README/spec and update playground/docs integration
2026-02-23 22:24:15 +08:00
yusing
0850ea3918 docs(http): remove default client from README.md 2026-02-23 14:51:30 +08:00
yusing
dd84d57f10 chore(deps): update submodule goutils 2026-02-23 14:51:03 +08:00
yusing
0aae9f07d1 chore(vscode): update YAML schema paths in settings example 2026-02-23 11:34:44 +08:00
yusing
ac1d8f3487 docs(readme): remove API endpoints section and clarify proxmox log streaming descriptions 2026-02-23 11:34:33 +08:00
yusing
6e8f5fb58d fix(server): fix race with closing listener first then shutdown 2026-02-23 11:28:09 +08:00
yusing
3001417a37 fix(health): only send recovery notification after down notification
Previously, up notifications were sent whenever a service recovered,
even if no down notification had been sent (e.g., when recovering
before the failure threshold was met). This could confuse users who
would receive "service is up" notifications without ever being
notified of a problem.

Now, recovery notifications are only sent when a prior down
notification exists, ensuring notification pairs are always complete.
2026-02-23 11:05:19 +08:00
yusing
730757e2c3 chore(ci): update GitHub Actions workflow to include versioned tags for CLI binary builds 2026-02-22 19:59:00 +08:00
yusing
be53b961b6 chore(env): add LOCAL_API_ADDR to env example 2026-02-22 19:55:26 +08:00
yusing
f6a82a3b7c docs(api): update swagger docs with field descriptions and operationId rename
- Add minimum: 0 validation to LogRetention properties (days, keep_size, last)
- Add "interned" descriptions to fstype, path, and name fields
- Rename operationId and x-id from "routes" to "list" for GET /route endpoint
2026-02-22 19:54:56 +08:00
yusing
4e5ded13fb fix(api/proxmox): add websocket validation to journalctl and tail endpoints
Add required websocket check at the beginning of both journalctl and tail endpoint handlers to ensure these endpoints only accept websocket connections.
2026-02-22 19:54:09 +08:00
yusing
2305eca90b feat(cli): add CLI application with automatic command generation from swagger
Add a new CLI application (`cmd/cli/`) that generates command-line interface commands from the API swagger specification. Includes:
- Main CLI entry point with command parsing and execution
- Code generator that reads swagger.json and generates typed command handlers
- Makefile targets (`gen-cli`, `build-cli`) for generating and building the CLI
- GitHub Actions workflow to build cross-platform CLI binaries (linux/amd64, linux/arm64)
2026-02-22 19:51:49 +08:00
yusing
4580543693 refactor(icons): improve favicon fetching with custom HTTP client and content-type validation
Replace the existing HTTP client with a custom-configured client that skips TLS verification for favicon fetching,
and add explicit Content-Type validation to ensure only valid image responses are accepted.

This fixes potential issues with SSL certificate validation and prevents processing of non-image responses.
2026-02-22 16:06:13 +08:00
yusing
bf54b51036 chore(http): remove stale default_client.go 2026-02-22 16:05:30 +08:00
yusing
8ba937ec4a refactor(middleware): replace sensitive fields with redacted types 2026-02-22 16:05:02 +08:00
yusing
0f78158c64 refactor: fix lint errors; improve error handling 2026-02-22 16:04:25 +08:00
yusing
3a7d1f8b18 refactor: modernize code with go fix 2026-02-21 13:03:21 +08:00
yusing
64ffe44a2d refactor(systeminfo): correct field usage regarding update to gopsutil submodule 2026-02-21 13:00:00 +08:00
yusing
dea37a437b chore: apply golangci-lint fmt 2026-02-21 12:56:51 +08:00
yusing
ee973f7997 chore(deps): upgrade dependencies and submodules 2026-02-21 12:53:34 +08:00
yusing
8756baf7fc fix(docs): remove application/json from /file/content API 2026-02-18 19:13:00 +08:00
yusing
a12bdeaf55 refactor(middleware): replace path prefix checks with function-based approach
Replace simple path prefix-based enforcement/bypass mechanism with a more
flexible function-based approach. This allows for more complex conditions
to determine when middleware should be enforced or bypassed.

- Add checkReqFunc and checkRespFunc types for flexible condition checking
- Replace enforcedPathPrefixes with separate enforce and bypass check functions
- Add static asset path detection for automatic bypassing
- Separate request and response check logic for better granularity
2026-02-18 19:12:07 +08:00
yusing
f7676b2dbd chore(go.mod): add backoff library for retrying operations 2026-02-18 18:17:29 +08:00
yusing
add7884a36 feat(icons): improve search ranking with priority-based matching
Restructure icon search to use a tiered ranking system:
- Exact matches get highest priority (rank 0)
- Prefix matches ranked by name length (rank 100+)
- Contains matches ranked by relevance (rank 500+)
- Fuzzy matches as fallback (rank 1000+)

Also refactors InitCache to use switch statements for clarity
and updates goutils submodule.
2026-02-18 18:13:34 +08:00
yusing
115fba4ff4 feat(route): allow empty listening port in port specification
Support the ":proxy" format where only the proxy port is specified.
When the listening port part is empty, it defaults to 0 instead of
returning a parse error.
2026-02-18 14:37:23 +08:00
yusing
bb757b2432 refactor: replace custom helper with stdlib strings.* 2026-02-18 14:26:29 +08:00
yusing
c2d8cca3b4 refactor(docs): migrate wiki generation to MDX format
- Convert markdown output to  fumadocs MDX
- Add api-md2mdx.ts for markdown to MDX transformation
- Remove sidebar auto-update functionality
- Change output directory from src/impl to content/docs/impl
- Update DOCS_DIR path in Makefile to local wiki directory
- Copy swagger.json directly instead of generating markdown
- Add argparse dependency for CLI argument parsing
2026-02-18 14:05:40 +08:00
yusing
20695c52e8 docs: unify header to import path for package docs 2026-02-18 03:25:32 +08:00
yusing
7baf0b6fe5 refactor(metrics): reorganize system info collection into separate functions
Split the monolithic AllSystemInfo handler into smaller, focused functions:
- Extract streamSystemInfo for channel consumption
- Add queueSystemInfo for safe non-blocking queue operations
- Create collectSystemInfoRound for parallel agent data collection
- Implement handleRoundResult for consistent round result processing
- Replace custom exponential backoff with cenkalti/backoff/v5 library

This improves code maintainability and separates concerns within the metrics API endpoint.
2026-02-16 20:19:18 +08:00
yusing
863f16862b chore: update screenshots 2026-02-16 10:48:41 +08:00
yusing
b4a9f44f4e fix(makefile): correct minify-js receipe syntax v0.26.0 2026-02-16 08:33:55 +08:00
yusing
ae45854977 fix(makefile): update minify-js target to conditionally skip based on agent and socket-proxy flags 2026-02-16 08:24:14 +08:00
yusing
b272f3ffb7 refactor(scripts): enhance update-wiki script directory link resolution with parent fallback
Add fallback logic to rewriteImplMarkdown to traverse parent directories when resolving directory links, allowing paths like "internal/watcher/events" to resolve via their parent "internal/watcher" if no exact match exists. Also update built-in import to use explicit "node:" protocol.
2026-02-16 08:13:47 +08:00
yusing
9064a37d62 fix(rules): update webui rules manifest path from webmanifest to json
- Changed the path for the manifest from /manifest.webmanifest to /manifest.json in both webui_dev.yml and webui.yml.
2026-02-16 07:44:51 +08:00
yusing
a8f4b8afee chore(makefile): suppress git describe stderr in VERSION variable 2026-02-15 20:08:10 +08:00
yusing
f8bc8dddb6 refactor(icons): hasIcon always return true in tests 2026-02-15 20:08:10 +08:00
yusing
54ea4d8790 refactor(entrypoint): enhance Entrypoint interface with detailed comments 2026-02-15 20:08:10 +08:00
yusing
fbb8a1fca4 refactor(middleware): emit OIDC blocked event at specific error points 2026-02-15 20:08:10 +08:00
yusing
af62ac98d3 refactor(middleware): clone middleware definitions before modification
- This change enhances the integrity of middleware configurations by ensuring original definitions remain unchanged.
2026-02-15 20:08:10 +08:00
yusing
cc516d23db refactor(health): allow connection reuse in HTTP pinger
- Commented out the SetConnectionClose method to enable connection reuse for HTTP requests, improving performance.
- This is a follow up commit to be9af03a1e setting MaxConnsPerHost to 1000
2026-02-15 20:08:10 +08:00
yusing
f92e96831c fix(auth): reorder password validation to enhance security against timing attacks
- Always perform bcrypt comparison before checking the username to mitigate potential timing attack vulnerabilities.
2026-02-15 20:08:10 +08:00
yusing
154149b06d refactor: minor styling fixes; deadcode cleanup and correct log level 2026-02-15 20:08:09 +08:00
yusing
35b8a60edb chore(makefile): improve benchmark cleanup and update api types path
Add automatic container cleanup for benchmark target using trap to ensure
containers are torn down after benchmarking completes. Also update the
gen-api-types output directory to src/lib and remove the prettier step.
2026-02-15 17:34:30 +08:00
yusing
d54f0c1411 chore(lint): update golangci-lint configuration
- Exclude gin.Context.Error from errcheck for error handler pattern
- Add godoclint with ignore pattern for internal/api/v1
- Remove gomoddirectives replace-allow-list
- Disable govet fieldalignment check
- Add QF1008 to staticcheck exceptions for embedded field clarity
- Simplify exclusion paths and disable test running
2026-02-15 17:33:17 +08:00
yusing
a9aabc0a20 chore(trunk): add linter configs and update versions
- Add .markdownlint.yaml with prettier-friendly config
- Add .yamllint.yaml with custom rules
- Enable yamllint and markdownlint in trunk.yaml
- Update Go runtime to 1.26.0
- Update linter versions (checkov, golangci-lint2, osv-scanner, trufflehog)
- Enable pre-push and pre-commit hooks
- Update .gitignore to track .trunk/configs directory
2026-02-15 17:31:36 +08:00
yusing
0a139067b8 fix(acl): add logging for unexpected remote address types in TCP and UDP listeners 2026-02-15 17:22:53 +08:00