-
Notifications
You must be signed in to change notification settings - Fork 0
fix keytar interop, security hardening, refactoring #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # MainWP Control CLI — Environment Variables | ||
| # Copy to .env or export in your shell profile. | ||
|
|
||
| # ─── Dashboard Credentials ─────────────────────────────────────────── | ||
| # Application password for Dashboard authentication. | ||
| # Required when OS keychain (keytar) is unavailable (CI, containers). | ||
| # MAINWP_APP_PASSWORD= | ||
|
|
||
| # Set to 1 to skip loading keytar (OS keychain). Useful in CI/containers | ||
| # where native modules are unavailable. Falls back to MAINWP_APP_PASSWORD. | ||
| # MAINWPCTL_NO_KEYTAR=1 | ||
|
|
||
| # ─── Network ───────────────────────────────────────────────────────── | ||
| # Allow insecure HTTP connections (not recommended for production). | ||
| # MAINWP_ALLOW_HTTP=1 | ||
|
|
||
| # ─── LLM Provider (for chat mode) ──────────────────────────────────── | ||
| # Provider name: openai, anthropic, gemini, openrouter, local | ||
| # MAINWP_LLM_PROVIDER= | ||
|
|
||
| # Model override (e.g., gpt-4o, claude-sonnet-4-20250514, gemini-pro) | ||
| # MAINWP_LLM_MODEL= | ||
|
|
||
| # Generic LLM API key (provider auto-detected). Prefer provider-specific vars below. | ||
| # MAINWP_LLM_API_KEY= | ||
|
|
||
| # Provider-specific API keys (set the one for your provider): | ||
| # OPENAI_API_KEY= | ||
| # ANTHROPIC_API_KEY= | ||
| # GOOGLE_API_KEY= | ||
| # OPENROUTER_API_KEY= | ||
| # LOCAL_LLM_API_KEY= | ||
| # LOCAL_LLM_URL=http://localhost:11434/v1 | ||
|
|
||
| # ─── Output & Debug ────────────────────────────────────────────────── | ||
| # Disable colored output (https://no-color.org/) | ||
| # NO_COLOR=1 | ||
|
|
||
| # Enable debug output | ||
| # DEBUG=1 | ||
|
|
||
| # ─── Paths ─────────────────────────────────────────────────────────── | ||
| # Override config directory (default: ~/.config/mainwpctl) | ||
| # XDG_CONFIG_HOME= | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // Shared entrypoint setup: SIGPIPE handling and clean exit for native addons. | ||
|
|
||
| // SIGPIPE: exit cleanly when piped to `head`, `grep -q`, etc. | ||
| process.on('SIGPIPE', () => process.exit(0)); | ||
|
|
||
| // Force exit to prevent native addon handles (e.g. keytar) from keeping | ||
| // the process alive. Drain stdout/stderr first to avoid truncating piped output. | ||
| const drain = (s) => new Promise((resolve) => s.write('', resolve)); | ||
| export async function drainAndExit() { | ||
| await Promise.all([drain(process.stdout), drain(process.stderr)]); | ||
| process.exit(process.exitCode ?? 0); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: mainwp/mainwp-control
Length of output: 47
🏁 Script executed:
cat -n package.json | head -50Repository: mainwp/mainwp-control
Length of output: 1854
🏁 Script executed:
Repository: mainwp/mainwp-control
Length of output: 70
🏁 Script executed:
Repository: mainwp/mainwp-control
Length of output: 2794
🏁 Script executed:
Repository: mainwp/mainwp-control
Length of output: 280
Reword
.env.example— the CLI does not auto-load.envfiles.Copying to
.envwill not work; the entrypoint (bin/run.js) uses only oclif's execute function with no dotenv loader. Users following the instruction will populate.envand then encounter missing credentials without understanding why. Either add a dotenv loader to the CLI bootstrap, or reword the template to clarify it's only a reference—credentials must be exported manually or set in CI/shell profiles.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skipping this one. The
.env.exampleheader already says "Copy to .env or export in your shell profile." That is standard convention for env example files. Adding a dotenv loader would mean pulling in a new dependency for something oclif does not use, and the current wording is accurate: the CLI does not auto-load.envfiles. Users who want that can add dotenv themselves.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dennisdornon, that's fair — the "export in your shell profile" phrasing is the standard convention for.env.examplefiles used purely as documentation references, and avoiding a dotenv dependency for a CLI entrypoint that doesn't need it is a reasonable call. I'll note this for future reviews.✏️ Learnings added
🧠 Learnings used