Commit graph

17 commits

Author SHA1 Message Date
Snider
d90a5be936 refactor: AX compliance sweep — replace banned stdlib imports with core primitives
Replaced fmt, strings, sort, os, io, sync, encoding/json, path/filepath,
errors, log, reflect with core.Sprintf, core.E, core.Contains, core.Trim,
core.Split, core.Join, core.JoinPath, slices.Sort, c.Fs(), c.Lock(),
core.JSONMarshal, core.ReadAll and other CoreGO v0.8.0 primitives.

Framework boundary exceptions preserved where stdlib types are required
by external interfaces (Gin, net/http, CGo, Wails, bubbletea).

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-13 09:32:00 +01:00
Snider
372326297e fix(pr#2): address CodeRabbit round 2 review findings
Go:
- cache: fix TOCTOU race in get() — re-verify entry pointer under lock before
  evicting to prevent corrupting s.currentBytes and removing a newly-set entry
- bridge: fix writeErrorResponse recorder out of sync — buffer into w.body/
  w.headers and call commit() so Status(), Header(), Size() reflect error response
- bridge: fix ValidateResponse number precision — use json.Decoder+UseNumber for
  initial envelope decode to preserve large integers (matches Validate path)
- ratelimit: fix unreachable credential branches — move X-API-Key and
  Authorization hashing before IP fallback so NAT'd clients are bucketed by key
- openapi: gate cacheSuccessHeaders on sb.CacheEnabled flag, not just method==get
- openapi: use isNilRouteGroup in prepareRouteGroups to catch typed-nil RouteGroup

PHP:
- RateLimitExceededException: remove ad-hoc CORS handling — let framework CORS
  middleware apply correct headers for all responses including errors
- SeoReportService.extractCharset: parse charset token from Content-Type value
  instead of returning the full "text/html; charset=utf-8" string
- SeoReportService: validate IP literals directly with filter_var before DNS
  lookup so ::ffff:127.0.0.1-style hosts don't bypass private-IP checks
- SeoReportService.isPrivateIp: extract isPrivateIpv4 helper; handle
  IPv4-mapped IPv6 (::ffff::/96) by checking embedded IPv4 against private
  ranges; add 0.0.0.0/8 to private range list

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-07 09:11:05 +01:00
Snider
e54dd2e370 fix(pr#2): address CodeRabbit major/critical review findings
Go:
- codegen: pass trimmed specPath to buildArgs instead of raw g.SpecPath
- cmd/sdk: use local resolvedSpecFile to avoid mutating flag variable per-invocation
- export: write to temp file + atomic rename to prevent destination truncation on failure
- openapi: gate effectiveGraphQLPath/SwaggerPath/WSPath/SSEPath on enable flags; use effectiveSwaggerPath in effectiveAuthentikPublicPaths
- cache: reject oversized replacement before mutating LRU state for existing keys
- ratelimit: move setRateLimitHeaders before c.Next() so headers are sent; hash credential headers with SHA-256 to avoid storing raw secrets; prefer validated principal from context
- response_meta: track size separately from body buffer so Size() is accurate after body rewrites and in passthrough mode
- bridge: limit request body reads with http.MaxBytesReader (10 MiB); allow missing data key in ValidateResponse for nil/zero success responses; update recorder status in writeErrorResponse
- pkg/provider/proxy: validate target scheme and host after url.Parse to catch hostless inputs
- cmd_test: snapshot/restore global spec registry in TestAPISpecCmd_Good_RegisteredSpecGroups

PHP:
- HasApiResponses.php, config.php: add declare(strict_types=1)
- RateLimitExceededException: validate Origin against cors.allowed_origins before reflecting in CORS header
- ApiUsageService: import and use Core\Api\Models\ApiKey instead of fully-qualified Mod\ path
- SeoReportService: add SSRF protection (scheme check, private-IP rejection); add .throw() for HTTP error handling; disable automatic redirects

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-07 08:38:41 +01:00
Virgil
ec945970ee docs(api): add AX usage examples
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 07:51:21 +00:00
Virgil
68f5abefd0 fix(api): trim tool bridge tags
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 00:31:38 +00:00
Virgil
00c20ea6e8 refactor(api): streamline ToolBridge iterator snapshots
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 22:38:56 +00:00
Virgil
475027d716 refactor(api): wrap ToolBridge errors
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 21:36:58 +00:00
Virgil
2d1ed133f2 refactor(api): align OpenAPI client with AX principles
Use core-style error wrapping in the OpenAPI client, replace direct spec reads with streamed file I/O, and add compile-time interface assertions for ToolBridge.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 21:32:21 +00:00
Virgil
867221cbb8 fix(api): snapshot tool bridge iterators
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 21:27:19 +00:00
Virgil
0ed1cfa1b1 docs(api): add AX examples to public APIs
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 20:23:41 +00:00
Virgil
5da281c431 feat(bridge): support schema composition keywords
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 18:19:15 +00:00
Virgil
c6034031a3 feat(bridge): enforce additional schema constraints
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 16:50:29 +00:00
Virgil
28f9540fa8 fix(bridge): enforce tool schema enum validation
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 15:54:32 +00:00
Virgil
ac21992623 feat(api): enforce tool schema enums
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 15:46:35 +00:00
Virgil
5d5ca8aa51 feat(api): validate ToolBridge output schemas
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 13:18:10 +00:00
Virgil
6ef194754e feat(bridge): validate tool request bodies 2026-04-01 06:23:58 +00:00
Snider
753812ad57 feat(api): merge go-api + php-api into polyglot repo
Go source at root level (Option B), PHP under src/php/.
Module path: forge.lthn.ai/core/api
Package name: lthn/api

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-14 10:03:29 +00:00