1
0
mirror of https://github.com/docker/docker-credential-helpers.git synced 2026-06-13 16:01:28 +05:30
Commit Graph

544 Commits

Author SHA1 Message Date
CrazyMax 72391b37df pass: properly handle errors in tests
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-05-29 12:02:49 +02:00
CrazyMax d0668939bb pass: exclude tests on windows
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-05-29 12:02:49 +02:00
CrazyMax a51d46e82c ci: set gpg key trust level with import-gpg action
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-05-29 12:02:48 +02:00
CrazyMax ea29253d2a ci: install pass on macOS for testing
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-05-29 12:02:48 +02:00
CrazyMax 90bf5da1c9 wincred: use go build constraint
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-05-29 12:02:48 +02:00
CrazyMax 6a2f53622b secretservice: use go build constraint
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-05-29 12:02:48 +02:00
CrazyMax 9f5511c8d5 osxkeychain: use go build constraint
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-05-29 12:02:48 +02:00
CrazyMax c740b990c2 Merge pull request #287 from thaJeztah/pass_no_interpolate
pass: fix interpolation of $PASSWORD_STORE_DIR, and use os.UserHomeDir()
2023-05-29 12:02:13 +02:00
Sebastiaan van Stijn 372315b138 pass: make home-dir resolution platform agnostic
Use stdlib's os.UserHomeDir() instead of depending only on $HOME. Note that
this does not yet does nss lookups for situations where $HOME / $USERPROFILE
is not set.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-29 08:54:49 +02:00
Sebastiaan van Stijn c8c415f9f7 pass: fix interpolation of $PASSWORD_STORE_DIR
commit a13ff50017 simplified the handling of
env-vars in getPassDir(), but moved interpolation of env-vars to the end
of the function.

As a result, a custom path passed through `$PASSWORD_STORE_DIR` would now
be interpolated, instead of taken as-is. For example;

    PASSWORD_STORE_DIR=$PWD/world

Would now interpolate `$PWD`, instead of using a literal `$PWD`.

This patch changes the logic to only expand env-vars for the default location.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-28 18:42:06 +02:00
Sebastiaan van Stijn a652f8e7e6 Merge pull request #286 from crazy-max/update-readme
readme: install emulators when building with docker
2023-05-28 18:05:09 +02:00
Sebastiaan van Stijn 2860ca4b4d Merge pull request #283 from crazy-max/fix-osx-min-version
osxkeychain: match min macos version for xx
2023-05-28 18:00:17 +02:00
CrazyMax 2103f1bcee readme: install emulators when building with docker
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-05-28 17:40:41 +02:00
Sebastiaan van Stijn bdd92dd0d3 Merge pull request #284 from thaJeztah/various_cleanups
Assorted improvements, and add  "--version, -v", and "--help, -h" flags
2023-05-28 15:56:28 +02:00
CrazyMax 5944f8a485 osxkeychain: match min macos version for xx
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-05-28 15:55:56 +02:00
CrazyMax 0b9180511f Merge pull request #285 from crazy-max/test-target
chore: use same target for sandboxed and native tests
2023-05-28 15:20:22 +02:00
CrazyMax d440e5916e chore: use same target for sandboxed and native tests
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-05-28 15:13:50 +02:00
Sebastiaan van Stijn 129017a3cd credentials: define consts for supported actions (sub-commands)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-28 13:53:34 +02:00
Sebastiaan van Stijn 99079cafd2 credentials: Serve(): implement "--version, -v", and "--help, -h" flags
As recommended in the GNU documentation;

- https://www.gnu.org/prep/standards/standards.html#g_t_002d_002dversion
- https://www.gnu.org/prep/standards/standards.html#g_t_002d_002dhelp

With this patch:

    $ docker-credential-osxkeychain --version
    docker-credential-osxkeychain (github.com/docker/docker-credential-helpers) v0.7.0-51-g26c426e.m

    $ docker-credential-osxkeychain -v
    docker-credential-osxkeychain (github.com/docker/docker-credential-helpers) v0.7.0-51-g26c426e.m

    $ docker-credential-osxkeychain --help
    Usage: docker-credential-osxkeychain <store|get|erase|list|version>

    $ docker-credential-osxkeychain -h
    Usage: docker-credential-osxkeychain <store|get|erase|list|version>

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-28 13:53:34 +02:00
Sebastiaan van Stijn ae1d1ec013 credentials: HandleCommand(): improve error for unknown command/action
- renamed the "key" variable, which was slightly confusing
- include the name of the binary in the error

Before this change:

    docker-credential-osxkeychain nosuchaction
    Unknown credential action `nosuchaction`

