Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SM-865] Part 2 Use new get secrets by IDs endpoint #150

Merged
merged 29 commits into from
Aug 28, 2023

Conversation

Thomas-Avery
Copy link
Contributor

@Thomas-Avery Thomas-Avery commented Jul 31, 2023

Type of change

- [ ] Bug fix
- [X] New feature development
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [ ] Other

Objective

The purpose of this PR is to expose the new get secrets by IDs endpoint in the SDK and use that in the bws CLI and napi.

Code changes

  • crates/bitwarden-json/src/client.rs:
    crates/bitwarden-json/src/command.rs:
    Exposing GetByIds as a secret command.

  • crates/bitwarden-napi/src-ts/bitwarden_client/index.ts:
    Exposing getByIds in typescript/ napi-rs implementation.

  • crates/bitwarden/src/secrets_manager/client_secrets.rs:
    crates/bitwarden/src/secrets_manager/secrets/get_by_ids.rs:
    crates/bitwarden/src/secrets_manager/secrets/mod.rs:
    Source code for get_by_ids secret command.

  • crates/bitwarden/src/secrets_manager/secrets/secret_response.rs:
    Add support for parsing the BaseSecretResponseModel and create SecretsResponse for returning a vec of SecretResponses.

  • crates/bws/src/main.rs:
    Use get_by_ids in bws secret listing command instead of individually making an HTTP request for each secret.

  • crates/sdk-schemas/src/main.rs:
    Add SecretsResponse as a result of SDK command.

Screenshots

Before you submit

  • Please add unit tests where it makes sense to do so (encouraged but not required)

@bitwarden-bot
Copy link

bitwarden-bot commented Jul 31, 2023

Logo
Checkmarx One – Scan Summary & Details6be963ce-066a-4dbd-b69b-03054d85c63e

No New Or Fixed Issues Found

@Thomas-Avery Thomas-Avery changed the title [SM-865] bulk secret fetching [SM-865] Use new bulk secret fetching endpoint Aug 1, 2023
@Thomas-Avery Thomas-Avery self-assigned this Aug 1, 2023
@Thomas-Avery Thomas-Avery changed the title [SM-865] Use new bulk secret fetching endpoint [SM-865] Use new get secrets by IDs endpoint Aug 1, 2023
@Thomas-Avery Thomas-Avery marked this pull request as ready for review August 1, 2023 18:25
Copy link
Member

@dani-garcia dani-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good on quick review, nice work! Just got a couple of comments:

  • Please update the changelog inside the bitwarden crate to mention this PR on the unreleased section
  • We're trying as much as we can to keep PRs small, and the autogenerated bindings definitely don't make this easy 😅, would you mind extracting the autogenerated bindings to a separate PR, which we can get merged quickly, and just keeping this one for the secrets changes? Thanks!

crates/bitwarden/src/secrets_manager/secrets/get_by_ids.rs Outdated Show resolved Hide resolved
@@ -11,7 +11,8 @@ function isMusl() {
// For Node 10
if (!process.report || typeof process.report.getReport !== "function") {
try {
return readFileSync("/usr/bin/ldd", "utf8").includes("musl");
const lddPath = require("child_process").execSync("which ldd").toString().trim();
return readFileSync(lddPath, "utf8").includes("musl");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to this file don't seem related to this PR, can we move it to a separate PR with some explanation on why they are needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is auto generated when running npm run build in the napi crate.

Looks like my M1 Macbook generates a different file for both master and this branch.

I'm reverting it back 143cd6e to what is in master.

In the future, this probably should be built during the build/release workflows and not handled by source control.

@Thomas-Avery Thomas-Avery changed the base branch from master to sm/sm-865-api-bindings August 2, 2023 15:59
@Thomas-Avery Thomas-Avery changed the title [SM-865] Use new get secrets by IDs endpoint [SM-865] Part 2 Use new get secrets by IDs endpoint Aug 2, 2023
dani-garcia
dani-garcia previously approved these changes Aug 4, 2023
Copy link
Member

@dani-garcia dani-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Base automatically changed from sm/sm-865-api-bindings to master August 28, 2023 15:15
@Thomas-Avery Thomas-Avery dismissed dani-garcia’s stale review August 28, 2023 15:15

The base branch was changed.

@Thomas-Avery Thomas-Avery merged commit 76865d9 into master Aug 28, 2023
@Thomas-Avery Thomas-Avery deleted the sm/sm-865-bulk-secret-fetching branch August 28, 2023 15:38
tangowithfoxtrot added a commit that referenced this pull request Feb 29, 2024
## Type of change

- [ ] Bug fix
- [ ] New feature development
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [x] Other

## Objective

Allow secret fetching by a list of IDs, rather than requesting multiple
secrets individually. Exposes the functionality from #150 in Go.

## Code changes

- **languages/go/secrets.go:** Add `GetByIDS` func.
- **languages/go/example/example.go:** Get secrets by ID. Added JSON
output for QA/ease-of-use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants