Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/config-file-boundary-policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@diginodes/stellarforge-cli': patch
---

Harden project configuration loading so reads stay on an inspected regular file inside the project root, document the portable non-secret permission policy, and add deterministic coverage for unreadable files and symlink boundaries.
2 changes: 1 addition & 1 deletion docs/reference/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ Before the Stellar CLI deployment subprocess starts, `stellarforge deploy` runs
- the generated Wasm artifact exists, is readable, and is not stale;
- the configuration file, if present, is well formed.

Preflight is validation and reporting only. It does not invoke a deployment transaction, does not spawn subprocesses, and does not contact any network endpoint.
Preflight is validation and reporting only. It does not invoke a deployment transaction, does not spawn subprocesses, and does not contact any network endpoint. Pass `--preflight` to stop after reporting the checks instead of starting the deployment.

Preflight output never prints private keys, seed phrases, tokens, account StrKeys, identity alias values, or other sensitive configuration values. Failed checks include remediation steps, for example:

Expand Down
17 changes: 14 additions & 3 deletions docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,26 @@ overrides only the identity.

The file must:

- live at the project root;
- be a regular file rather than a symbolic link;
- live at the project root under the exact name `stellarforge.config.json`;
- be a regular file rather than a symbolic link, including links whose target is inside the project root;
- be readable by the current process;
- be no larger than 64 KiB;
- be encoded as UTF-8 (a single leading UTF-8 byte-order mark is tolerated);
- contain valid JSON with no duplicate object keys;
- contain no duplicate object keys at any nesting level (escaped-equivalent spellings are treated as the same key);
- contain only supported schema fields.

Validation failures are designed to be actionable without echoing raw file contents or sensitive values.
The loader reads only the opened regular file descriptor and rechecks the project-root path before reading. A symlink substituted between inspection and read is rejected; the config is never read through a link that could escape the project boundary.

Validation failures are designed to be actionable without echoing raw file contents, paths, OS error text, or sensitive values.

### File permissions and platform behavior

This configuration file is non-secret by design: it holds only a schema version, a network name, and an identity alias. StellarForge therefore does not reject or warn about permissive file modes or unusual ownership, because those are not security signals for this file.

- POSIX permission and ownership bits are ignored on every supported platform, including Windows where those bits are synthetic. Mode `0666`, group ownership, and root ownership are accepted.
- A file that the current process cannot read produces the validation error `Unable to inspect stellarforge.config.json.` (exit code 2). The message never includes the path, the OS error, or file contents.
- StellarForge never changes file permissions or ownership and never attempts privilege escalation. If a config file cannot be read, adjust it outside the CLI.

