mirror of
https://github.com/docker/docker-credential-helpers.git
synced 2026-06-28 15:21:29 +05:30
Compare commits
77 Commits
v0.9.2
..
e3d1da694f
| Author | SHA1 | Date | |
|---|---|---|---|
| e3d1da694f | |||
| 98a1b9ce53 | |||
| ca21698edc | |||
| 300c1b491f | |||
| 14b6d371c9 | |||
| bfd43cacbb | |||
| 7b43509f5b | |||
| 5ad51ee4a4 | |||
| 5b6a1880fa | |||
| 29038b4df4 | |||
| 955f6c518d | |||
| 0202e5a960 | |||
| 4e2b0ff14f | |||
| 8fe8d458f7 | |||
| af758c414c | |||
| dc6f4f5cb9 | |||
| 4e68cd824e | |||
| d520877610 | |||
| f0e4adbf36 | |||
| bf6137df6b | |||
| 2b4e08bca3 | |||
| 62deeb49c1 | |||
| 6ca9924445 | |||
| 806dc5f678 | |||
| a7b23cd2b5 | |||
| 178a3a4e57 | |||
| f5fd80af0f | |||
| ae163ade7b | |||
| b871f76540 | |||
| 50c1460bf5 | |||
| aecf6e5780 | |||
| ecf6c1ccc7 | |||
| b844409a12 | |||
| 9df2c7782a | |||
| 7a15b77bcb | |||
| 81f7ebebfd | |||
| 3f97cf3ce3 | |||
| 8b5e6dffc6 | |||
| 4741f33d28 | |||
| 78303955b8 | |||
| 9b0c242b5c | |||
| 057ed818a9 | |||
| b7a754b9ff | |||
| 62777f0887 | |||
| 9d04e49561 | |||
| bc131d729d | |||
| 84c3413e0e | |||
| fcb0b664b5 | |||
| cf4e41fbb0 | |||
| 53f7bdc3fa | |||
| d4602cd917 | |||
| ae84c25786 | |||
| 2adf3cf9aa | |||
| 1fdce4c733 | |||
| 962a779645 | |||
| ec5efac3ca | |||
| 8154b98959 | |||
| d075f3cecc | |||
| fdddb02817 | |||
| c07513a69d | |||
| 4142982fb8 | |||
| 860f1459e3 | |||
| d378d46316 | |||
| 4c97a761df | |||
| b61abf1cb8 | |||
| 85841ea0ce | |||
| c32e697324 | |||
| d770c60191 | |||
| 5095e43ecf | |||
| 00313838c6 | |||
| bcf656656f | |||
| fd27520bbd | |||
| 4849c2328b | |||
| 2e8005f3a7 | |||
| 5d4d5150ae | |||
| f9d3010165 | |||
| e7bd3957ae |
+40
-23
@@ -1,5 +1,14 @@
|
||||
name: build
|
||||
|
||||
# Default to 'contents: read', which grants actions to read commits.
|
||||
#
|
||||
# If any permission is set, any permission not included in the list is
|
||||
# implicitly set to "none".
|
||||
#
|
||||
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
@@ -8,18 +17,19 @@ on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'main'
|
||||
tags:
|
||||
- 'v*'
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
DESTDIR: ./bin
|
||||
GO_VERSION: 1.23.6
|
||||
GO_VERSION: 1.25.8
|
||||
|
||||
jobs:
|
||||
validate:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 30 # guardrails timeout for the whole job
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -29,10 +39,10 @@ jobs:
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
||||
-
|
||||
name: Run
|
||||
run: |
|
||||
@@ -40,23 +50,24 @@ jobs:
|
||||
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 30 # guardrails timeout for the whole job
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-24.04
|
||||
- ubuntu-22.04
|
||||
- macOS-15-intel
|
||||
- macOS-15
|
||||
- macOS-14
|
||||
- macOS-13
|
||||
- windows-2022
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
-
|
||||
name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
-
|
||||
@@ -73,7 +84,7 @@ jobs:
|
||||
-
|
||||
name: GPG conf
|
||||
if: ${{ !startsWith(matrix.os, 'windows-') }}
|
||||
uses: actions/github-script@v7
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
id: gpg
|
||||
with:
|
||||
script: |
|
||||
@@ -90,7 +101,7 @@ jobs:
|
||||
-
|
||||
name: Import GPG key
|
||||
if: ${{ !startsWith(matrix.os, 'windows-') }}
|
||||
uses: crazy-max/ghaction-import-gpg@v6
|
||||
uses: crazy-max/ghaction-import-gpg@2dc316deee8e90f13e1a351ab510b4d5bc0c82cd # v7.0.0
|
||||
with:
|
||||
gpg_private_key: ${{ steps.gpg.outputs.key }}
|
||||
passphrase: ${{ steps.gpg.outputs.passphrase }}
|
||||
@@ -108,20 +119,21 @@ jobs:
|
||||
shell: bash
|
||||
-
|
||||
name: Upload coverage
|
||||
uses: codecov/codecov-action@v5
|
||||
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
|
||||
with:
|
||||
files: ${{ env.DESTDIR }}/coverage.txt
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
test-sandboxed:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 30 # guardrails timeout for the whole job
|
||||
steps:
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
||||
-
|
||||
name: Test
|
||||
uses: docker/bake-action@v6
|
||||
uses: docker/bake-action@a66e1c87e2eca0503c343edf1d208c716d54b8a8 # v7.1.0
|
||||
with:
|
||||
targets: test
|
||||
set: |
|
||||
@@ -129,25 +141,29 @@ jobs:
|
||||
*.cache-to=type=gha,scope=test,mode=max
|
||||
-
|
||||
name: Upload coverage
|
||||
uses: codecov/codecov-action@v5
|
||||
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
|
||||
with:
|
||||
files: ${{ env.DESTDIR }}//coverage.txt
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 30 # guardrails timeout for the whole job
|
||||
permissions:
|
||||
# required to create GitHub release
|
||||
contents: write
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
||||
-
|
||||
name: Build
|
||||
run: |
|
||||
@@ -165,7 +181,7 @@ jobs:
|
||||
find ${{ env.DESTDIR }} -type f -exec file -e ascii -e text -- {} +
|
||||
-
|
||||
name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
||||
with:
|
||||
name: docker-credential-helpers
|
||||
path: ${{ env.DESTDIR }}/*
|
||||
@@ -173,7 +189,7 @@ jobs:
|
||||
-
|
||||
name: GitHub Release
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1
|
||||
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
@@ -181,11 +197,12 @@ jobs:
|
||||
files: ${{ env.DESTDIR }}/*
|
||||
|
||||
build-deb:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 30 # guardrails timeout for the whole job
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
-
|
||||
|
||||
+11
-19
@@ -1,31 +1,23 @@
|
||||
version: "2"
|
||||
run:
|
||||
timeout: 10m
|
||||
modules-download-mode: vendor
|
||||
|
||||
linters:
|
||||
default: none
|
||||
enable:
|
||||
- gofmt
|
||||
- govet
|
||||
- depguard
|
||||
- goimports
|
||||
- ineffassign
|
||||
- misspell
|
||||
- unused
|
||||
- revive
|
||||
- staticcheck
|
||||
- typecheck
|
||||
disable-all: true
|
||||
|
||||
linters-settings:
|
||||
depguard:
|
||||
- unused
|
||||
settings:
|
||||
revive:
|
||||
rules:
|
||||
main:
|
||||
deny:
|
||||
- pkg: "io/ioutil"
|
||||
desc: The io/ioutil package has been deprecated. See https://go.dev/doc/go1.16#ioutil
|
||||
- name: package-comments # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#package-comments
|
||||
disabled: true
|
||||
|
||||
issues:
|
||||
exclude-rules:
|
||||
- linters:
|
||||
- revive
|
||||
text: "stutters"
|
||||
formatters:
|
||||
enable:
|
||||
- gofmt
|
||||
- goimports
|
||||
|
||||
+16
-37
@@ -1,12 +1,11 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG GO_VERSION=1.23.6
|
||||
ARG GO_VERSION=1.25.8
|
||||
ARG DEBIAN_VERSION=bookworm
|
||||
|
||||
ARG XX_VERSION=1.6.1
|
||||
ARG OSXCROSS_VERSION=11.3-r7-debian
|
||||
ARG GOLANGCI_LINT_VERSION=v1.64.5
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ARG XX_VERSION=1.7.0
|
||||
ARG OSXCROSS_VERSION=11.3-r8-debian
|
||||
ARG GOLANGCI_LINT_VERSION=v2.8
|
||||
|
||||
ARG PACKAGE=github.com/docker/docker-credential-helpers
|
||||
|
||||
@@ -18,7 +17,6 @@ FROM crazymax/osxcross:${OSXCROSS_VERSION} AS osxcross
|
||||
|
||||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-${DEBIAN_VERSION} AS gobase
|
||||
COPY --from=xx / /
|
||||
ARG DEBIAN_FRONTEND
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends clang dpkg-dev file git lld llvm make pkg-config rsync
|
||||
ENV GOFLAGS="-mod=vendor"
|
||||
ENV CGO_ENABLED="1"
|
||||
@@ -56,7 +54,6 @@ EOT
|
||||
|
||||
FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION} AS golangci-lint
|
||||
FROM gobase AS lint
|
||||
ARG DEBIAN_FRONTEND
|
||||
RUN apt-get install -y binutils gcc libc6-dev libgcc-11-dev libsecret-1-dev pkg-config
|
||||
RUN --mount=type=bind,target=. \
|
||||
--mount=type=cache,target=/root/.cache \
|
||||
@@ -65,11 +62,9 @@ RUN --mount=type=bind,target=. \
|
||||
|
||||
FROM gobase AS base
|
||||
ARG TARGETPLATFORM
|
||||
ARG DEBIAN_FRONTEND
|
||||
RUN xx-apt-get install -y binutils gcc libc6-dev libgcc-11-dev libsecret-1-dev pkg-config
|
||||
|
||||
FROM base AS test
|
||||
ARG DEBIAN_FRONTEND
|
||||
RUN xx-apt-get install -y dbus-x11 gnome-keyring gpg-agent gpgconf libsecret-1-dev pass
|
||||
RUN --mount=type=bind,target=. \
|
||||
--mount=type=cache,target=/root/.cache \
|
||||
@@ -99,21 +94,7 @@ FROM gobase AS version
|
||||
RUN --mount=target=. \
|
||||
echo -n "$(./hack/git-meta version)" | tee /tmp/.version ; echo -n "$(./hack/git-meta revision)" | tee /tmp/.revision
|
||||
|
||||
FROM base AS build-linux
|
||||
ARG PACKAGE
|
||||
RUN --mount=type=bind,target=. \
|
||||
--mount=type=cache,target=/root/.cache \
|
||||
--mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=bind,source=/tmp/.version,target=/tmp/.version,from=version \
|
||||
--mount=type=bind,source=/tmp/.revision,target=/tmp/.revision,from=version <<EOT
|
||||
set -ex
|
||||
xx-go --wrap
|
||||
make build-pass build-secretservice PACKAGE=$PACKAGE VERSION=$(cat /tmp/.version) REVISION=$(cat /tmp/.revision) DESTDIR=/out
|
||||
xx-verify /out/docker-credential-pass
|
||||
xx-verify /out/docker-credential-secretservice
|
||||
EOT
|
||||
|
||||
FROM base AS build-darwin
|
||||
FROM base AS build
|
||||
ARG PACKAGE
|
||||
RUN --mount=type=bind,target=. \
|
||||
--mount=type=cache,target=/root/.cache \
|
||||
@@ -124,28 +105,26 @@ RUN --mount=type=bind,target=. \
|
||||
set -ex
|
||||
export MACOSX_VERSION_MIN=$(make print-MACOSX_DEPLOYMENT_TARGET)
|
||||
xx-go --wrap
|
||||
case "$(xx-info os)" in
|
||||
linux)
|
||||
make build-pass build-secretservice PACKAGE=$PACKAGE VERSION=$(cat /tmp/.version) REVISION=$(cat /tmp/.revision) DESTDIR=/out
|
||||
xx-verify /out/docker-credential-pass
|
||||
xx-verify /out/docker-credential-secretservice
|
||||
;;
|
||||
darwin)
|
||||
go install std
|
||||
make build-osxkeychain build-pass PACKAGE=$PACKAGE VERSION=$(cat /tmp/.version) REVISION=$(cat /tmp/.revision) DESTDIR=/out
|
||||
xx-verify /out/docker-credential-osxkeychain
|
||||
xx-verify /out/docker-credential-pass
|
||||
EOT
|
||||
|
||||
FROM base AS build-windows
|
||||
ARG PACKAGE
|
||||
RUN --mount=type=bind,target=. \
|
||||
--mount=type=cache,target=/root/.cache \
|
||||
--mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=bind,source=/tmp/.version,target=/tmp/.version,from=version \
|
||||
--mount=type=bind,source=/tmp/.revision,target=/tmp/.revision,from=version <<EOT
|
||||
set -ex
|
||||
xx-go --wrap
|
||||
;;
|
||||
windows)
|
||||
make build-wincred PACKAGE=$PACKAGE VERSION=$(cat /tmp/.version) REVISION=$(cat /tmp/.revision) DESTDIR=/out
|
||||
mv /out/docker-credential-wincred /out/docker-credential-wincred.exe
|
||||
xx-verify /out/docker-credential-wincred.exe
|
||||
;;
|
||||
esac
|
||||
EOT
|
||||
|
||||
FROM build-$TARGETOS AS build
|
||||
|
||||
FROM scratch AS binaries
|
||||
COPY --from=build /out /
|
||||
|
||||
|
||||
+3
-5
@@ -1,14 +1,12 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG GO_VERSION=1.23.6
|
||||
ARG GO_VERSION=1.25.8
|
||||
ARG DISTRO=ubuntu
|
||||
ARG SUITE=focal
|
||||
ARG SUITE=jammy
|
||||
|
||||
FROM golang:${GO_VERSION}-bullseye AS golang
|
||||
FROM golang:${GO_VERSION}-bookworm AS golang
|
||||
|
||||
FROM ${DISTRO}:${SUITE}
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get update && apt-get install -yy debhelper dh-make libsecret-1-dev
|
||||
RUN mkdir -p /build
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ retract (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/danieljoos/wincred v1.2.2
|
||||
github.com/danieljoos/wincred v1.2.3
|
||||
github.com/keybase/go-keychain v0.0.1
|
||||
)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
github.com/danieljoos/wincred v1.2.2 h1:774zMFJrqaeYCK2W57BgAem/MLi6mtSE47MB6BOJ0i0=
|
||||
github.com/danieljoos/wincred v1.2.2/go.mod h1:w7w4Utbrz8lqeMbDAK0lkNJUv5sAOkFi7nd/ogr0Uh8=
|
||||
github.com/danieljoos/wincred v1.2.3 h1:v7dZC2x32Ut3nEfRH+vhoZGvN72+dQ/snVXo/vMFLdQ=
|
||||
github.com/danieljoos/wincred v1.2.3/go.mod h1:6qqX0WNrS4RzPZ1tnroDzq9kY3fu1KwE7MRLQK4X0bs=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/keybase/go-keychain v0.0.1 h1:way+bWYa6lDppZoZcgMbYsvC7GxljxrskdNInRtuthU=
|
||||
@@ -8,8 +8,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
|
||||
@@ -46,6 +46,17 @@ func (h Osxkeychain) Add(creds *credentials.Credentials) error {
|
||||
item.SetLabel(credentials.CredsLabel)
|
||||
item.SetAccount(creds.Username)
|
||||
item.SetData([]byte(creds.Secret))
|
||||
// Prior to v0.9, the credential helper was searching for credentials with
|
||||
// the "dflt" authentication type (see [1]). Since v0.9.0, Get doesn't use
|
||||
// that attribute anymore, and v0.9.0 - v0.9.2 were not setting it here
|
||||
// either.
|
||||
//
|
||||
// In order to keep compatibility with older versions, we need to store
|
||||
// credentials with this attribute set. This way, credentials stored with
|
||||
// newer versions can be retrieved by older versions.
|
||||
//
|
||||
// [1]: https://github.com/docker/docker-credential-helpers/blob/v0.8.2/osxkeychain/osxkeychain.c#L66
|
||||
item.SetAuthenticationType("dflt")
|
||||
if err := splitServer(creds.ServerURL, item); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+2
-2
@@ -83,10 +83,10 @@ func TestPassHelperList(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
for server, username := range credsList {
|
||||
if !(strings.HasSuffix(server, "2376/v1") || strings.HasSuffix(server, "2375/v1")) {
|
||||
if !strings.HasSuffix(server, "2376/v1") && !strings.HasSuffix(server, "2375/v1") {
|
||||
t.Errorf("invalid url: %s", server)
|
||||
}
|
||||
if !(username == "foo" || username == "bar") {
|
||||
if username != "foo" && username != "bar" {
|
||||
t.Errorf("invalid username: %v", username)
|
||||
}
|
||||
|
||||
|
||||
+7
-13
@@ -31,13 +31,13 @@ func utf16FromString(str string) []uint16 {
|
||||
|
||||
// goBytes copies the given C byte array to a Go byte array (see `C.GoBytes`).
|
||||
// This function avoids having cgo as dependency.
|
||||
func goBytes(src uintptr, len uint32) []byte {
|
||||
if src == uintptr(0) {
|
||||
func goBytes(src *byte, len uint32) []byte {
|
||||
if src == nil || len == 0 {
|
||||
return []byte{}
|
||||
}
|
||||
rv := make([]byte, len)
|
||||
copy(rv, *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
|
||||
Data: src,
|
||||
Data: uintptr(unsafe.Pointer(src)),
|
||||
Len: int(len),
|
||||
Cap: int(len),
|
||||
})))
|
||||
@@ -59,7 +59,7 @@ func sysToCredential(cred *sysCREDENTIAL) (result *Credential) {
|
||||
result.CredentialBlob = goBytes(cred.CredentialBlob, cred.CredentialBlobSize)
|
||||
result.Attributes = make([]CredentialAttribute, cred.AttributeCount)
|
||||
attrSlice := *(*[]sysCREDENTIAL_ATTRIBUTE)(unsafe.Pointer(&reflect.SliceHeader{
|
||||
Data: cred.Attributes,
|
||||
Data: uintptr(unsafe.Pointer(cred.Attributes)),
|
||||
Len: int(cred.AttributeCount),
|
||||
Cap: int(cred.AttributeCount),
|
||||
}))
|
||||
@@ -85,17 +85,13 @@ func sysFromCredential(cred *Credential) (result *sysCREDENTIAL) {
|
||||
result.LastWritten = syscall.NsecToFiletime(cred.LastWritten.UnixNano())
|
||||
result.CredentialBlobSize = uint32(len(cred.CredentialBlob))
|
||||
if len(cred.CredentialBlob) > 0 {
|
||||
result.CredentialBlob = uintptr(unsafe.Pointer(&cred.CredentialBlob[0]))
|
||||
} else {
|
||||
result.CredentialBlob = 0
|
||||
result.CredentialBlob = &cred.CredentialBlob[0]
|
||||
}
|
||||
result.Persist = uint32(cred.Persist)
|
||||
result.AttributeCount = uint32(len(cred.Attributes))
|
||||
attributes := make([]sysCREDENTIAL_ATTRIBUTE, len(cred.Attributes))
|
||||
if len(attributes) > 0 {
|
||||
result.Attributes = uintptr(unsafe.Pointer(&attributes[0]))
|
||||
} else {
|
||||
result.Attributes = 0
|
||||
result.Attributes = &attributes[0]
|
||||
}
|
||||
for i := range cred.Attributes {
|
||||
inAttr := &cred.Attributes[i]
|
||||
@@ -104,9 +100,7 @@ func sysFromCredential(cred *Credential) (result *sysCREDENTIAL) {
|
||||
outAttr.Flags = 0
|
||||
outAttr.ValueSize = uint32(len(inAttr.Value))
|
||||
if len(inAttr.Value) > 0 {
|
||||
outAttr.Value = uintptr(unsafe.Pointer(&inAttr.Value[0]))
|
||||
} else {
|
||||
outAttr.Value = 0
|
||||
outAttr.Value = &inAttr.Value[0]
|
||||
}
|
||||
}
|
||||
result.TargetAlias, _ = syscall.UTF16PtrFromString(cred.TargetAlias)
|
||||
|
||||
+6
-3
@@ -5,6 +5,7 @@ package wincred
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"runtime"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
@@ -33,10 +34,10 @@ type sysCREDENTIAL struct {
|
||||
Comment *uint16
|
||||
LastWritten windows.Filetime
|
||||
CredentialBlobSize uint32
|
||||
CredentialBlob uintptr
|
||||
CredentialBlob *byte
|
||||
Persist uint32
|
||||
AttributeCount uint32
|
||||
Attributes uintptr
|
||||
Attributes *sysCREDENTIAL_ATTRIBUTE
|
||||
TargetAlias *uint16
|
||||
UserName *uint16
|
||||
}
|
||||
@@ -46,7 +47,7 @@ type sysCREDENTIAL_ATTRIBUTE struct {
|
||||
Keyword *uint16
|
||||
Flags uint32
|
||||
ValueSize uint32
|
||||
Value uintptr
|
||||
Value *byte
|
||||
}
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows/desktop/api/wincred/ns-wincred-_credentialw
|
||||
@@ -93,6 +94,8 @@ func sysCredWrite(cred *Credential, typ sysCRED_TYPE) error {
|
||||
uintptr(unsafe.Pointer(ncred)),
|
||||
0,
|
||||
)
|
||||
// Make sure everything reachable from ncred stays alive through the call.
|
||||
runtime.KeepAlive(ncred)
|
||||
if ret == 0 {
|
||||
return err
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
# github.com/danieljoos/wincred v1.2.2
|
||||
# github.com/danieljoos/wincred v1.2.3
|
||||
## explicit; go 1.18
|
||||
github.com/danieljoos/wincred
|
||||
# github.com/keybase/go-keychain v0.0.1
|
||||
|
||||
Reference in New Issue
Block a user