Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mdunnio/hs-vault-tool
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: bitnomial/hs-vault-tool
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.

Commits on Feb 15, 2018

  1. Copy the full SHA
    08c879f View commit details

Commits on Mar 11, 2018

  1. Changed VaultAppRoleId and VaultAppRoleSecretId to Text instead o…

    …f ByteString. Added To/FromJSON. Added addtional types.
    mdunnio committed Mar 11, 2018
    Copy the full SHA
    78bdc8a View commit details
  2. Copy the full SHA
    e07ebbb View commit details
  3. Merge pull request #1 from michaelsdunn1/approle-login

    Added AppRole types and functions to allow connecting to vault via Ap…
    bitc authored Mar 11, 2018
    Copy the full SHA
    4986b43 View commit details
  4. Version 0.0.0.4

    bitc committed Mar 11, 2018
    Copy the full SHA
    4a6f78e View commit details
  5. Copy the full SHA
    ac43bb8 View commit details
  6. Copy the full SHA
    f3ddafc View commit details
  7. Version 0.1.0.0

    bitc committed Mar 11, 2018
    Copy the full SHA
    3215b97 View commit details

Commits on Aug 2, 2018

  1. Copy the full SHA
    22b50c6 View commit details

Commits on Aug 5, 2018

  1. Merge pull request bitc#2 from ChristopherDavenport/updateBoundsAndAd…

    …dStackInit
    
    Update base Upper Bound to 5 and Allow for Stack Use
    bitc authored Aug 5, 2018
    Copy the full SHA
    31bf280 View commit details

Commits on Aug 8, 2018

  1. Copy the full SHA
    f73aad7 View commit details
  2. merge

    lukehoersten committed Aug 8, 2018
    Copy the full SHA
    bd78b96 View commit details

Commits on Aug 20, 2018

  1. Copy the full SHA
    4053861 View commit details

Commits on Sep 4, 2018

  1. Support Vault 0.10

    CYBAI committed Sep 4, 2018
    Copy the full SHA
    8f49225 View commit details

Commits on Jan 19, 2019

  1. Merge pull request bitc#4 from herp-inc/vault-10

    Support Vault 0.10
    bitc authored Jan 19, 2019
    Copy the full SHA
    24492b2 View commit details

Commits on May 1, 2019

  1. Version 0.1.0.1

    bitc committed May 1, 2019
    Copy the full SHA
    a474f11 View commit details

Commits on Oct 28, 2021

  1. Refactor to allow for different secret engines

    Jason Davidson committed Oct 28, 2021
    Copy the full SHA
    5a23596 View commit details
  2. undo format changes

    Jason Davidson committed Oct 28, 2021
    Copy the full SHA
    e210a75 View commit details

Commits on Nov 2, 2021

  1. Apply PR suggestions

    Jason Davidson committed Nov 2, 2021
    Copy the full SHA
    dac4b0b View commit details

Commits on Nov 3, 2021

  1. Refactor VaultConnection

    Jason Davidson committed Nov 3, 2021
    Copy the full SHA
    89b7668 View commit details

Commits on Nov 4, 2021

  1. Hide VaultConnection data constructors and expose constructor functio…

    …ns instead
    Jason Davidson committed Nov 4, 2021
    Copy the full SHA
    2bf99a3 View commit details
  2. Copy the full SHA
    7558da4 View commit details

Commits on Nov 8, 2021

  1. Simplifications and comments

    Jason Davidson committed Nov 8, 2021
    Copy the full SHA
    2c42064 View commit details
  2. Add test for vaultReadVersion

    Jason Davidson committed Nov 8, 2021
    Copy the full SHA
    b2b62ae View commit details
  3. Merge pull request #1 from viking66/refactor

    Refactor to allow for different secret engines
    viking66 authored Nov 8, 2021
    Copy the full SHA
    beb4327 View commit details

Commits on Nov 9, 2021

  1. Merge remote-tracking branch 'upstream/master' into jd-refactor

    # Conflicts:
    #	stack.yaml
    #	vault-tool-server/vault-tool-server.cabal
    Jason Davidson committed Nov 9, 2021
    Copy the full SHA
    7644822 View commit details
  2. Bump major version

    Jason Davidson committed Nov 9, 2021
    Copy the full SHA
    187c8d1 View commit details
  3. Merge pull request #1 from bitnomial/jd-refactor

    Refactor to make it easier to add new secret engines
    wraithm authored Nov 9, 2021
    Copy the full SHA
    c857d2f View commit details

Commits on Nov 12, 2021

  1. Add TOTP API

    Jason Davidson committed Nov 12, 2021
    Copy the full SHA
    57d1d2b View commit details

