Giter VIP home page Giter VIP logo

comfygure's Introduction

npm version CLI dependencies API dependencies npm downloads docker pulls Build Status

comfygure

Encrypted and versioned configuration storage built with collaboration in mind.

Source - Releases - Stack Overflow

asciicast

Features

  • Simple CLI
  • End-to-end AES-256 encryption
  • Multiple formats support (JSON, YAML, environment variables)
  • Git-like Versioning
  • Easy to host on your own

Comfygure is great to manage application configurations for multiple environments, toggle feature flags quickly, manage A/B testing based on configuration files.

It is not a Secret Management Tool, it focus on configurations files, their history, and how teams collaborate with them.

Get Started

On every server that needs access to the settings of an app, install the comfy CLI using npm:

npm install -g comfygure
comfy help

Usage

Initialize comfygure in a project directory with comfy init:

> cd myproject
> comfy init

Initializing project configuration...
Project created on comfy server https://comfy.marmelab.com
Configuration saved locally in .comfy/config
comfy project successfully created

This creates a unique key to access the settings for myproject, and stores the key in .comfy/config. You can copy this file to share the credentials with co-workers or other computers.

Note: By default, the comfy command stores encrypted settings in the comfy.marmelab.com server. To host your own comfy server, see the related documentation.

Import an existing settings file to comfygure using comfy setall:

> echo '{"login": "admin", "password": "S3cr3T"}' > config.json
> comfy setall development config.json
Great! Your configuration was successfully saved.

From any computer sharing the same credentials, grab these settings using comfy get:

> comfy get development
{"login": "admin", "password": "S3cr3T"}
> comfy get development --envvars
export LOGIN='admin';
export PASSWORD='S3cr3T';

To turn settings grabbed from comfygure into environment variables, use the following:

> comfy get development --envvars | source /dev/stdin
> echo $LOGIN
admin

See the documentation to know more about how it works and the remote usage.

License

Comfygure is licensed under the MIT License, sponsored and supported by marmelab.

comfygure's People

Contributors

arturparkhisenko avatar demougin2u avatar djhi avatar floo51 avatar fossabot avatar fzaninotto avatar greenkeeper[bot] avatar hallerpierre avatar jpetitcolas avatar julienmattiussi avatar kmaschta avatar luwangel avatar sedy-bot avatar zyhou 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

comfygure's Issues

Implement non-interactive comfy init command

e.g.

> comfy init
# creates a project using the curent directory name, development environment, a generated passphrase
> comfy init --name foo
# creates a project using the the name 'foo', development environment, a generated passphrase
> comfy init --environments=development,staging,production
# you get the idea

See the discussion here #49

Use STDIN for add command

The current comfy add syntax is counterintuitive:

comfy add dev -f config.json

One has to peek inside the doc to know it. It would be more intuitive to have

comfy add dev '{"login": "admin", "password": "S3cr3T"}'

That way, I could also do

cat config.json | comfy add dev

or any other mix and match of STDIN and STDOUT

Unfriendly error 500 when env name is unknown by comfy

Description

If I try to get for a non existant environment on comfy, then I get a 500 error.

Steps to Reproduce

  1. type "comfy get fake_env"
  2. Get this error message:
