mirror of https://github.com/sobolevn/git-secret
commit
80797bcd46
@ -0,0 +1,34 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "GIT\-SECRET\-CAT" "1" "April 2018" "sobolevn" "git-secret"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBgit\-secret\-cat\fR \- decrypts files passed on command line to stdout
|
||||
.
|
||||
.SH "SYNOPSIS"
|
||||
.
|
||||
.nf
|
||||
|
||||
git secret cat [\-d dir] [\-p password] filename [filenames]
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.SH "DESCRIPTION"
|
||||
\fBgit\-secret\-cat\fR \- Outputs to stdout the contents of the files named on the command line by running \fBgpg \-\-decrypt\fR\. As with \fBgit\-secret\-reveal\fR, it is important to have the paired secret\-key with one of the public\-keys which were used in the encryption\.
|
||||
.
|
||||
.SH "OPTIONS"
|
||||
.
|
||||
.nf
|
||||
|
||||
\-d \- specifies `\-\-homedir` option for the `gpg`, basically use this option if you store your keys in a custom location\.
|
||||
\-p \- specifies password for noinput mode, adds `\-\-passphrase` option for `gpg`\.
|
||||
\-h \- shows help\.
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.SH "MANUAL"
|
||||
Run \fBman git\-secret\-cat\fR to see this note\.
|
||||
.
|
||||
.SH "SEE ALSO"
|
||||
git\-secret\-init(1) \fIhttp://git\-secret\.io/git\-secret\-init\fR, git\-secret\-tell(1) \fIhttp://git\-secret\.io/git\-secret\-tell\fR, git\-secret\-add(1) \fIhttp://git\-secret\.io/git\-secret\-add\fR, git\-secret\-hide(1) \fIhttp://git\-secret\.io/git\-secret\-hide\fR, git\-secret\-reveal(1) \fIhttp://git\-secret\.io/git\-secret\-cat\fR
|
@ -0,0 +1,27 @@
|
||||
git-secret-cat - decrypts files passed on command line to stdout
|
||||
=============================================
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
git secret cat [-d dir] [-p password] filename [filenames]
|
||||
|
||||
|
||||
## DESCRIPTION
|
||||
`git-secret-cat` - Outputs to stdout the contents of the files named on the command line by running `gpg --decrypt`. As with `git-secret-reveal`, it is important to have the paired secret-key with one of the public-keys which were used in the encryption.
|
||||
|
||||
|
||||
## OPTIONS
|
||||
|
||||
-d - specifies `--homedir` option for the `gpg`, basically use this option if you store your keys in a custom location.
|
||||
-p - specifies password for noinput mode, adds `--passphrase` option for `gpg`.
|
||||
-h - shows help.
|
||||
|
||||
|
||||
## MANUAL
|
||||
|
||||
Run `man git-secret-cat` to see this note.
|
||||
|
||||
|
||||
## SEE ALSO
|
||||
|
||||
[git-secret-init(1)](http://git-secret.io/git-secret-init), [git-secret-tell(1)](http://git-secret.io/git-secret-tell), [git-secret-add(1)](http://git-secret.io/git-secret-add), [git-secret-hide(1)](http://git-secret.io/git-secret-hide), [git-secret-reveal(1)](http://git-secret.io/git-secret-cat)
|
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
function cat {
|
||||
local homedir=''
|
||||
local passphrase=''
|
||||
|
||||
OPTIND=1
|
||||
|
||||
while getopts 'hd:p:' opt; do
|
||||
case "$opt" in
|
||||
h) _show_manual_for 'cat';;
|
||||
|
||||
p) passphrase=$OPTARG;;
|
||||
|
||||
d) homedir=$OPTARG;;
|
||||
|
||||
*) _invalid_option_for 'cat';;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND-1))
|
||||
[ "$1" = '--' ] && shift
|
||||
|
||||
_user_required
|
||||
|
||||
# Command logic:
|
||||
|
||||
for line in "$@"
|
||||
do
|
||||
local filename
|
||||
local path
|
||||
|
||||
filename=$(_get_record_filename "$line")
|
||||
path=$(_append_root_path "$filename")
|
||||
|
||||
# The parameters are: filename, write-to-file, force, homedir, passphrase
|
||||
_decrypt "$path" "0" "0" "$homedir" "$passphrase"
|
||||
done
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# shellcheck disable=2034
|
||||
GITSECRET_VERSION='0.2.3'
|
||||
GITSECRET_VERSION='0.2.4'
|
||||
|
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load _test_base
|
||||
|
||||
FILE_TO_HIDE="file_to_hide"
|
||||
FILE_CONTENTS="hidden content юникод"
|
||||
|
||||
FINGERPRINT=""
|
||||
|
||||
|
||||
function setup {
|
||||
FINGERPRINT=$(install_fixture_full_key "$TEST_DEFAULT_USER")
|
||||
|
||||
set_state_initial
|
||||
set_state_git
|
||||
set_state_secret_init
|
||||
set_state_secret_tell "$TEST_DEFAULT_USER"
|
||||
set_state_secret_add "$FILE_TO_HIDE" "$FILE_CONTENTS"
|
||||
set_state_secret_hide
|
||||
}
|
||||
|
||||
|
||||
function teardown {
|
||||
uninstall_fixture_full_key "$TEST_DEFAULT_USER" "$FINGERPRINT"
|
||||
unset_current_state
|
||||
}
|
||||
|
||||
|
||||
@test "run 'cat' with password argument" {
|
||||
local password=$(test_user_password "$TEST_DEFAULT_USER")
|
||||
run git secret cat -d "$TEST_GPG_HOMEDIR" -p "$password" "$FILE_TO_HIDE"
|
||||
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
# $output is the output from 'git secret cat' above
|
||||
# note that currently content may differ by a newline
|
||||
[ "$FILE_CONTENTS" == "$output" ]
|
||||
}
|
||||
|
||||
@test "run 'cat' with wrong filename" {
|
||||
run git secret reveal -d "$TEST_GPG_HOMEDIR" -p "$password" NO_SUCH_FILE
|
||||
[ "$status" -eq 2 ]
|
||||
}
|
||||
|
Loading…
Reference in New Issue