Commits on Nov 15, 2021

  1. Apply hlint suggestions

    Jason Davidson committed Nov 15, 2021
    Copy the full SHA
    1d6c9d3 View commit details
  2. Add smart constructor for GenerateKeyRequest

    Jason Davidson committed Nov 15, 2021
    Copy the full SHA
    0854456 View commit details
  3. Improve GeneratedKey comments

    Jason Davidson committed Nov 15, 2021
    Copy the full SHA
    9e02d47 View commit details
  4. Add code comments and hide Data.Aeson.Utils

    Jason Davidson committed Nov 15, 2021
    Copy the full SHA
    a126490 View commit details

Commits on Nov 16, 2021

  1. Document the barcode data URI

    Jason Davidson committed Nov 16, 2021
    Copy the full SHA
    9424ad8 View commit details
  2. Merge pull request bitc#2 from bitnomial/jd-totp-lib

    Add TOTP module to vault library
    wraithm authored Nov 16, 2021
    Copy the full SHA
    f9c7df0 View commit details

Commits on May 13, 2022

  1. Copy the full SHA
    95e5f01 View commit details
  2. Merge pull request bitc#3 from bitnomial/update-stack-lts

    Updated stack lts, updated impacted code
    wraithm authored May 13, 2022
    Copy the full SHA
    a8e8289 View commit details

Commits on Aug 24, 2024

  1. Copy the full SHA
    ae131c8 View commit details
  2. Add GitHub Actions CI

    cdepillabout committed Aug 24, 2024
    Copy the full SHA
    d18802d View commit details
  3. Copy the full SHA
    6259bd9 View commit details
  4. Copy the full SHA
    4be4a15 View commit details
  5. Merge pull request bitc#4 from bitnomial/update-lts-22

    Update to LTS-22 / GHC-9.6 and add CI
    wraithm authored Aug 24, 2024
    Copy the full SHA
    24ba939 View commit details

Commits on Jan 10, 2025

  1. Copy the full SHA
    9c1fc02 View commit details
  2. Copy the full SHA
    91d64d7 View commit details
84 changes: 84 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: CI

on:
pull_request:
push:
branches: [master]

jobs:
cabal:
name: cabal / ghc-${{ matrix.ghc }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
# - macOS-latest
cabal:
- "latest"
ghc:
- "9.2.8"
- "9.4.8"
- "9.6.3"

steps:
- uses: actions/checkout@v4

- uses: haskell-actions/setup@v2
id: setup-haskell-cabal
name: Setup Haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}

- uses: actions/cache@v3
name: Cache cabal-store
with:
path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
key: ${{ matrix.os }}-${{ matrix.ghc }}-cabal

- name: Build
run: |
cabal update
cabal build all --enable-tests --enable-benchmarks --write-ghc-environment-files=always
# TODO: Tests require the `vault` executable to be available.
# - name: Test
# run: |
# cabal test all --enable-tests --enable-benchmarks --write-ghc-environment-files=always

stack:
name: stack ${{ matrix.resolver }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
# - macOS-latest
stack: ["latest"]
resolver:
- "--stack-yaml ./stack.yaml"

steps:
- uses: actions/checkout@v4

- uses: haskell-actions/setup@v2
name: Setup Haskell Stack
with:
stack-version: ${{ matrix.stack }}
enable-stack: true

- uses: actions/cache@v3
name: Cache ~/.stack
with:
path: ~/.stack
key: ${{ matrix.os }}-stack-${{ matrix.resolver }}

- name: Build
run: |
stack build --test --bench --no-run-tests --no-run-benchmarks
# TODO: Tests require the `vault` executable to be available.
# - name: Test
# run: |
# stack test --bench --no-run-benchmarks
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist-newstyle/
dist/
.stack-work/
2 changes: 2 additions & 0 deletions .hgignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
syntax: regexp
\.stack-work/
6 changes: 6 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resolver: lts-23.3
flags: {}
packages:
- vault-tool
- vault-tool-server
extra-deps: []
12 changes: 12 additions & 0 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file was autogenerated by Stack.
# You should not edit this file by hand.
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files

packages: []
snapshots:
- completed:
sha256: dd89d2322cb5af74c6ab9d96c0c5f6c8e6653e0c991d619b4bb141a49cb98668
size: 679282
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/23/3.yaml
original: lts-23.3
54 changes: 37 additions & 17 deletions vault-tool-server/src/Network/VaultTool/VaultServerProcess.hs
Original file line number Diff line number Diff line change
@@ -19,23 +19,43 @@ module Network.VaultTool.VaultServerProcess
) where