After this change:

    docker-credential-osxkeychain nosuchaction
    docker-credential-osxkeychain: unknown action: nosuchaction

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-28 13:53:34 +02:00
Sebastiaan van Stijn db0ac44c97 credentials: Serve(): simplify error-handling logic
Don't use an err if we can print the error immediately :)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-28 13:53:34 +02:00
Sebastiaan van Stijn 0dbcdb66a7 credentials: Serve(): use "Name instead of "os.Args[0]" for usage output
GNU guidelines describes; https://www.gnu.org/prep/standards/html_node/_002d_002dversion.html#g_t_002d_002dversion

    The program’s name should be a constant string; don’t compute it from argv[0].
    The idea is to state the standard or canonical name for the program, not its
    file name.

Although the above recommendation is for `--version` output, it probably makes
sense to do the same for the "usage" output.

Before this change:

    /usr/local/bin/docker-credential-osxkeychain invalid command
    Usage: /usr/local/bin/docker-credential-osxkeychain <store|get|erase|list|version>

    /Applications/Docker.app/Contents/Resources/bin/docker-credential-osxkeychain invalid command
    Usage: /Applications/Docker.app/Contents/Resources/bin/docker-credential-osxkeychain <store|get|erase|list|version>

With this patch:

    /usr/local/bin/docker-credential-osxkeychain invalid command
    Usage: docker-credential-osxkeychain <store|get|erase|list|version>

    /Applications/Docker.app/Contents/Resources/bin/docker-credential-osxkeychain invalid command
    Usage: docker-credential-osxkeychain <store|get|erase|list|version>

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-28 13:53:23 +02:00
Sebastiaan van Stijn c324fe0a6f credentials: Get(): remove intermediate variable
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-28 12:38:05 +02:00
Sebastiaan van Stijn 19557f8fff fix some errCheck warnings, and update examples
- Explicitly suppress some unhandled errors
- Use "pass" credentials helper in examples, which is available
  on more platforms than "secretservice" (only supporte on Linux)
- Update domain and username in examples.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-28 12:33:58 +02:00
Sebastiaan van Stijn 94483d2d23 godoc: credentials helper -> credentials-helper
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-28 12:13:49 +02:00
Sebastiaan van Stijn 4c9fc240ed client: use os/exec/Cmd.Environ() instead of os.Environ()
Don't set Env if not set; the default is already handled if it's nil; from
the documentation: https://pkg.go.dev/os/exec@go1.20.4#Cmd.Env

    // If Env is nil, the new process uses the current process's
    // environment.

Use `os/exec/Cmd.Environ()` instead of `os.Environ()`, which was added in
go1.19, and handles additional environment variables, such as `PWD` on POSIX
systems, and `SYSTEMROOT` on Windows. https://pkg.go.dev/os/exec@go1.20.4#Cmd.Environ

Also remove a redundant `fmt.Sprintf()`, as we're only concatenating strings.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-28 12:11:06 +02:00
Sebastiaan van Stijn f8e94d91c0 Merge pull request #275 from thaJeztah/subtests
rewrite tests to use sub-tests, improve error-handling in tests, and use t.Cleanup()
2023-05-27 19:18:19 +02:00
Sebastiaan van Stijn 6f4e3abfc8 Merge pull request #281 from thaJeztah/bump_go_version
update go to go1.20.4
2023-05-27 19:17:16 +02:00
Sebastiaan van Stijn ec695cee3c Merge pull request #279 from crazy-max/win-arm64
windows/arm64 support for wincred
2023-05-27 19:00:36 +02:00
Sebastiaan van Stijn fa89a70db3 update go to go1.20.4
go1.20.4 (released 2023-05-02) includes three security fixes to the html/template
package, as well as bug fixes to the compiler, the runtime, and the crypto/subtle,
crypto/tls, net/http, and syscall packages. See the Go 1.20.4 milestone on our
issue tracker for details:

https://github.com/golang/go/issues?q=milestone%3AGo1.20.4+label%3ACherryPickApproved

release notes: https://go.dev/doc/devel/release#go1.20.4
full diff: https://github.com/golang/go/compare/go1.20.3...go1.20.4

from the announcement:

