-
Notifications
You must be signed in to change notification settings - Fork 707
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
Cabal 3.14.1.0 invokes test binaries with a corrupt (duplicated) environment variable list #10718
Comments
haskell/cabal#10718 breaks the tests.
Hey! Thanks for the report! Presumably, this issue doesn't lead to a failure in any case, does it? I'm asking because it'd be good to understand how severe it is. On the surface it looks rather benign to me. |
It may cause uses of environment variables in tests to behave incorrectly. In the theoretical worst-case scenario, it could lead to security risks, e.g.
The severity of this issue in practice is unclear. The most probable scenario I can think of is that a fragile piece of code that scrubs sensitive data out of environment variables could misbehave due to the duplication, causing credentials to get leaked through, say, logs. A bit of a stretch but not impossible. |
I have written a test and you are right that with 3.14, many duplicates are passed. With 3.12, the |
I see the issue was introduced in ee11ac6 |
This fixes a bug where environment variables were duplicated when running executables. ``` overrideEnv <- fromMaybe [] <$> getEffectiveEnvironment ([("PATH", Just newPath)] ++ envOverrides) let shellEnv = overrideEnv ++ existingEnv ``` Since getEffectiveEnvironment already calls getEnvironment internally, if any overrides are passed then the result is a complete environment. Appending it to the already existing environment results in duplicated environment variables. The fix: * Added getFullEnvironment function to handle the common pattern correctly * Updated code in Bench, Test/ExeV10, Test/LibV09, and Client/Run to use this function In the future it would be good to generalise `getFullEnvironment` further so it can also handle the `addLibraryPath` case, which modifies an environment variable, rather than merely setting or unsetting it. Fixes #10718
Adds a simple test case that identifies and reports duplicate environment variables in the Cabal environment. For issue (#10718)
Adds a simple test case that identifies and reports duplicate environment variables in the Cabal environment. For issue (#10718)
This fixes a bug where environment variables were duplicated when running executables. ``` overrideEnv <- fromMaybe [] <$> getEffectiveEnvironment ([("PATH", Just newPath)] ++ envOverrides) let shellEnv = overrideEnv ++ existingEnv ``` Since getEffectiveEnvironment already calls getEnvironment internally, if any overrides are passed then the result is a complete environment. Appending it to the already existing environment results in duplicated environment variables. The fix: * Added getFullEnvironment function to handle the common pattern correctly * Updated code in Bench, Test/ExeV10, Test/LibV09, and Client/Run to use this function In the future it would be good to generalise `getFullEnvironment` further so it can also handle the `addLibraryPath` case, which modifies an environment variable, rather than merely setting or unsetting it. Fixes #10718
Adds a simple test case that identifies and reports duplicate environment variables in the Cabal environment. For issue (#10718)
This fixes a bug where environment variables were duplicated when running executables. ``` overrideEnv <- fromMaybe [] <$> getEffectiveEnvironment ([("PATH", Just newPath)] ++ envOverrides) let shellEnv = overrideEnv ++ existingEnv ``` Since getEffectiveEnvironment already calls getEnvironment internally, if any overrides are passed then the result is a complete environment. Appending it to the already existing environment results in duplicated environment variables. The fix: * Added getFullEnvironment function to handle the common pattern correctly * Updated code in Bench, Test/ExeV10, Test/LibV09, and Client/Run to use this function In the future it would be good to generalise `getFullEnvironment` further so it can also handle the `addLibraryPath` case, which modifies an environment variable, rather than merely setting or unsetting it. Fixes #10718
Adds a simple test case that identifies and reports duplicate environment variables in the Cabal environment. For issue (#10718)
This fixes a bug where environment variables were duplicated when running executables. ``` overrideEnv <- fromMaybe [] <$> getEffectiveEnvironment ([("PATH", Just newPath)] ++ envOverrides) let shellEnv = overrideEnv ++ existingEnv ``` Since getEffectiveEnvironment already calls getEnvironment internally, if any overrides are passed then the result is a complete environment. Appending it to the already existing environment results in duplicated environment variables. The fix: * Added getFullEnvironment function to handle the common pattern correctly * Updated code in Bench, Test/ExeV10, Test/LibV09, and Client/Run to use this function In the future it would be good to generalise `getFullEnvironment` further so it can also handle the `addLibraryPath` case, which modifies an environment variable, rather than merely setting or unsetting it. Fixes #10718
Adds a simple test case that identifies and reports duplicate environment variables in the Cabal environment. For issue (#10718)
This fixes a bug where environment variables were duplicated when running executables. ``` overrideEnv <- fromMaybe [] <$> getEffectiveEnvironment ([("PATH", Just newPath)] ++ envOverrides) let shellEnv = overrideEnv ++ existingEnv ``` Since getEffectiveEnvironment already calls getEnvironment internally, if any overrides are passed then the result is a complete environment. Appending it to the already existing environment results in duplicated environment variables. The fix: * Added getFullEnvironment function to handle the common pattern correctly * Updated code in Bench, Test/ExeV10, Test/LibV09, and Client/Run to use this function In the future it would be good to generalise `getFullEnvironment` further so it can also handle the `addLibraryPath` case, which modifies an environment variable, rather than merely setting or unsetting it. Fixes #10718
Adds a simple test case that identifies and reports duplicate environment variables in the Cabal environment. For issue (#10718)
Fixed #10827 |
This fixes a bug where environment variables were duplicated when running executables. ``` overrideEnv <- fromMaybe [] <$> getEffectiveEnvironment ([("PATH", Just newPath)] ++ envOverrides) let shellEnv = overrideEnv ++ existingEnv ``` Since getEffectiveEnvironment already calls getEnvironment internally, if any overrides are passed then the result is a complete environment. Appending it to the already existing environment results in duplicated environment variables. The fix: * Added getFullEnvironment function to handle the common pattern correctly * Updated code in Bench, Test/ExeV10, Test/LibV09, and Client/Run to use this function In the future it would be good to generalise `getFullEnvironment` further so it can also handle the `addLibraryPath` case, which modifies an environment variable, rather than merely setting or unsetting it. Fixes #10718
Adds a simple test case that identifies and reports duplicate environment variables in the Cabal environment. For issue (#10718)
Adds a simple test case that identifies and reports duplicate environment variables in the Cabal environment. For issue (#10718)
Describe the bug
cabal 3.14.1.0
invokes test binaries with with an invalid environment variable list that contains duplicate entries.As documented by POSIX: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap08.html
This is causing the
directory
CI tests to fail: https://github.com/haskell/directory/actions/runs/12595046406The bug is not found in
cabal 3.12.1.0
.To Reproduce
$ cabal test
Actual output
Expected behavior
There should not be any duplicates, i.e.
System information
cabal 3.14.1.0
. Not reproducible oncabal 3.12.1.0
.The text was updated successfully, but these errors were encountered: