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-1402 - review and update php sdk #1032

Merged
merged 42 commits into from
Sep 18, 2024

Conversation

tangowithfoxtrot
Copy link
Contributor

@tangowithfoxtrot tangowithfoxtrot commented Sep 9, 2024

🎟️ Tracking

https://bitwarden.atlassian.net/browse/SM-1402

📔 Objective

Update PHP bindings in accordance with our other wrappers. This renames any "put" methods to "update", refactors access_token_login to auth().login_access_token, re-orders function args for create and update, and adds secret syncing.

This update required quite a few changes to the schemas. However, since we cannot auto-generate them with quicktype (see the error referenced in glideapps/quicktype/pull/2407), schemas were generated with the swaggest/json-cli:

json-cli gen-php ../../support/schemas/schema_types/SchemaTypes.json --ns '\Bitwarden\Sdk\Schemas' --ns-path ./src/schemas/

The generated schemas still required hand modification to get human-readable class names for things like ProjectCommand, SecretCommand, etc.

To validate the changes, I've run the example.php file after updating the schemas.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation
    team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed
    issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

Copy link
Contributor

github-actions bot commented Sep 9, 2024

Logo
Checkmarx One – Scan Summary & Details9f274337-322f-45a6-aa53-2bf9cd742c0a

New Issues

Severity Issue Source File / Package Checkmarx Insight
MEDIUM Privacy_Violation /languages/java/src/main/java/com/bitwarden/sdk/BitwardenClient.java: 41 Attack Vector
MEDIUM Privacy_Violation /languages/java/src/main/java/com/bitwarden/sdk/SecretsClient.java: 40 Attack Vector
MEDIUM Unpinned Actions Full Length Commit SHA /build-cli.yml: 341 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /publish-rust-crates.yml: 56 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /build-swift.yml: 84 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...

Fixed Issues

Severity Issue Source File / Package
MEDIUM Privacy_Violation /languages/java/example/Example.java: 46
MEDIUM Privacy_Violation /languages/java/src/main/java/com/bitwarden/sdk/BitwardenClient.java: 43
MEDIUM Privacy_Violation /languages/java/example/Example.java: 43
MEDIUM Privacy_Violation /languages/java/src/main/java/com/bitwarden/sdk/BitwardenClient.java: 43
MEDIUM Privacy_Violation /languages/java/src/main/java/com/bitwarden/sdk/BitwardenClient.java: 43
MEDIUM Privacy_Violation /languages/java/src/main/java/com/bitwarden/sdk/BitwardenClient.java: 43
MEDIUM Privacy_Violation /languages/java/src/main/java/com/bitwarden/sdk/BitwardenClient.java: 43
MEDIUM Privacy_Violation /languages/java/src/main/java/com/bitwarden/sdk/SecretsClient.java: 138
MEDIUM Privacy_Violation /languages/java/src/main/java/com/bitwarden/sdk/SecretsClient.java: 41
MEDIUM Privacy_Violation /languages/java/src/main/java/com/bitwarden/sdk/SecretsClient.java: 41
MEDIUM Privacy_Violation /languages/java/example/Example.java: 53
MEDIUM Privacy_Violation /languages/java/src/main/java/com/bitwarden/sdk/SecretsClient.java: 20
MEDIUM Unpinned Actions Full Length Commit SHA /release-cli.yml: 58
MEDIUM Unpinned Actions Full Length Commit SHA /build-cli.yml: 338
MEDIUM Unpinned Actions Full Length Commit SHA /release-cli.yml: 192
MEDIUM Unpinned Actions Full Length Commit SHA /build-cli-docker.yml: 54
MEDIUM Unpinned Actions Full Length Commit SHA /build-cli-docker.yml: 61
MEDIUM Unpinned Actions Full Length Commit SHA /build-cli.yml: 173
MEDIUM Unpinned Actions Full Length Commit SHA /release-cli.yml: 198
MEDIUM Unpinned Actions Full Length Commit SHA /release-cli.yml: 66
MEDIUM Unpinned Actions Full Length Commit SHA /publish-rust-crates.yml: 43
MEDIUM Unpinned Actions Full Length Commit SHA /build-swift.yml: 91
MEDIUM Unpinned Actions Full Length Commit SHA /build-cli-docker.yml: 131
MEDIUM Unpinned Actions Full Length Commit SHA /build-cli.yml: 86
MEDIUM Unpinned Actions Full Length Commit SHA /release-cli.yml: 124

Copy link

codecov bot commented Sep 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.16%. Comparing base (c0859c4) to head (f255347).
Report is 18 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1032      +/-   ##
==========================================
- Coverage   58.18%   58.16%   -0.03%     
==========================================
  Files         197      197              
  Lines       13487    13523      +36     
==========================================
+ Hits         7847     7865      +18     
- Misses       5640     5658      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tangowithfoxtrot tangowithfoxtrot marked this pull request as ready for review September 9, 2024 15:17
@tangowithfoxtrot tangowithfoxtrot requested review from a team and dani-garcia September 9, 2024 15:17
@mzieniukbw
Copy link
Contributor

The #878 have conflicting changes. Maybe you join them together or pick changes individually from other one, so we won't have to redu the testing ?

mzieniukbw
mzieniukbw previously approved these changes Sep 11, 2024
Copy link
Member

@coltonhurst coltonhurst left a comment

Choose a reason for hiding this comment

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

Nice, thanks for the hard work! Just a couple nits...


## Introduction

Composer is used to build PHP Bitwarden client library.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Composer is used to build PHP Bitwarden client library.
Composer is used to build the PHP Bitwarden client library.

- Linux x86_64: `src/lib/linux-x64/libbitwarden_c.so`
- macOS x86_64: `src/lib/macos-x64/libbitwarden_c.dylib`
- macOS aarch64: `src/lib/macos-arm64/libbitwarden_c.dylib`
- If you prefer to build SDK yourself, see [SDK README.md](../../README.md) for instructions.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- If you prefer to build SDK yourself, see [SDK README.md](../../README.md) for instructions.
- If you prefer to build the SDK yourself, see the [SDK README.md](../../README.md) for instructions.

PHP bindings for interacting with the [Bitwarden Secrets Manager]. This is a beta release and might be missing some functionality.
Supported are CRUD operations on project and secret entities.
PHP bindings for interacting with the [Bitwarden Secrets Manager]. This is a beta release and might be missing some
functionality.
Copy link
Member

Choose a reason for hiding this comment

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

Any reason this is on a new line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure. I'll fix it.

$identity_url = "<identity url>";
require_once 'vendor/autoload.php';

$access_token = '<access-token>';
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$access_token = '<access-token>';
$access_token = "<access-token>";

Just a nit, as the others use "

coltonhurst
coltonhurst previously approved these changes Sep 12, 2024
Copy link
Contributor

@mzieniukbw mzieniukbw left a comment

Choose a reason for hiding this comment

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

state_file from README have disappeared ❓

coltonhurst
coltonhurst previously approved these changes Sep 13, 2024
mzieniukbw
mzieniukbw previously approved these changes Sep 13, 2024
dani-garcia
dani-garcia previously approved these changes Sep 18, 2024
## 🎟️ Tracking

https://bitwarden.atlassian.net/browse/SM-1402
(Not part of this ticket, but agreed with @tangowithfoxtrot that it
would make sense to do so)

## 📔 Objective

Automatic PHP Schema generation using quicktype.
The schema is not compatible with previously generated Swaggest based
schema - PHP code changes are required (does not affect the usage,
`README.md` and `example.php` works as before)
Notable code changes:
- Schema class fields are private, no setters or getters. Can only init
the classes via constructor. (Could enable getters in schema generation,
but the quicktype does not respond well with nested arrays that are part
of schema, as a result PHP generated schema file does not compile)
- Schema class constructors are initialized with named arguments, which
is more readable than `new Command(null, null, null, null, null,
$secrets_command, null, null)
- Uses PHP native json serialization, but SDK does not react well to
null fields, so adjusted the code to remove it just before JSON
serialization.
- Separated `AuthClient` into separate file
- Imports with `uses`

## ⏰ Reminders before review

- Contributor guidelines followed
- All formatters and local linters executed and passed
- Written new unit and / or integration tests where applicable
- Protected functional changes with optionality (feature flags)
- Used internationalization (i18n) for all UI strings
- CI builds passed
- Communicated to DevOps any deployment requirements
- Updated any necessary documentation (Confluence, contributing docs) or
informed the documentation
  team

## 🦮 Reviewer guidelines

<!-- Suggested interactions but feel free to use (or not) as you desire!
-->

- 👍 (`:+1:`) or similar for great changes
- 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info
- ❓ (`:question:`) for questions
- 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry
that's not quite a confirmed
  issue and could potentially benefit from discussion
- 🎨 (`:art:`) for suggestions / improvements
- ❌ (`:x:`) or ⚠️ (`:warning:`) for more significant problems or
concerns needing attention
- 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or
indications of technical debt
- ⛏ (`:pick:`) for minor or nitpick changes
@mzieniukbw mzieniukbw dismissed stale reviews from dani-garcia, coltonhurst, and themself via 49b5023 September 18, 2024 12:35
Copy link
Member

@coltonhurst coltonhurst left a comment

Choose a reason for hiding this comment

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

Looks good only two small comments.

languages/php/README.md Show resolved Hide resolved
languages/php/example.php Outdated Show resolved Hide resolved
@tangowithfoxtrot tangowithfoxtrot merged commit 2f1717d into main Sep 18, 2024
74 of 76 checks passed
@tangowithfoxtrot tangowithfoxtrot deleted the sm-1402-review-and-update-php-sdk branch September 18, 2024 13:47
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.

5 participants