Skip to content

Add admin VPS console, secure health server, tips import/export and deployment hardening - #76

Merged
gamblecodezcom merged 2 commits into
mainfrom
codex/configure-git-and-update-project-files-z7gjqe
Feb 25, 2026
Merged

Add admin VPS console, secure health server, tips import/export and deployment hardening#76
gamblecodezcom merged 2 commits into
mainfrom
codex/configure-git-and-update-project-files-z7gjqe

Conversation

@gamblecodezcom

@gamblecodezcom gamblecodezcom commented Feb 25, 2026

Copy link
Copy Markdown
Owner

User description

Motivation

  • Improve runtime security and deployability by adding HTTPS health support, safe path validation, and stricter systemd/service defaults.
  • Provide richer admin tooling: a lightweight VPS console (/sshv) with session persistence and safe command execution for on‑VPS maintenance.
  • Make helpful group tips manageable (import/export/overwrite) and more robust when posting to target groups.
  • Standardize packaging and ops files (license, security policy, .env example, prod-run enhancements) for production readiness.

Description

  • Introduces a persistent lightweight admin console feature (/sshv) with per-admin sessions, editor mode, command execution, safety checks, session persistence to data/sshv-sessions.json, and session GC.
  • Adds safe path validation (validateSafePath) and hardens file IO (loadJson, writeFileAtomic, saveJson) to limit file access to the data directory and allowed cert directories.
  • Switches WebApp init-data validation to use WEBAPP_HMAC_KEY from env and rejects missing keys; updates .env.example accordingly.
  • Converts health server to optionally serve HTTPS when HTTPS_KEY_PATH/HTTPS_CERT_PATH are configured and allowed, and adds a request helper requestHealthPayload used by admin health checks; startHealthServer now conditionally creates an HTTPS server.
  • Enhances tips/helpful messages: persist to helpful_messages.json, add import/overwrite via JSON in /tipadd and /tipedit, avoid repeating the last tip, and verify bot permissions before posting to the target group.
  • Adds ephemeral onboarding promo prompt auto-removal (sendEphemeralBonusPrompt) to reduce chat clutter and other UI improvements to persistent admin/user menus and admin-mode visibility toggles (/on/off).
  • Adds a set of registered commands for unknown-command handling, improved command error responses, and a global fallback for stale callback_data buttons.
  • Ops changes: remove Dockerfile, add LICENSE and SECURITY.md, update README deployment notes, enhance prod-run.sh to create runtime files, perform health checks (HTTP/HTTPS), create/own data files, safe permissions, and extend runewager.service with dedicated runewager user and tighter sandboxing options.

Testing

  • Basic runtime smoke: started the bot and verified GET /health returned a 200 JSON payload via the new requestHealthPayload logic (HTTP and HTTPS fallback exercised); health checks succeeded.
  • Manual smoke-tested admin flows: opened persistent admin menu, toggled admin view (/on//off), and exercised /sshv console run/lock/refresh/editor save flows in a controlled environment; session persistence file created in data/.
  • Tips import/export and manager actions were exercised: /tipadd with JSON array (append), /tipedit with JSON overwrite, per-tip enable/disable and scheduler posting permission checks succeeded.
  • No additional automated unit tests were added in this change set; existing runtime behavior was validated via local smoke checks described above.

Codex Task


CodeAnt-AI Description

Fix prod-run env parsing and improve startup health/status reporting

What Changed

  • Corrected .env value parsing to strip Windows CR characters so environment values read reliably.
  • Ensure runtime directories and log files are created before setting ownership and permissions to avoid permission/setup errors.
  • Show service startup status more clearly: detect systemd service state, compute and display the resolved health URL and port, wait for the health endpoint before reporting healthy/unhealthy, and report whether the health port is listening.
  • Logging output now includes explicit health URL, health endpoint result, systemd active state, and port listening status to aid deploy diagnostics.

Impact

✅ Fewer failed deploys due to env parsing errors
✅ Shorter troubleshooting for startup and health-check issues
✅ Clearer service health and port status during deployment

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@codeant-ai

codeant-ai Bot commented Feb 25, 2026

Copy link
Copy Markdown

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai

coderabbitai Bot commented Feb 25, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@gamblecodezcom has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 39 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between d69da45 and a4829e1.

📒 Files selected for processing (1)
  • prod-run.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/configure-git-and-update-project-files-z7gjqe

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gamblecodezcom
gamblecodezcom merged commit 1d4e66e into main Feb 25, 2026
2 checks passed
@gamblecodezcom
gamblecodezcom deleted the codex/configure-git-and-update-project-files-z7gjqe branch February 25, 2026 04:01
@codeant-ai codeant-ai Bot added the size:S This PR changes 10-29 lines, ignoring generated files label Feb 25, 2026
@codeant-ai

codeant-ai Bot commented Feb 25, 2026

Copy link
Copy Markdown

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Insecure HTTPS health probe
    The health-check helper uses curl -k for HTTPS which disables certificate validation. While the server is local, using -k can hide TLS problems and normalize behavior that would otherwise fail on misconfigured certs. Also, the health check and reporting send raw log contents to Telegram which may expose secrets (tokens, PII) in notifications.

  • Env parsing robustness
    read_env_value uses grep -E "^${key}=" which treats key as a regex and can be surprised by special characters, or produce unexpected matches. Also the current pipeline relies on head/cut/sed which can mis-handle keys/values containing = or leading/trailing whitespace. This may return wrong values (including empty), breaking TLS detection and other config-driven behavior.

  • Duplicate health-check logic
    The script contains duplicated blocks that compute SYSTEMD_ACTIVE, HEALTH_URL, HEALTH_PORT, run wait_for_health and test is_port_listening. Having this logic twice increases maintenance burden and can lead to inconsistent outputs if future edits update only one block.

@codeant-ai

codeant-ai Bot commented Feb 25, 2026

Copy link
Copy Markdown

CodeAnt AI finished reviewing your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex size:S This PR changes 10-29 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant