Default configuration path falls back to the current directory when the home directory cannot be determined
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
pkg/config/localconfig.goのDefaultConfigDirとDefaultLocalConfigPathから始め、context listなどのコマンドがデフォルトのローカル設定をどのように読み込むかを追ってください。ホームディレクトリの検索エラーがどのように処理されるか、また選択した動作が読み取りと書き込みの両方にどのように適用されるかを確認してください。ホームディレクトリの検索に失敗しても、現在のディレクトリを基準とする設定パスが生成されず、CLIが明確なエラーを報告するか、意図的に選ばれたフォールバックを使うようになれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
When MICROCKS_CONFIG_DIR is unset and the CLI cannot determine the user's home directory, DefaultConfigDir in pkg/config/localconfig.go discards the error returned by getHomeDir() and returns an empty string with no error.
DefaultLocalConfigPath then constructs the configuration path using this empty directory. Instead of returning an error or selecting a documented fallback, the resulting path can be the relative path config.
This creates an unexpected dependency on the process's current working directory. Commands that load or save local configuration may consequently resolve the configuration file relative to whichever directory the CLI was launched from, rather than using a stable, user-specific configuration directory.
Depending on the command and its execution path, this could cause the CLI to read an unintended file, create configuration in an unexpected location, or fail in a way that obscures the underlying problem. If the relative file contains authentication data, using an unintended location could also create a credential-handling risk.
Expected behavior
The CLI should not silently accept an empty configuration directory after home-directory resolution fails.
It should either:
Return a clear, actionable error indicating that the home directory could not be determined; or
Use a documented and deliberate fallback location that does not unexpectedly resolve to a file in the current working directory.
The selected behavior should be consistent for commands that read and write the default configuration.
Actual behavior
The error from getHomeDir() is discarded, and DefaultConfigDir returns an empty path with a nil error. DefaultLocalConfigPath can consequently resolve to the relative path config, allowing subsequent file operations to depend on the current working directory.
How to Reproduce?
-
Build the CLI or a small diagnostic program against the affected source.
-
Create and switch to a temporary working directory that does not contain an existing configuration file.
-
Unset MICROCKS_CONFIG_DIR and the relevant home-directory environment variables. On Windows, unset USERPROFILE; on Unix-like systems, unset HOME.
-
Call config.DefaultLocalConfigPath() or run a CLI command that loads the default local configuration, such as context list.
-
Inspect the resolved path and the command's behavior.
For a direct path-resolution check, call DefaultLocalConfigPath() and print both its returned path and error. Under the affected conditions, the expected reproduction is a relative path such as config with no reported error.
To verify actual file access separately, place a harmless, deliberately malformed test configuration file named config in the temporary working directory and run a command that loads the local configuration. A parsing error can help demonstrate that the relative file is being read. Do not use real configuration files or credentials for this test.
Microcks version or git rev
main
Install method (docker-compose, helm chart, operator, docker-desktop extension,...)
CLI
Additional information
No response
- 主要言語
- Go
- スター
- 58
- フォーク
- 72
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 27
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microcks/microcks-cli のほかの issue
-
microcks test exits with code 1 (contract failure) instead of code 11 (connection) when polling loop times out対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンcomponent/cli kind/bug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
microcks/microcks-cli#573 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
bug: YAML parse error in config is silently swallowed, login overwrites all other contexts対応中かも @Sarthak-Shreshtha01 が 7 日前に担当しました。 オープンcomponent/cli kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
microcks/microcks-cli#572 · コメント 6 件 ·
メンテナーはふだん 1 日以内に返信
-
import-dir uploads secondary artifacts before their primary API definition対応中かも @doraem-on が 14 日前に担当しました。 オープンcomponent/cli kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
microcks/microcks-cli#561 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
TEST: `ConnectAndGetToken` Returns Error on Non-200 Response対応中かも @aniket866 が 17 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
microcks/microcks-cli#554 ·
メンテナーはふだん 1 日以内に返信
-
Empty `AuthToken` Causes Cryptic JWT Parse Error対応中かも @aniket866 が 17 日前に担当しました。 オープンcomponent/connectors kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
microcks/microcks-cli#551 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
microcks/microcks-cli の issue をすべて見る
似ている issue
-
area: watch bug priority: low
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
mariadb-operator/mariadb-operator#1962 ·
メンテナーはふだん 1 日以内に返信
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
eugenioenko/ttt#919 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
QuantumNous/new-api#7839 ·
メンテナーはふだん 1 日以内に返信
-
bug needs-triage service/costoptimizationhub
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
hashicorp/terraform-provider-aws#50507 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信