> These minor releases include 3 security fixes following the security policy:
>
> - html/template: improper sanitization of CSS values
>
>   Angle brackets (`<>`) were not considered dangerous characters when inserted
>   into CSS contexts. Templates containing multiple actions separated by a '/'
>   character could result in unexpectedly closing the CSS context and allowing
>   for injection of unexpected HMTL, if executed with untrusted input.
>
>   Thanks to Juho Nurminen of Mattermost for reporting this issue.
>
>   This is CVE-2023-24539 and Go issue https://go.dev/issue/59720.
>
> - html/template: improper handling of JavaScript whitespace
>
>   Not all valid JavaScript whitespace characters were considered to be
>   whitespace. Templates containing whitespace characters outside of the character
>   set "\t\n\f\r\u0020\u2028\u2029" in JavaScript contexts that also contain
>   actions may not be properly sanitized during execution.
>
>   Thanks to Juho Nurminen of Mattermost for reporting this issue.
>
>   This is CVE-2023-24540 and Go issue https://go.dev/issue/59721.
>
> - html/template: improper handling of empty HTML attributes
>
>   Templates containing actions in unquoted HTML attributes (e.g. "attr={{.}}")
>   executed with empty input could result in output that would have unexpected
>   results when parsed due to HTML normalization rules. This may allow injection
>   of arbitrary attributes into tags.
>
>   Thanks to Juho Nurminen of Mattermost for reporting this issue.
>
>   This is CVE-2023-29400 and Go issue https://go.dev/issue/59722.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-27 18:57:55 +02:00
Sebastiaan van Stijn 14d46ffd7e credentials: don't fail tests early, and use consts
- use consts for fixed values in tests
- don't fail tests early if there's more we can test

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-27 17:14:13 +02:00
Sebastiaan van Stijn c20f883316 client: don't use un-keyed literals in tests, and don't fail early
- don't fail tests early if there's more we can test
- don't user un-keyed literals in tests

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-27 17:14:13 +02:00
Sebastiaan van Stijn 7a60d70114 wincred: use sub-tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-27 17:14:13 +02:00
Sebastiaan van Stijn 814dbb3b5a wincred: use t.Cleanup(), and don't ignore errors
Make sure we don't drop errors when cleaning up state before/after
tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-27 17:14:13 +02:00
Sebastiaan van Stijn ed91395f20 wincred: don't use un-keyed literals in test-tables
Also moving the comments into the test-tables.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-27 17:14:12 +02:00
Sebastiaan van Stijn 5c5b09e7f8 osxkeychain: use sub-tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-27 17:14:12 +02:00
Sebastiaan van Stijn 8282d3336a osxkeychain: use t.Cleanup(), and don't ignore errors
Make sure we don't drop errors when cleaning up state before/after
tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-27 17:14:12 +02:00
Sebastiaan van Stijn a7ff1c7d16 osxkeychain: don't use un-keyed literals in test-tables
Also moving the comments into the test-tables.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-27 17:14:12 +02:00
Sebastiaan van Stijn 4a8c2d1d81 registryurl: use sub-tests
Also reformat the test-table to easier see what fields are used for
each test in the table.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-27 17:14:12 +02:00
Sebastiaan van Stijn 810dcd4ed5 use "tc" for test-cases
Mostly for my own sanity; just about every repository we have
started to converge to using "tc" as variable name for this, so
updating this repository as well to help reduce cognitive load.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-27 17:14:09 +02:00
Sebastiaan van Stijn f09e79d741 Merge pull request #278 from thaJeztah/osxkeychain_typed_error
osxkeychain: Delete(): return typed errors
2023-05-27 17:13:23 +02:00
Sebastiaan van Stijn b21b69c8ee osxkeychain: Delete(): return typed errors
This allows a Delete for non-existing credentials to be handled.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-27 16:54:37 +02:00
Sebastiaan van Stijn 7f00c5c8bd osxkeychain: use a switch for handling errors
Makes the error-handling slightly cleaner.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-27 16:54:37 +02:00
Sebastiaan van Stijn 1ed95cb020 osxkeychain: explicitly ignore error
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-27 16:54:32 +02:00
CrazyMax 88cb947f19 windows/arm64 support for wincred
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-05-27 16:46:54 +02:00
Sebastiaan van Stijn 9ff5b6126b Merge pull request #276 from crazy-max/ci-bump-os
ci: bump runners to ubuntu-22.04
2023-05-27 16:07:51 +02:00
CrazyMax 62d8c84526 ci: add ubuntu-22.04 to test matrix
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-05-27 15:58:02 +02:00
CrazyMax 2749e559d9 ci: bump runners to ubuntu-22.04
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-05-27 15:51:14 +02:00
Sebastiaan van Stijn 4ede49ca78 Merge pull request #273 from thaJeztah/gofumpt
format code with gofumpt
2023-05-27 13:44:47 +02:00
Sebastiaan van Stijn a001d639ae Merge pull request #272 from thaJeztah/add_project_files
Add CONTRIBUTING.md, CODE_OF_CONDUCT.md, SECURITY.md
2023-05-27 13:30:15 +02:00