The API call returned a 500 HTTP error code
Error: The API call returned a 500 HTTP error code
    at Request._callback (/home/julienm/.nvm/versions/node/v8.10.0/lib/node_modules/comfygure/src/client.js:14:27)
    at Request.self.callback (/home/julienm/.nvm/versions/node/v8.10.0/lib/node_modules/comfygure/node_modules/request/request.js:188:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (/home/julienm/.nvm/versions/node/v8.10.0/lib/node_modules/comfygure/node_modules/request/request.js:1171:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at IncomingMessage.<anonymous> (/home/julienm/.nvm/versions/node/v8.10.0/lib/node_modules/comfygure/node_modules/request/request.js:1091:12)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:111:20)
Unknown error, command aborted.
If the error persists, please report it at https://github.com/marmelab/comfygure/issues

I would be so much better to have an explicit message like

Cannot get env "fake_env", check existing env with "comfy env list"

  • Exact date when the issue happened: 26/03/2019

Get and set one keys

Actually, we have comfy setall your-env, it would be nice to have something like that:

comfy set your-env your-key your-value
comfy get your-env your-key

Do not forget to take into account the case where you-key is object, array or simple value.

comfy setall with absolute path doesn't work

Description

When I run a setall command with an absolute path as the file argument, the client crash.

Steps to Reproduce

  1. Run the following command
comfy setall [env] /my/file.json

Expected behavior: It should retrieve my config

Actual behavior: It doesn't.

Do this issue happen with the default server (https://comfy.marmelab.com)?: Yes

Delete old entry configuration

Let's have the following example:

"parent": {
 "entry": "value"
}

I update my configuration like this:

"parent": {
 "child1": {
  "entry": "value"
 },
"child2": {
  "entry": "value"
 }
}

In database, parent.entry.value is not deleted, but the link with my configuration is removed.
The problem comes from get.

Add date in logs and order them would be fine

Description

When using comfy log my_env, logs are returned not ordered, and there is no information to date them.

Steps to Reproduce

  1. type comfy log existing_env
  2. see the return without order and date

Expected behavior:

Something like:

development	2019-04-17 10:50:01 964e51df37c0fe2a518998fb6457b461c4013d28	(next)
development	2019-04-17 10:45:31 43990ed1b72b77a5bcaa6514a05e7bd773d1c482	(no tag)
development	2019-04-17 10:40:07 de9b94fdfc4d952a2efcf6ef81c7085cd00cd6c4	(no tag)
development	2019-03-17 09:40:01 5582a12fa38e60e500a92aa835c842b792aeac1e	(stable)

Actual behavior:

development	964e51df37c0fe2a518998fb6457b461c4013d28	(next)
development	5582a12fa38e60e500a92aa835c842b792aeac1e	(stable)
development	43990ed1b72b77a5bcaa6514a05e7bd773d1c482	(no tag)
development	de9b94fdfc4d952a2efcf6ef81c7085cd00cd6c4	(no tag)

Do this issue happen with the default server (https://comfy.marmelab.com)?: Yes

  • Exact date when the issue happened: 2019-04-17

ENVVARS format doesn't escape things !

With ENVVARS like:

SOMETHING_URL=http://whatever.com/admin/#/something
WHATEVER=It's working

Calling something like:

$(eval ENVVARS = $(shell ./node_modules/.bin/comfy get integration --envvars))

It breaks because the cli actually echoes:

export SOMETHING_URL="http://whatever.com/admin/#/something";
export WHATEVER="It's working";

It happens for hash and quotes but it could happen with anything like string interpolation.

Possible solution: put single quotes.

Remove the `object-hash` dependency from the API

Rationale

For now, we use object-hash to get a hash of configuration version.
We want to remove this dependency and write our own hashing function.

Details

Here is an example of the new API:

const currentVersion = {
    hash: '000000000000000000000000', // Already computed unique hash
    entries: {
        A: 'value A',
    },
};

const newVersion = {
    // ...
    entries: {
        A: 'value A',
        B: 'value B',
    },
};

const hash = getHash(newVersion.entries, currentVersion.hash); // Should be a unique hash
// or, if there is no precedent version (for example for the first version)
const hash = getHash(newVersion.entries);

The idea is to concatenate the following values:

[PRECEDENT VERSION HASH] + [ENTRY KEY 0] + [ENTRY VALUE 0] + [ENTRY KEY 1] ...
eg: 000000000000000000000000 A value A B value B

or, for no precedent version

[ENTRY KEY 0] + [ENTRY VALUE 0] + [ENTRY KEY 1] +  [ENTRY VALUE 1] ...

Then, get a unique hash of this character chain. You can use the native Node.JS crypto module to find the better way to do this.

Requirements

  • The code MUST be tested
  • The transpiled code should be compatible with Node 6 (see node.green)
  • The hash MUST be unique for two different strings getHash({ a: 1 }) !== getHash({ b: 2 })
  • The hash MUST be the same for the same string getHash({ a: 1 }) !== getHash({ a: 1 })

It is highly recommended to write the tests first and then code the function.
Feel free to ask your questions here!

What about the storage of booleans?

Let's have the following example:

> cat '{ "myvar": false }' > test.json
> comfy add production -f test.json

What is retrieved will depends on the format:

> comfy get production --envars
MYVAR='false'
> comfy get production --yml
myvar: false
> comfy get production --json
{
    "myvar": "false"
}

As you can see in JSON and environment variables, the boolean false is transformed in string.
This is a problem, especially in JSON, because:

Boolean('false') === true

And I'm not sure how to handle this case.

Add output option to save result in a file

Description

Currently, saving a comfy get result into a file need to be done manually like this, by example:

comfy get test > config/test.js

But if something goes wrong with comfy (network down, server down, configuration doesn't exists), then It erases all the previous test.js file and replaces it with the comfy error message

It would be very nice to have an explicit output command inside comfy to assure this to not happen

Steps to Reproduce

  1. Create a test.js file
  2. Type something inside and save it
  3. Do: comfy get testRandom > test.js
  4. Open your file and see that all is erased
  • Exact date when the issue happened: 2019-06-18

Optimize E2E test execution

This is the benchmark for one test:

  Basic Usages
    accessors
exec command: "comfy init --origin 'http://localhost:3000'": 762.499ms
PROJECT CREATION REQUEST: 84.690ms (api request)

exec command: "echo '{"login":"admin","password":"S3cret"}' > test.json": 3.164ms
exec command: "comfy setall development test.json": 492.143ms
exec command: "comfy get development": 435.218ms
exec command: "echo '{"login":"admin"}' > test.json": 3.501ms
exec command: "comfy setall development test.json": 442.185ms
exec command: "comfy get development": 370.392ms
      โœ“ should retrieve the latest version by default (1748ms)


  1 passing (3s)

On this benchmark, you can see that the API request take 80ms and the command result is 762ms.
This cause test timeout, that we want to avoid.

TODO

  • Find why the commands are so slow
  • Remove the 5s timeout for mocha tests in test/Makefile

How not to store the private key in plain text?

Currently, the private key used te encrypt and decrypt the config values is stored inside the .comfy/config file in clear text.

It would be better to store this private key (and some perhaps some other crypto informations) into a secure file like .comfy/privatekey or something.

I thought of some implementations, but none of them are satisfactory from the security and/or UX standpoint.

Any idea on how to implement a solution that is both secure and easy to use?

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.