From 932945de319c7950a1e4f27fb55d378b261eb8b6 Mon Sep 17 00:00:00 2001 From: Matt Bishop Date: Thu, 29 Feb 2024 03:58:24 -0500 Subject: [PATCH 1/3] Undo global coverage setting application (#637) Reverts #634 and #636 as we found our mistake. --- .github/codecov.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/codecov.yml b/.github/codecov.yml index eb851984f..3228d009c 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -1,8 +1,3 @@ -coverage: - status: - patch: - informational: true - ignore: - "crates/sdk-schemas" # Tool - "crates/uniffi-bindgen" # Tool From c0fe4ac39c6a91b23575b6cf8d1db48e79897761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ch=C4=99ci=C5=84ski?= Date: Thu, 29 Feb 2024 12:13:01 +0100 Subject: [PATCH 2/3] [DEVOPS-1750] Build and release pipeline for go SDK (#632) ## Type of change ``` - [ ] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [x] Build/deploy pipeline (DevOps) - [ ] Other ``` ## Objective ## Code changes - **languages/go/.version:** Add file to hold current go SDK version - **.github/workflows/version-bump.yml** Add go SDK to version bump workflow - **.github/workflows/golang-release.yml** replace it with `.github/workflows/release-go.yaml` workflow. - **.github/workflows/build-go.yaml** Add build go as a separate workflow - **.github/workflows/release-go.yml** Update release go pipeline to our standards. Sync go SDK folder to external repo. Create release tag. ## Before you submit - Please add **unit tests** where it makes sense to do so --- .github/workflows/build-go.yaml | 49 +++++++++ .github/workflows/golang-release.yml | 73 ------------- .github/workflows/release-go.yml | 151 +++++++++++++++++++++++++++ .github/workflows/version-bump.yml | 6 ++ languages/go/.version | 1 + 5 files changed, 207 insertions(+), 73 deletions(-) create mode 100644 .github/workflows/build-go.yaml delete mode 100644 .github/workflows/golang-release.yml create mode 100644 .github/workflows/release-go.yml create mode 100644 languages/go/.version diff --git a/.github/workflows/build-go.yaml b/.github/workflows/build-go.yaml new file mode 100644 index 000000000..433013aac --- /dev/null +++ b/.github/workflows/build-go.yaml @@ -0,0 +1,49 @@ +name: Build Go SDK + +on: + push: + branches: + - main + - rc + - hotfix-rc + + pull_request: + +env: + GO111MODULE: on + GO_VERSION: "^1.18" + +jobs: + build: + name: Build + runs-on: ubuntu-22.04 + steps: + - name: Checkout Repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Setup Go environment + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Cache dependencies + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: npm ci + run: npm ci + + - name: Generate schemas + run: npm run schemas + + - name: Build + working-directory: languages/go + run: go build -v ./... + + - name: Test + working-directory: languages/go + run: go test -v ./... diff --git a/.github/workflows/golang-release.yml b/.github/workflows/golang-release.yml deleted file mode 100644 index 10ec7675e..000000000 --- a/.github/workflows/golang-release.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: Go Release - -on: - workflow_dispatch: - inputs: - version_number: - description: "New Version" - required: true - -env: - GO111MODULE: on - GO_VERSION: "^1.18" - -jobs: - build_rust: - uses: ./.github/workflows/build-rust-cross-platform.yml - - generate-schemas: - uses: ./.github/workflows/generate_schemas.yml - - build: - name: Build - needs: - - build_rust - - generate-schemas - runs-on: ubuntu-22.04 - steps: - - name: Checkout Repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - - name: Setup Go environment - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Cache dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Build - run: go build -v ./... - - - name: Test - run: go test -v ./... - - release: - name: Release - needs: build - runs-on: ubuntu-22.04 - steps: - - name: Checkout Repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - - name: Setup Go environment - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Set release version - run: echo "VERSION=${{ github.event.inputs.version_number }}" >> $GITHUB_ENV - - - name: Install Goreleaser - run: go install github.com/goreleaser/goreleaser@v1.21.2 - - - name: Run Goreleaser - run: goreleaser release --rm-dist --skip-validate - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VERSION: ${{ env.VERSION }} diff --git a/.github/workflows/release-go.yml b/.github/workflows/release-go.yml new file mode 100644 index 000000000..830e5f313 --- /dev/null +++ b/.github/workflows/release-go.yml @@ -0,0 +1,151 @@ +name: Release Go + +on: + workflow_dispatch: + inputs: + release_type: + description: "Release Options" + required: true + default: "Release" + type: choice + options: + - Release + - Dry Run + +env: + GO111MODULE: on + GO_VERSION: "^1.18" + +jobs: + validate: + name: Setup + runs-on: ubuntu-22.04 + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - name: Checkout repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Branch check + if: ${{ github.event.inputs.release_type != 'Dry Run' }} + run: | + if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then + echo "===================================" + echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches" + echo "===================================" + exit 1 + fi + + - name: Get version + id: version + run: | + VERSION=$(cat languages/go/.version | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+") + echo "version=$VERSION" >> $GITHUB_OUTPUT + + repo-sync: + name: Push changed files to SDK Go repo + runs-on: ubuntu-22.04 + needs: validate + env: + _KEY_VAULT: "bitwarden-ci" + _BOT_EMAIL: 106330231+bitwarden-devops-bot@users.noreply.github.com + _BOT_NAME: bitwarden-devops-bot + _PKG_VERSION: ${{ needs.validate.outputs.version }} + steps: + - name: Checkout SDK repo + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + with: + path: sdk + + - name: Checkout SDK-Go repo + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + with: + repository: bitwarden/sm-sdk-go + path: sm-sdk-go + ref: main + + - name: Login to Azure - Prod Subscription + uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7 + with: + creds: ${{ secrets.AZURE_CI_SERVICE_PRINCIPAL }} + + - name: Retrieve secrets + id: retrieve-secrets + uses: bitwarden/gh-actions/get-keyvault-secrets@62d1bf7c3e31c458cc7236b1e69a475d235cd78f + with: + keyvault: ${{ env._KEY_VAULT }} + secrets: "github-pat-bitwarden-devops-bot-repo-scope" + + - name: Setup Git + working-directory: sm-sdk-go + run: | + git config --local user.email "${{ env._BOT_EMAIL }}" + git config --local user.name "${{ env._BOT_NAME }}" + + - name: Update files + run: | + # Copy files to local sm-sdk-go repo path + cp --verbose -rf sdk/languages/go sm-sdk-go + + - name: Push changes + working-directory: sm-sdk-go + run: | + git add . + git commit -m "Update Go SDK to ${{ github.sha }}" + + if [[ "${{ github.event.inputs.release_type }}" == "Dry Run" ]]; then + echo "===================================" + echo "[!] Dry Run - Skipping push" + echo "===================================" + git ls-files -m + exit 0 + else + git push origin main + fi + + - name: Create release tag on SDK Go repo + if: ${{ github.event.inputs.release_type != 'Dry Run' }} + working-directory: sm-sdk-go + run: | + # Check if tag exists, set output then exit 0 if true. + if git log v${{ env._PKG_VERSION }} >/dev/null 2>&1; then + echo "===================================" + echo "[!] Tag v${{ env._PKG_VERSION }} already exists" + echo "===================================" + exit 1 + fi + + git tag v${{ env._PKG_VERSION }} + git push origin v${{ env._PKG_VERSION }} + + github-release: + name: GitHub Release + runs-on: ubuntu-22.04 + needs: + - repo-sync + - validate + env: + _PKG_VERSION: ${{ needs.validate.outputs.version }} + steps: + - name: Login to Azure - Prod Subscription + uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7 + with: + creds: ${{ secrets.AZURE_CI_SERVICE_PRINCIPAL }} + + - name: Retrieve secrets + id: retrieve-secrets + uses: bitwarden/gh-actions/get-keyvault-secrets@62d1bf7c3e31c458cc7236b1e69a475d235cd78f + with: + keyvault: ${{ env._KEY_VAULT }} + secrets: "github-pat-bitwarden-devops-bot-repo-scope" + + - name: Create release + if: ${{ github.event.inputs.release_type != 'Dry Run' }} + uses: ncipollo/release-action@6c75be85e571768fa31b40abf38de58ba0397db5 # v1.13.0 + with: + tag: v${{ env._PKG_VERSION }} + name: v${{ env._PKG_VERSION }} + body: "" + token: ${{ steps.retrieve-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }} + draft: true + repo: bitwarden/sm-sdk-go diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index 3c6485a09..8298781fc 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -20,6 +20,7 @@ on: - napi - python-sdk - ruby-sdk + - go-sdk version_number: description: "New version (example: '2024.1.0')" required: true @@ -156,6 +157,11 @@ jobs: if: ${{ inputs.project == 'ruby-sdk' }} run: sed -i "s/VERSION = '[0-9]\.[0-9]\.[0-9]'/VERSION = '${{ inputs.version_number }}'/" ./languages/ruby/bitwarden_sdk_secrets/lib/version.rb + ### go sdk + - name: Bump go-sdk Version + if: ${{ inputs.project == 'go-sdk' }} + run: sed -i 's/[0-9]\.[0-9]\.[0-9]/${{ inputs.version_number }}/' ./languages/go/.version + ############################ # VERSION BUMP SECTION END # ############################ diff --git a/languages/go/.version b/languages/go/.version new file mode 100644 index 000000000..6c6aa7cb0 --- /dev/null +++ b/languages/go/.version @@ -0,0 +1 @@ +0.1.0 \ No newline at end of file From c3d809b6b3a0a9ebf9fe6bddeea10f54a3701062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Thu, 29 Feb 2024 17:31:56 +0100 Subject: [PATCH 3/3] Fix typo in `trust_device` (#640) ## Type of change ``` - [x] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ``` ## Objective Function was accidentally called `t` when it should have been called `trust_device` --- crates/bitwarden-uniffi/src/auth/mod.rs | 2 +- languages/kotlin/doc.md | 68 +++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/crates/bitwarden-uniffi/src/auth/mod.rs b/crates/bitwarden-uniffi/src/auth/mod.rs index 34d0de93f..2a451ffdf 100644 --- a/crates/bitwarden-uniffi/src/auth/mod.rs +++ b/crates/bitwarden-uniffi/src/auth/mod.rs @@ -130,7 +130,7 @@ impl ClientAuth { } /// Trust the current device - pub async fn t(&self) -> Result { + pub async fn trust_device(&self) -> Result { Ok(self.0 .0.write().await.auth().trust_device()?) } } diff --git a/languages/kotlin/doc.md b/languages/kotlin/doc.md index d69e134c4..c4b564a2e 100644 --- a/languages/kotlin/doc.md +++ b/languages/kotlin/doc.md @@ -46,6 +46,16 @@ Generator operations **Output**: Arc +### `exporters` + +Exporters + +**Arguments**: + +- self: Arc + +**Output**: Arc + ### `auth` Auth operations @@ -138,6 +148,23 @@ password, use the email OTP. **Output**: std::result::Result<,BitwardenError> +### `validate_password_user_key` + +Validate the user password without knowing the password hash + +Used for accounts that we know have master passwords but that have not logged in with a password. +Some example are login with device or TDE. + +This works by comparing the provided password against the encrypted user key. + +**Arguments**: + +- self: +- password: String +- encrypted_user_key: String + +**Output**: std::result::Result + ### `new_auth_request` Initialize a new auth request @@ -160,6 +187,16 @@ Approve an auth request **Output**: std::result::Result +### `trust_device` + +Trust the current device + +**Arguments**: + +- self: + +**Output**: std::result::Result + ## ClientAttachments ### `encrypt_buffer` @@ -1287,6 +1324,37 @@ implementations. + + deviceKey + object + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyTypeDescription
device_keystringThe device's DeviceKey
protected_device_private_keyThe Device Private Key
device_protected_user_keyThe user's symmetric crypto key, encrypted with the Device Key.
+ + ## `InitUserCryptoRequest`