Skip to content

Commit

Permalink
Restrict commands allowed in interpreter mode
Browse files Browse the repository at this point in the history
Stack interpreter comment annotation allows arbitrary commands to be
written and executed when the file is run. It can lead to confusing
and surprising behavior if mistakes are made in writing a proper
comment.

This change restricts the interpreter mode commands to runghc and
runhaskell. This change moves add-commands to a separate function.

Closes commercialhaskell#1504
  • Loading branch information
harendra-kumar committed Dec 13, 2015
1 parent 8e5b5f3 commit e43d6bf
Show file tree
Hide file tree
Showing 3 changed files with 280 additions and 295 deletions.
4 changes: 4 additions & 0 deletions src/Stack/Docker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Stack.Docker
,CleanupAction(..)
,dockerCleanupCmdName
,dockerCmdName
,dockerHelpOptName
,dockerPullCmdName
,entrypoint
,preventInContainer
Expand Down Expand Up @@ -846,6 +847,9 @@ inContainerEnvVar = stackProgNameUpper ++ "_IN_CONTAINER"
dockerCmdName :: String
dockerCmdName = "docker"

dockerHelpOptName :: String
dockerHelpOptName = dockerCmdName ++ "-help"

-- | Command-line argument for @docker pull@.
dockerPullCmdName :: String
dockerPullCmdName = "pull"
Expand Down
4 changes: 4 additions & 0 deletions src/Stack/Nix.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
module Stack.Nix
(reexecWithOptionalShell
,nixCmdName
,nixHelpOptName
) where

import Control.Applicative
Expand Down Expand Up @@ -117,6 +118,9 @@ inShellEnvVar = concat [map toUpper stackProgName,"_IN_NIXSHELL"]
nixCmdName :: String
nixCmdName = "nix"

nixHelpOptName :: String
nixHelpOptName = nixCmdName ++ "-help"

type M env m =
(MonadIO m
,MonadReader env m
Expand Down
Loading

0 comments on commit e43d6bf

Please sign in to comment.