Git Product home page Git Product logo

cli's Introduction

Bitwarden

GitHub Workflow browser build on main GitHub Workflow CLI build on main GitHub Workflow desktop build on main GitHub Workflow web build on main gitter chat


Bitwarden Client Applications

This repository houses all Bitwarden client applications except the Mobile application.

Please refer to the Clients section of the Contributing Documentation for build instructions, recommended tooling, code style tips, and lots of other great information to get you started.

Related projects:

We're Hiring!

Interested in contributing in a big way? Consider joining our team! We're hiring for many positions. Please take a look at our Careers page to see what opportunities are currently open as well as what it's like to work at Bitwarden.

Contribute

Code contributions are welcome! Please commit any pull requests against the main branch. Learn more about how to contribute by reading the Contributing Guidelines. Check out the Contributing Documentation for how to get started with your first contribution.

Security audits and feedback are welcome. Please open an issue or email us privately if the report is sensitive in nature. You can read our security policy in the SECURITY.md file.

cli's People

Contributors

addisonbeck avatar bullshit avatar cscharf avatar differsthecat avatar djsmith85 avatar eliykat avatar estheruary avatar gep13 avatar github-actions[bot] avatar hinton avatar ivankovnatsky avatar jacalz avatar jarimatti avatar joseph-flinn avatar kkusch avatar kspearrin avatar kwkelly avatar libertylocked avatar luckymee avatar mgibson1 avatar mimartin12 avatar muniftanjim avatar operator-name avatar philser avatar plett avatar sangxxh avatar simon04 avatar snyk-bot avatar vgrassia avatar vincentsalucci avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cli's Issues

2FA method and code parameter lead to false login message

bitwarden-cli version 1.1.0 on macOS 10.13.6

The account has 2FA enabled via Authenticator App. I can login successfull via cli this way:

bw login <user> <pw> --code <code>

If I do bw login <user> <pw> --method 0 [ or 5] --code <random-code> where is NOT a valid code from the Authenticator app but just arbitrary numbers - the result is

You are not logged in.`

...
$ bw list items --session cJ1xGm7zjtw+xHdIEOiJ//wRgMT4y/XXXXXXXXXXXX8OeH/C4NOOAym9qN9e/TdCwBpYKaCacA8mSEDX3LeQ==

This message is falsely returned I believe as I cannot use the session id, bitwarden tells me that I am not logged in - which is then again correct.

So security wise that's not an issue but it's still not the correct behavior I would assume.

Unable to install bw as root

Hi BitWarden team,

I am trying to install bitwarden cli in my remote instance, but I am stuck at the installation stage itself.

So far, I've tried installing via npm

[email protected] /nix/store/hshlb7ysskab4pa0vqabz50kv9mc1cjd-nodejs-8.11.4/lib/node_modules/npm
root@pup:~# npm install -g @bitwarden/cli
/nix/store/hshlb7ysskab4pa0vqabz50kv9mc1cjd-nodejs-8.11.4/bin/bw -> /nix/store/hshlb7ysskab4pa0vqabz50kv9mc1cjd-nodejs-8.11.4/lib/node_modules/@bitwarden/cli/build/bw.js

> [email protected] postinstall /nix/store/hshlb7ysskab4pa0vqabz50kv9mc1cjd-nodejs-8.11.4/lib/node_modules/@bitwarden/cli/node_modules/tldjs
> node ./bin/postinstall.js

sh: 1: node: Permission denied
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] postinstall: `node ./bin/postinstall.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-10-20T12_49_53_640Z-debug.log
root@pup:~# npm install [email protected]

> [email protected] postinstall /root/node_modules/tldjs
> node ./bin/postinstall.js

npm WARN saveError ENOENT: no such file or directory, open '/root/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/root/package.json'
npm WARN root No description
npm WARN root No repository field.
npm WARN root No README data
npm WARN root No license field.

+ [email protected]
added 2 packages in 1.005s
root@pup:~# ^C
root@pup:~# ls
clojerl  euamoabhi  FStar  miniconda3  node_modules  nostrand  package-lock.json  packages.txt  projects  python_log
root@pup:~# rm -rf node_modules/
root@pup:~# npm install -g [email protected]