If the file is rejected, see [Troubleshooting](troubleshooting.md#configuration-file-is-rejected). For deployment settings, see [Deployment network is required](troubleshooting.md#deployment-network-is-required) and [Deployment identity is rejected](troubleshooting.md#deployment-identity-is-rejected).

Expand Down
14 changes: 7 additions & 7 deletions docs/reference/exit-codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ StellarForge CLI uses predictable process exit codes so humans, scripts, and CI

| Exit code | Category | Meaning |
|---:|---------|---------|
| `0` x Success | The requested CLI operation completed successfully. |
| `1` x Unexpected failure | An unclassified exception reached the top-level CLI boundary. |
| `2` x Validation / usage failure | User input, command syntax, options, arguments, or other validated input was invalid. |
| `3` x Subprocess failure | A required external process or tool failed. |
| `4` x Internal failure | StellarForge detected a known internal failure condition that should not expose implementation details to the user. |
| `5` x Diagnostic failure | A diagnostic command completed normally but one or more required checks failed; used by `doctor` (environment health) and `stellarforge validate` (local project requirements). |
| `130` x Cancellation | The operation was interrupted by the user (SIGINT or equivalent) and stopped before completion. |
| `0` | Success | The requested CLI operation completed successfully. |
| `1` | Unexpected failure | An unclassified exception reached the top-level CLI boundary. |
| `2` | Validation / usage failure | User input, command syntax, options, arguments, or other validated input was invalid. |
| `3` | Subprocess failure | A required external process or tool failed. |
| `4` | Internal failure | StellarForge detected a known internal failure condition that should not expose implementation details to the user. |
| `5` | Diagnostic failure | A diagnostic command completed normally but one or more required checks failed; used by `doctor` (environment health) and `stellarforge validate` (local project requirements). |
| `130` | Cancellation | The operation was interrupted by the user (SIGINT or equivalent) and stopped before completion. |


These values are part of the CLI contract and should not be changed casually. New stable categories require deliberate review and documentation.
Expand Down
3 changes: 2 additions & 1 deletion docs/reference/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ StellarForge code should expose platform differences deliberately instead of hid
- Cargo subprocesses use `cargo.exe`;
- Stellar deployment subprocesses use `stellar.exe`;
- path tests must use Node path APIs rather than assuming POSIX separators;
- commands must not rely on Bash being the default shell.
- commands must not rely on Bash being the default shell;
- POSIX permission and ownership bits reported for files are synthetic, so config loading ignores them on every platform instead of applying platform-dependent rules or changing file permissions.

### macOS and Linux

Expand Down
10 changes: 9 additions & 1 deletion docs/reference/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This page covers common failures in the implemented StellarForge CLI MVP.
| Deployment | Network or identity is missing or rejected, Mainnet or Futurenet is refused, or Stellar CLI fails | [Deployment network is required](#deployment-network-is-required), [Deployment rejects Mainnet or Futurenet](#deployment-rejects-mainnet-or-futurenet), [Deployment identity is rejected](#deployment-identity-is-rejected), and [Stellar CLI deployment fails](#stellar-cli-deployment-fails) |
| Unexpected failure | A generic error message with exit code `1` or `4` | [Unexpected or internal failure](#unexpected-or-internal-failure) |
| Sensitive data | A secret appeared in output or in a report | [Sensitive information appeared in a failure](#sensitive-information-appeared-in-a-failure) |
| Cancellation | A command was interrupted and exited with code `130` | [Cancelled operation](#cancelled-operation) |

### Look up by exit code

Expand All @@ -25,6 +26,7 @@ This page covers common failures in the implemented StellarForge CLI MVP.
| `3` | A subprocess failed: [`dev`](#stellarforge-dev-says-no-supported-script-exists), [`test`](#stellarforge-test-cannot-find-a-workflow), or [Stellar CLI deployment](#stellar-cli-deployment-fails) |
| `5` | [`stellarforge doctor` reports failures](#stellarforge-doctor-reports-failures) |
| `1` or `4` | [Unexpected or internal failure](#unexpected-or-internal-failure) |
| `130` | [Cancelled operation](#cancelled-operation) |

Exit code meanings are defined in [Exit Codes](exit-codes.md). Related references: [Installation](../guides/installation.md), [Quick Start](../guides/quick-start.md), [Command Reference](commands.md), [Configuration](configuration.md), and [Platform Support](platform-support.md).

Expand Down Expand Up @@ -137,7 +139,9 @@ stellarforge.config.json

and live at the project root.

It must be a regular non-symlink file, no larger than 64 KiB, encoded as UTF-8 (a single leading UTF-8 byte-order mark is tolerated), and contain valid JSON with schema version `1`, and it must not contain duplicate object keys at any nesting level (escaped-equivalent spellings are treated as the same key).
It must be a regular non-symlink file, no larger than 64 KiB, encoded as UTF-8 (a single leading UTF-8 byte-order mark is tolerated), and contain valid JSON with schema version `1`, and it must not contain duplicate object keys at any nesting level (escaped-equivalent spellings are treated as the same key). Symbolic links are never followed, including links that point back inside the project.

If the file cannot be read, the CLI reports `Unable to inspect stellarforge.config.json.` without echoing the path or the system error. Fix access outside StellarForge: the CLI never changes permissions or ownership. Permissive POSIX modes are accepted because this file contains no secrets, and Windows does not expose meaningful POSIX permission semantics.

Supported fields are only:

Expand Down Expand Up @@ -247,6 +251,10 @@ StellarForge errors are designed not to render raw secrets. Do not paste private

If you believe a secret disclosure is caused by a vulnerability, follow [SECURITY.md](../../SECURITY.md) instead of opening a public issue.

## Cancelled operation

A command that receives an interrupt (SIGINT, or SIGBREAK where supported) stops gracefully and exits with code `130`. Cleanup runs first: `dev` stops its watcher and child processes, `test` and `deploy` wait for the in-flight subprocess, and `new` rolls back partially generated files. A second interrupt during cleanup exits immediately with the same code. Cancellation messages go to stderr and never report success. See [Exit Codes](exit-codes.md#stable-baseline).

## Still blocked?

Collect only non-sensitive information:
Expand Down
13 changes: 13 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,17 @@ export default tseslint.config(
'@typescript-eslint/no-explicit-any': 'error',
},
},
{
files: ['templates/**/*.js'],
languageOptions: {
globals: {
clearInterval: 'readonly',
clearTimeout: 'readonly',
process: 'readonly',
setInterval: 'readonly',
setTimeout: 'readonly',
URL: 'readonly',
},
},
},
);
Loading
Loading