import Control.Concurrent (threadDelay)
import Control.Concurrent.Async
import Control.Concurrent.Async (waitAnyCancel, withAsync)
import Control.Exception (Exception, IOException, catches, Handler(Handler), bracket, bracketOnError, throwIO, try)
import Control.Monad (forever)
import Data.Aeson
import Data.Aeson (ToJSON, Value, (.=), eitherDecode', encode, object, toJSON)
import Data.Maybe (fromMaybe)
import Data.Text (Text)
import Network.HTTP.Client (HttpException)
import System.Exit (ExitCode)
import System.FilePath ((</>))
import System.IO (Handle, hClose)
import System.IO.Temp
import System.Process
import System.IO.Temp (withSystemTempDirectory)
import System.Process (
ProcessHandle,
StdStream (..),
close_fds,
createProcess,
env,
getProcessExitCode,
proc,
std_err,
std_in,
std_out,
terminateProcess,
waitForProcess,
)
import qualified Data.ByteString.Lazy as BL
import qualified Data.Text as T
import qualified Data.Text.IO as T

import Network.VaultTool
import Network.VaultTool (
VaultAddress (..),
VaultException,
VaultUnsealKey (..),
unauthenticatedVaultConnection,
vaultHealth,
defaultManager,
)

-- | The ""backend"" section of the Vault server configuration.
--
@@ -101,8 +121,7 @@ readVaultBackendConfig file = do
-- | File should have one line per key (blank lines are ignored)
readVaultUnsealKeys :: FilePath -> IO [VaultUnsealKey]
readVaultUnsealKeys file =
T.readFile file >>=
(pure . map VaultUnsealKey . (filter (not . T.null)) . map T.strip . T.lines)
map VaultUnsealKey . filter (not . T.null) . map T.strip . T.lines <$> T.readFile file

withVaultConfigFile :: VaultConfig -> (FilePath -> IO a) -> IO a
withVaultConfigFile vaultConfig action = do
@@ -119,18 +138,18 @@ data VaultServerProcess = VaultServerProcess
}

data VaultServerLaunchException
= VaultServerLaunchException_VaultStartTimeout
| VaultServerLaunchException_ConnectTimeout
| VaultServerLaunchException_ExecFailure IOException
| VaultServerLaunchException_ProcessFailure ExitCode Text
= VaultStartTimeout
| ConnectTimeout
| ExecFailure IOException
| ProcessFailure ExitCode Text
deriving (Show, Eq)

instance Exception VaultServerLaunchException

withVaultServerProcess :: Maybe FilePath -> FilePath -> VaultAddress -> IO a -> IO a
withVaultServerProcess mbVaultExe vaultConfigFile addr act = do
bracket (launchVaultServerProcess mbVaultExe vaultConfigFile addr)
(shutdownVaultServerProcess)
shutdownVaultServerProcess
(const act)

launchVaultServerProcess :: Maybe FilePath -> FilePath -> VaultAddress -> IO VaultServerProcess
@@ -147,19 +166,19 @@ launchVaultServerProcess mbVaultExe vaultConfigFile addr = do
vaultExe = fromMaybe "vault" mbVaultExe
waitUntilRunningThread stdoutH = do
withAsync (waitUntilVaultStarted stdoutH) $ \startA -> do
withAsync (timeout vaultStartTimeoutMilliseconds VaultServerLaunchException_VaultStartTimeout) $ \timeoutA -> do
withAsync (timeout vaultStartTimeoutMilliseconds VaultStartTimeout) $ \timeoutA -> do
_ <- waitAnyCancel [startA, timeoutA]
pure ()
withAsync waitUntilVaultConnect $ \connectA -> do
withAsync (timeout vaultConnectTimeoutMilliseconds VaultServerLaunchException_ConnectTimeout) $ \timeoutA -> do
withAsync (timeout vaultConnectTimeoutMilliseconds ConnectTimeout) $ \timeoutA -> do
_ <- waitAnyCancel [connectA, timeoutA]
pure ()
checkProcessFailureThread vs = do
mbExitCode <- getProcessExitCode (vs_processHandle vs)
case mbExitCode of
Just exitCode -> do
stderrText <- T.hGetContents (vs_stderrH vs)
throwIO $ VaultServerLaunchException_ProcessFailure exitCode stderrText
throwIO $ ProcessFailure exitCode stderrText
Nothing -> do
threadDelay (checkExitedSnoozeMilliseconds * 1000)
checkProcessFailureThread vs
@@ -200,7 +219,7 @@ execProcess vaultExe vaultConfigFile = do
, close_fds = True
}
case tryResult of
Left ex -> throwIO $ VaultServerLaunchException_ExecFailure ex
Left ex -> throwIO $ ExecFailure ex
Right (Just stdinH, Just stdoutH, Just stderrH, processHandle) ->
pure VaultServerProcess
{ vs_processHandle = processHandle
@@ -221,7 +240,8 @@ shutdownVaultServerProcess vs = do

vaultIsRunning :: VaultAddress -> IO Bool
vaultIsRunning addr = do
(vaultHealth addr >> pure True) `catches`
conn <- flip unauthenticatedVaultConnection addr <$> defaultManager
(True <$ vaultHealth conn) `catches`
[ Handler $ \(_ :: HttpException) -> pure False
, Handler $ \(_ :: VaultException) -> pure False
]
Loading