> [email protected] postinstall /nix/store/hshlb7ysskab4pa0vqabz50kv9mc1cjd-nodejs-8.11.4/lib/node_modules/tldjs
> node ./bin/postinstall.js

sh: 1: node: Permission denied
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] postinstall: `node ./bin/postinstall.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-10-20T12_51_02_269Z-debug.log

And also with snap

root@pup:~# snap install bw
snap "bw" is already installed, see 'snap help refresh'

However, it doesn't sense bw on the cli

root@pup:~# bw
bw: command not found

Could you please help me out a bit ?

Feature request: list item names

Hi,

Could you implement an option to list the item names in the vault?

Similar to:

bw list items | jq -r '.[]?.name'

Gr, Justin

Trying to edit custom fields boolean from cli?

Am I missing something, or is it currently no support to edit a custom field? Lets say I have a custom boolean field, I'd like to swap between checked and unchecked form the command line, but there seems to be no support for this?

Failed sync reported as successful

Since I'm using bitwarden in conjunction with a self signed certificate the sync doesn't work (without the workaround mentioned in #9).
However it is still reported as successful:

$ bw sync --session ***
Syncing complete.

Interestingly, the last sync date is correct / doesn't get updated:

$ bw sync --last --session ***
2018-05-28T15:49:04.015Z

Typed password is visible on git for windows mintty bash prompt

On windows when using git for windows mintty terminal and bw asks for password, it is echoed to the terminal (here aaaaa was the typed password):

$ bw unlock
? Master password: [input is hidden] aaaaa
? Master password: [hidden]

In cmd.exe it works correctly with nothing echoed back.

CLI doesn't support deleting collections

According to the documentation it should be possible to delete collections.

However the local help text of the delete command lists only these deletable objects:

Objects:
  item
  attachment
  folder

I wasn't able to delete collections.

Create a new Account using CLI

My organisation would love to be able to add new users using the cli.
This would enable us to make this a part of our onboarding process which would force the users to use bitwarden as intended by us.
Will this come as a feature?

bw list shows folders bw delete cannot remove

Running 1.7.0 on Powershell 5.1, installled via Chocolatey (if it matters)

Whenever I sync, after being logged on and fetching a Session Key by using "bw unlock --raw" and I try to do a check to see if an entry exists, "bw list" returns folders not existing anymore. I cannot delete them via "bw delete" either. Whenever I try, I get a "Resource not found". No matter how many times I sync, they cannot be removed.
They don't show in the web interface as well.

Unique exit codes

Similar to #28, this issue is about using unique exit codes for the different types of errors. For example, instead of exiting with 1 for every error, not logged in could return 1, but locked vaults could return 2. I would hope this could be extended to all states: "more than one result found", etc. so that we could refer to a documented mapping of exit codes and errors.

Thanks!

getting attachment by exact name

I'm bumping into a minor issue when two attchments are similar, and I want to fetch them by exact name rather than id.

A typical example: id_rsa and id_rsa.pub ...

If I fetch bw get attachment id_rsa.pub --itemid <...> this works great.

But if I try to fetch bw get attachment id_rsa --itemid <...>, then I get

More than one result was found. Try getting a specific object by id instead. The following objects were found:

Yes, I can do some minor jq acrobatics and fetch the id, but I hope it can be simplified on the cli if possible (maybe a flag)? worth asking... :)

Unknown cipher type

$bw --version
1.0.1
$bw get template item
{"organizationId":null,"folderId":null,"type":1,"name":"Item name","notes":"Some notes about this item.","favorite":false,"fields":[],"login":null,"secureNote":null,"card":null,"identity":null}

$echo '{"name":"Teste"}' | bw encode | bw create item
(node:21967) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): Error: Unknown cipher type.
(node:21967) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Extract item by organization

Hi,
I'm trying to extract item by organization name, where I have items for (for example) API_URL stored in a DEV organization and a PRODUCTION organization.

Is it possible to do something via the CLI like this?

bw get API_URL --organization DEV

That way I can keep the item names the same across different organizations. Yes, I could just have DEV_API_URL and PRD_API_URL, and programatically get round it, but that seems a bit ... hacky.

Hope that makes sense.

Andy

Import / Edit of organistation folder

I have a task that I am unsure if can be done in Bitwarden CLI, and how.

I have an organisation folder. (Backends). I would like to replace the password of all logins in this folder by using the CLI.

I am considering 2 approaches.

  1. Delete the current folder, Create a new organisation folder and import alle the logins using the import functionality.
  2. Get a list of all entries within the organisation folder, and edit the password one by one.

What is the best/easiest solution?
Does CLI support editing organisation folders/logins?

Duo support in CLI?

Hi,

Any reason for Duo not being supported in the CLI client?

It seems the jslib auth.service already supports Duo:
https://github.com/bitwarden/jslib/blob/f16fc58d707b9ed55355e62440fb95185f972090/src/services/auth.service.ts

And there are valid methods for Duo in the CLI:

// CONCATENATED MODULE: ./jslib/src/enums/twoFactorProviderType.ts
var TwoFactorProviderType;
(function (TwoFactorProviderType) {
    TwoFactorProviderType[TwoFactorProviderType["Authenticator"] = 0] = "Authenticator";
    TwoFactorProviderType[TwoFactorProviderType["Email"] = 1] = "Email";
    TwoFactorProviderType[TwoFactorProviderType["Duo"] = 2] = "Duo";
    TwoFactorProviderType[TwoFactorProviderType["Yubikey"] = 3] = "Yubikey";
    TwoFactorProviderType[TwoFactorProviderType["U2f"] = 4] = "U2f";
    TwoFactorProviderType[TwoFactorProviderType["Remember"] = 5] = "Remember";
    TwoFactorProviderType[TwoFactorProviderType["OrganizationDuo"] = 6] = "OrganizationDuo";
})(TwoFactorProviderType || (TwoFactorProviderType = {}));

Or is it just no time/not a priority?

If it will help, there's an NPM Duo API module here:
https://www.npmjs.com/package/@duosecurity/duo_api

With docs for the auth here:
https://duo.com/docs/authapi#/auth

Thanks!

Permission issues when installed via snap on Ubuntu18.04

Hi Bitwarden team

I installed the bitwarden cli via snap install bitwarden however when I try to run bitwarden login this is the error I come across

 2018-10-24 01:25:44 ⌚  pup in ~
○ → bitwarden login
ln: failed to create symbolic link '/root/snap/bitwarden/11/snap/bitwarden/11/Documents': No such file or directory
ln: failed to create symbolic link '/root/snap/bitwarden/11/snap/bitwarden/11/Desktop': No such file or directory
ln: failed to create symbolic link '/root/snap/bitwarden/11/snap/bitwarden/11/Downloads': No such file or directory
ln: failed to create symbolic link '/root/snap/bitwarden/11/snap/bitwarden/11/Music': No such file or directory
ln: failed to create symbolic link '/root/snap/bitwarden/11/snap/bitwarden/11/Pictures': No such file or directory
ln: failed to create symbolic link '/root/snap/bitwarden/11/snap/bitwarden/11/Videos': No such file or directory
ln: failed to create symbolic link '/root/snap/bitwarden/11/snap/bitwarden/11/Public': No such file or directory
ln: failed to create symbolic link '/root/snap/bitwarden/11/snap/bitwarden/11/Templates': No such file or directory


Could you please help me out a bit ?

Release Hashes

Would it be possible to have sha256 hashes on the release page? This allows for downloads to be verified and can help increase security when building from sourcecode.

Keep vault perpetually unlocked?

I know this wouldn't be the best for security reasons, but for the application I'm going to be using it for it would be awesome if I could somehow keep the cli vault unlocked after unlocking it once?

Maybe on reboot it could lock or whatever, but ideally this would be a login once and you're in for good sort of thing.

I see this in the docs: "It is possible to persist your session key to your environment (for example, exporting it in .bashrc), however, we do not recommend doing this." although it seems I still need to unlock it on every new shell session?

Is this possible somehow, to just stay logged in?

"mac failed." When getting attachments

Hello,

When I was trying to download one of my attachments, the CLI had some weird behavior:

PS E:\Go\src\github.com\vwxyzjn\portwarden\cmd\portwarden> bw get attachment q5kvo3v8ywm2d8ggusjswv8xizlyfwjq --itemid a1de07cd-121d-4eb8-a46a-a9af01149a3b --session EdDKYVuLymrop3NPtjvbkn5PoLc505n2C8hUvcr4zxGmWoBRcSnaWeJZLN13PJbs0WIqh6CmSMmCe4rFlZm31w== --output ./
mac failed.
An error occurred while saving the attachment.
PS E:\Go\src\github.com\vwxyzjn\portwarden\cmd\portwarden> bw get attachment au1rlkl8o1uq26522w6f1bvemt7uhx5k --itemid a1de07cd-121d-4eb8-a46a-a9af01149a3b --session EdDKYVuLymrop3NPtjvbkn5PoLc505n2C8hUvcr4zxGmWoBRcSnaWeJZLN13PJbs0WIqh6CmSMmCe4rFlZm31w== --output ./
mac failed.
An error occurred while saving the attachment.
PS E:\Go\src\github.com\vwxyzjn\portwarden\cmd\portwarden> bw get attachment hdj7uipykiga1hyj55z0m9iyabp8e49j --itemid 51645f39-16e6-4f3d-bfb8-a8ef0145f25f --session EdDKYVuLymrop3NPtjvbkn5PoLc505n2C8hUvcr4zxGmWoBRcSnaWeJZLN13PJbs0WIqh6CmSMmCe4rFlZm31w== --output ./
Saved E:\Go\src\github.com\vwxyzjn\portwarden\cmd\portwarden\2015-2017 South Carolina Document of Registration.pdf
PS E:\Go\src\github.com\vwxyzjn\portwarden\cmd\portwarden>

I could get all of the other attachments, but this particular one returns "mac failed" error. Not sure what's going on.

feature: commands to check if logged in

Commands in the fashion of

bw login --check
# exit code 0 if logged in or 1 if logged out

This will be useful for building commands on top of the cli. Specifically with this package I built bitwarden-dmenu, it would be useful to know if the user has logged in before trying to unlock so I can send a useful error to the user

`export` should export attachments too

Running v.1.7.0 on Arch Linux 5.0.3.

I want to use the export command to export my entire vault as a backup. In doing so i noticed that neither the csv or json exports contain any copy of or information about attached files. This makes my backup incomplete.

I know I can download attachments using get attachment <filename> --itemid <itemid>, and I could write a script to go through and save these, but ideally an export command should already export everything. Any custom solution I implement is not going to work with import either, which is not ideal.

Maybe the command could include any attachments as base64 encoded entries in the json/csv structure? Of course this would have to work in the reverse when you use import with the bitwardencsv/bitwardenjson entries.

Self signed certificate support

Since Node.js uses a built-in certificate store, I have to use the following workaround the get the CLI working with my self signed certificate:

NODE_EXTRA_CA_CERTS=<path to my ca> bw login

There should be an option (e.g. config setting, specific environment variable, ...) for the CLI to permanently trust a self signed CA.

CLI create attachment bug

Hi

We use Bitwarden cli a great deal and we recently decided to start uploading some attachments to some of our logins, by script.
When we call:

bw --session $sessionKey create attachment --file $pathToAttachment --itemid ($item.id)

We get the item returned but no where is the attachment visible.
The item is shared in an organization.
The user has write access to the collection in which the item resides.

Since there is nothing indicating an error has occoured we are stuck :).

Returned:
`
{
"object": "item",
"id": "X",
"organizationId": "Y",
"folderId": null,
"type": 1,
"name": "Z",
"notes": "-",
"favorite": false,
"login": {
"uris": [

],
"username": "-",
"password": "-",
"totp": "-",
"passwordRevisionDate": null

},
"collectionIds": [
"XYZ"
],
"revisionDate": "2019-03-29T14:12:20.800Z"
}
`

CLI returns [object Object] when logging in

When issuing the bw login command, entering my e-mail address and then my master password, the CLI client returns [object Object]:

image

When running with the --response flag, the response is {"success":false,"message":"[object Object]"}.

My account has 2FA TOTP enabled. This is the CLI client version 1.7.2 installed from Homebrew on macOS 10.14.4.

TOTP not working for organization in self-hosted config

Bitwarden version 2.5.0, self-hosted on via Linux docker, with registered paid organizeation.

I can access TOTP codes that are shared with the organization via the web plugin, but cli keeps on claiming:
"Premium status is required to use this feature."

flic-totp

image

jsdom and webpack build problems

In 1.7.0 when running webpack build, the bw.js bundle came with all the dependencies, which is excellent and can be used anywhere nodejs is installed. We can basically run node /usr/lib/bitwarden-cli/bw.js without having to use the binary built by pkg (since it's got a pretty fat nodejs runtime in it).

1.7.1 added jsdom and the webpack config doesn't build external node_modules into the bundle anymore, making it pretty difficult to use standalone.

I tried removing the externals from webpack.conf.js but it had some issue with canvas module not found.

I wonder if it's still possible to build a standalone javascript bundle?

Invalid JSON output for `list items`, possible too many items?

I get invalid JSON when I list all items in my vault.

Here are my test cases:

bw list items | python -mjson.tool
bw --response list items | python -mjson.tool

When doing --response and manually looking at the output, there's a lack of closing } to one of the items and then the output is cut off (no closing symbols for the parent elements).

Expecting ',' delimiter: line 1 column 65488 (char 65487

If I remove the --response part then I get an "unterminated string" error.

Unterminated string starting at: line 1 column 65465 (char 65464)

Hint: Both are suspiciously close to 2¹⁶ = 65536. 🤔

Hint: With the envelope from --response, the item that is cut off is earlier in the output.

Hint: If I search for any single normal letter like a or e I still get the error. If I add another letter so I would get fewer results, then everything works.

Hint: This is not a bug in Python; I'm just using Python as a simple test case. I get the same problem no matter which JSON library or program I use; even raw output can be verified to not being closed correctly.


I suspect that whatever code is writing to STDOUT is not buffering correctly, so it actually writes the maximum number of bytes that it allows and returns that number, but then the method does not write the next chunk of the buffer.

int written = fwrite(stdout, all_the_json, strlen(all_the_json));
// written is now close to 2**16, which could be < strlen(all_the_json).

// Something like this might solve it..?

int offset = 0;
int written = 0;
int len = strlen(all_the_json);

while (written < len) {
  written += fwrite(stdout, all_the_json + offset, len - offset);
}

As this codebase is written in JS/Node, then this kind of API would be hidden behind JS-specific abstractions. This Stack Overflow post seems to talk about a similar problem.

Bitwarden CLI Beta Test

The Bitwarden CLI is now available as a public beta test.

CLI

Download/Install

NPM

npm install -g @bitwarden/cli

Native Executables

During this beta test, you can download the latest executables for Windows, macOS, and Linux from our CI build artifacts, here: https://ci.appveyor.com/project/bitwarden/cli/build/135/artifacts

Documentation

See help center article with detailed documentation here: https://help.bitwarden.com/article/cli/

Feedback

Provide any bug reports, questions, and/or feedback in this issue. Please do not open a new issue.

Also, please provide feedback on the help documentation at https://help.bitwarden.com/article/cli/

Unable to login using the CLI

Hello everyone,

Could you please help me in resolving the following error

○ → bw login
? Email address: [email protected]
? Master password: [hidden]
request to https://api.bitwarden.com/accounts/prelogin failed, reason: getaddrinfo ENOTFOUND api.bitwarden.com api.bitwarden.com:443

I checked the password via logging into the Desktop Bitwarden app with the credentials, it works there.

Import fails

I have tried to everything and this works fine. However whenever I try to import the same file I get the following error

I am importing using this command.

bw import bitwardencsv ./backups/import.csv --session MY-SESSION-KEY-IS-HERE

I have tried both changing some passwords in the file, but i have also tried without editing anything. I dont understand how the structure of the file can be wrong, even when it is an untouched copy of the file i exported.

Here is the error

Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Error parsing row undefined: Unable to auto-detect delimiting character; defaulted to ','
Cannot read property 'message' of null

Import support from command line.

For users that prefer to stay away from the web vault and for scripting bulk operations.

Benefits:

  • unencrypted data never has to touch a web browser
  • self-hosting the backend requires extra effort
  • for people who use a non-standard backend (I'm currently in love with https://github.com/vvondra/bitwarden-serverless but this is also true for whoever uses the ruby implementation) there's a fair amount of extra work to get the vault running.

It would be awesome to support doing this from the CLI, since 90% of the work is already done in jslib.

I intend to take on this work and implement it as follows:

  1. Recreate the generic import logic from web in jslib as importer.service.
  2. wrap that service from the CLI just like export does.
  3. open jslib pull request, and once it's closed and released, open the cli changes as another.
  4. go back and refactor web to use the new importer service, and submit as a separate pull request.

Please let me know if you have reservations about any of that.

bw get password [uri] only matches first URI entry

I noticed that when trying to get the password from a URI, it only works if you try to find the first of the defined URI's. Take for example following entry:

{
  "object": "item",
[..]
  "login": {
    "password": "thispassword",
    "uris": [
      {
        "match": null,
        "uri": "firsturl.eu"
      },
      {
        "match": null,
        "uri": "secondurl.io"
      }
    ],
[..]
}

If you'd try bw get password firsturl.eu you would get thispassword as response.
When executing bw get password secondurl.io you get Not found.

Logo design

Hello. I want to design a logo for you. If you like it, I will give you a present. What do you think?

[FEATURE] Create organization item via CLI

I tried to create an item with an organization id set but all I get is "The model state is invalid.", without setting the organizationId it works.

Environment:
Self-Hosted on docker
Admin user role
Logged in with two factor authentication via bw login and setting the BW_SESSION environment variable

bw get template item | jq '.login = {"uris":null,"username":"jdoe","password":"myp@ssword123","totp":null}' | jq '.name = "test"' | jq '.organizationId = "XXX-XXX-XXX-XXX"' | bw encode | bw create item

My questions now is, is it supported to create a shared item via CLI or do I have some problem with my setup?

Error trying to create basic item

Hi,

I'm trying to create a basic item via the CLI:

bw get template item | jq '.name = "dev_mariadb_master_pvc"' | bw encode | bw create item

But doing this, I get the error:

(node:25703) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'uris' of null at Function.toView (/snapshot/cli/build/bw.js:95146:17) at Function.toView (/snapshot/cli/build/bw.js:95232:49) at create_command_CreateCommand.<anonymous> (/snapshot/cli/build/bw.js:102561:82) at Generator.next (<anonymous>) at create_command_awaiter (/snapshot/cli/build/bw.js:102511:71) at new Promise (<anonymous>) at create_command_awaiter (/snapshot/cli/build/bw.js:102507:12) at create_command_CreateCommand.createCipher (/snapshot/cli/build/bw.js:102560:16) at create_command_CreateCommand.<anonymous> (/snapshot/cli/build/bw.js:102549:39) at Generator.next (<anonymous>) (node:25703) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:25703) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. root@util:~/devenv# bw get template item | jq '.name = "dev_mariadb_master_pvc"' | bw encode | bw create item (node:25773) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'uris' of null at Function.toView (/snapshot/cli/build/bw.js:95146:17) at Function.toView (/snapshot/cli/build/bw.js:95232:49) at create_command_CreateCommand.<anonymous> (/snapshot/cli/build/bw.js:102561:82) at Generator.next (<anonymous>) at create_command_awaiter (/snapshot/cli/build/bw.js:102511:71) at new Promise (<anonymous>) at create_command_awaiter (/snapshot/cli/build/bw.js:102507:12) at create_command_CreateCommand.createCipher (/snapshot/cli/build/bw.js:102560:16) at create_command_CreateCommand.<anonymous> (/snapshot/cli/build/bw.js:102549:39) at Generator.next (<anonymous>) (node:25773) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:25773) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I can create a folder fine using your documentation example:
bw get template folder | jq '.name = "My Folder"' | bw encode | bw create folder

Can you help by providing working item creation code, for a secure note, please?

Regards,
Andy

Error while creating an entry

I'm trying to create multiple login/password entries from the cli. If I try to create:

{ "organizationId": null, "folderId": "xxxxxxxxx-xxxx-xxxx-xxxxxx", "type": 1, "name": "name", "notes": "Some notes about this item.", "favorite": false, "fields": [], "login": null, "secureNote": null, "card": null, "identity": null, "note": "" }

I get

(node:24307) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'uris' of null
    at Function.toView (/snapshot/cli/build/bw.js:40339:17)
    at Function.toView (/snapshot/cli/build/bw.js:30719:84)
    at CreateCommand.<anonymous> (/snapshot/cli/build/bw.js:82471:124)
    at Generator.next (<anonymous>)
    at __awaiter (/snapshot/cli/build/bw.js:82421:71)
    at new Promise (<anonymous>)
    at __awaiter (/snapshot/cli/build/bw.js:82417:12)
    at CreateCommand.createCipher (/snapshot/cli/build/bw.js:82470:16)
    at CreateCommand.<anonymous> (/snapshot/cli/build/bw.js:82459:39)
    at Generator.next (<anonymous>)
(node:24307) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:24307) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

What did I miss? The doc doesn't show how to create a login/password item.

Ambiguous error message for incorrect master password or two-step code

If a user inputs an incorrect password, the output is The model state is invalid ... which is the same error message for an incorrect two-step verification code. It'd be preferable if the error codes had some uniqueness to them (e.g. "incorrect master password entered") so that we could parse that easier in scripts.

keepass2xml import fails with "DOMParser is not defined"

When doing bw import keepass2xml someexport.xml it fails with "DOMParser is not defined". A brief glance of the code leads me to think that the code is attempting to use DOMParser in Node.js, which is a browser API and isn't available in Node.

Passwords with spaces fail login and unlock

When logging in or unlocking by passing the password as an argument to the bw login or unlock commands the login or unlock fails. This does not happen if I do not pass the password as an argument and enter it at the prompt.

bw unlock 'password with spaces'
Invalid master password.

fzf helper

I just wanted to post, i use fzf regularly. and i managed to make a helper to easily search for a login and copy the password to the clipboard using xclip. To use this you need:

fzf
jq
xclip

and in your bash or zsh profile, add this function

bwcopy() {
  if hash bw 2>/dev/null; then
    bw get item "$(bw list items | jq '.[] | "\(.name) | username: \(.login.username) | id: \(.id)" ' | fzf-tmux | awk '{print $(NF -0)}' | sed 's/\"//g')" | jq '.login.password' | sed 's/\"//g' | xclip -sel clip
  fi
}

Then source the file to activate, then just run bwcopy and you will see a list of all of your logins in the format:

name: [name] | username: [username] | id: [id]

start typing the name of the login, and when you select one with [enter] it will copy the password field to your clipboard. I thought this helper might be able to be added to the docs somewhere on https://help.bitwarden.com/article/cli/#get

I hope others find it useful

Scripting and command subsitution input prompts not showing

I'm trying to script in bash with the bitwarden cli, but I'm having some issues trying to login or unlock within a command substitution. Within a command substitution, the prompts do not show up.

For example: bw unlock --raw works just fine, but if I try to capture that output, no prompts show up. So session=$(bw unlock --raw) won't ask for the password.

I think it may be an issue with inquirer.js, so I also filed an issue with them here.

Login don't show password *

At least in Linux it's not common to show * when you type in a password (I think this is for safety reasons)

So I would recommend to change the password input at the login to an input which doesn't show the *

Provide an URI match command or option

I'm implementing a bitwarden keyring backend using bitwarden-cli. I'll be provided with a URL and a username, and will need to return the appropriate password. I'd like to be able to use the full system of URI matching that's in place in other clients (especially in browser extensions) but that may prove complicated if I have to reimplement the whole logic on my side. I'm guessing that bitwarden cli has this functionnality in its code already, but if I'm not mistaken, it's not exposed. Is there a way this could be exposed somehow ? Maybe a bw list --match-uri=<match> ?

Export of organization entries is not possible

I can share passwords to organization, in this case the password entry will be transfered to the organization vault. In web UI i can perform csv export for user and organization, but i can only export user entries via cli. Is it possible to export/import organization entries? I could not found any options on the help page.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.