Default configuration path falls back to the current directory when the home directory cannot be determined
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 76/100
Rechercherichtung
Beginne in pkg/config/localconfig.go bei DefaultConfigDir und DefaultLocalConfigPath und verfolge dann, wie Befehle wie context list die lokale Standardkonfiguration laden. Prüfe, wie mit einem Fehler bei der Ermittlung des Home-Verzeichnisses umgegangen wird und wie das ausgewählte Verhalten sowohl für Lese- als auch für Schreibvorgänge gilt. Fertig, wenn ein Fehler bei der Ermittlung des Home-Verzeichnisses keinen Konfigurationspfad mehr relativ zum aktuellen Verzeichnis erzeugt und die CLI einen klaren Fehler meldet oder einen bewusst gewählten Fallback verwendet.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- Go
- Sterne
- 57
- Forks
- 73
- Ø Merge
- 1 T. 9 Std.
- Gemergte PRs (30 T.)
- 28
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microcks/microcks-cli
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
microcks/microcks-cli#573 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug: YAML parse error in config is silently swallowed, login overwrites all other contextsEvtl. vergeben @Sarthak-Shreshtha01 hat das vor 5 Tagen übernommen. Offencomponent/cli kind/bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
microcks/microcks-cli#572 · 5 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
import-dir uploads secondary artifacts before their primary API definitionEvtl. vergeben @doraem-on hat das vor 12 Tagen übernommen. Offencomponent/cli kind/bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
microcks/microcks-cli#561 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
TEST: `ConnectAndGetToken` Returns Error on Non-200 ResponseEvtl. vergeben @aniket866 hat das vor 15 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
microcks/microcks-cli#554 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Empty `AuthToken` Causes Cryptic JWT Parse ErrorEvtl. vergeben @aniket866 hat das vor 15 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
microcks/microcks-cli#551 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in microcks/microcks-cli
Ähnliche Issues
-
difficulty: easy documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
-
scaleway_lb_frontend: updating a frontend with external_acls = true deletes all scaleway_lb_aclOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
scaleway/terraform-provider-scaleway#4485 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100