sim
sim copied to clipboard
feat(api): add version endpoint for instance identification
Summary
- Add GET /api/version endpoint that returns version information
- Returns app version, name, build time, git commit, and environment
- Helps identify the version of a running Sim Studio instance
Test plan
- [ ] Manual testing with
curl /api/version
Fixes #2014
@majiayu000 is attempting to deploy a commit to the Sim Team on Vercel.
A member of the Team first needs to authorize it.
Greptile Summary
Adds a new version endpoint that returns instance identification information including app version, build time, and git commit hash.
Key Changes:
- New
GET /api/versionendpoint returns version metadata without authentication - Network policy updated to support custom egress rules for realtime service
- Endpoint uses
force-dynamicto prevent caching
Security Consideration:
- Exposing
NODE_ENVin the response reveals environment details that could aid reconnaissance attacks
Confidence Score: 4/5
- This PR is safe to merge with one security consideration to address
- The implementation is straightforward and adds useful functionality. The endpoint correctly uses
force-dynamicto prevent caching. However, exposingNODE_ENVpresents a minor security concern by revealing the environment type, which could aid attackers in reconnaissance. The network policy change is safe and follows established patterns. - Review
apps/sim/app/api/version/route.tsto consider removingnodeEnvfrom the response
Important Files Changed
| Filename | Overview |
|---|---|
| apps/sim/app/api/version/route.ts | New version endpoint that exposes app version, build time, git commit, and environment - potential information disclosure concern with nodeEnv |
| helm/sim/templates/networkpolicy.yaml | Added custom egress rule support to realtime service network policy - clean infrastructure improvement |
Sequence Diagram
sequenceDiagram
participant Client
participant API as /api/version
participant Env as Environment Variables
Client->>API: GET /api/version
API->>Env: Read npm_package_version or APP_VERSION
API->>Env: Read BUILD_TIME
API->>Env: Read VERCEL_GIT_COMMIT_SHA or GIT_COMMIT
API->>Env: Read NODE_ENV
Env-->>API: Return environment values
API->>API: Format gitCommit to 7 chars
API-->>Client: Return JSON with version info