Esempio n. 1
0
def main():
    io.activate()
    try:
        repo = Repository("")
    except NoSuchRepository:
        io.stderr("{} Not inside a bundlewrap repository".format(red("!")))
        sys.exit(1)
    my_path = pathlib.Path(__file__).parent.absolute()
    relpath = my_path.relative_to(repo.path)
    if not str(relpath).startswith("collections/"):
        io.stderr(
            "{} Collection should be installed to <repo>/collections".format(
                yellow("!")))
        sys.exit(1)
    install_dir(my_path / "hooks", repo.hooks_dir)
    install_dir(my_path / "libs", repo.libs_dir)
    install_dir(my_path / "items", repo.items_dir)
Esempio n. 2
0
from bundlewrap.utils.ui import io
from passlib.hash import apr_md5_crypt, sha512_crypt
from requests import Session

CONFIG_PATH = expanduser(
    environ.get("BW_TEAMVAULT_SECRETS_FILE", "~/.bw_teamvault_secrets.cfg"))
DUMMY_MODE = environ.get("BW_TEAMVAULT_DUMMY_MODE", "0") == "1"

cache = {}
config = SafeConfigParser()
try:
    config.read([CONFIG_PATH])
except:
    io.stderr("{x} WARNING: Unable to read TeamVault config at {path}".format(
        path=CONFIG_PATH,
        x=yellow("!"),
    ))
sessions = {}


def _fetch_secret(site, secret_id):
    try:
        return cache[site][secret_id]
    except KeyError:
        pass

    session = sessions.setdefault(getpid(), Session())

    try:
        full_url = "{}/api/secrets/{}/".format(
            config.get(site, "url"),
Esempio n. 3
0
from bundlewrap.utils.ui import io
from passlib.hash import apr_md5_crypt, sha512_crypt
from requests import Session

CONFIG_PATH = expanduser(
    environ.get("BW_TEAMVAULT_SECRETS_FILE", "~/.bw_teamvault_secrets.cfg"))
DUMMY_MODE = environ.get("BW_TEAMVAULT_DUMMY_MODE", "0") == "1"

cache = {}
config = ConfigParser()
try:
    config.read([CONFIG_PATH])
except:
    io.stderr("{x} WARNING: Unable to read TeamVault config at {path}".format(
        path=CONFIG_PATH,
        x=yellow("!"),
    ))
sessions = {}

for site_name, site_config in config.items():
    if (('password' not in site_config or not site_config['password'])
            and 'pass_command' in site_config):
        try:
            config[site_name]['password'] = check_output(
                site_config['pass_command'],
                shell=True).decode('UTF-8').splitlines()[0].strip()
        except (FileNotFoundError, CalledProcessError, IndexError) as e:
            io.stderr("{x} TeamVault pass_command for site {site} failed: {e}".
                      format(x=yellow('!'), site=site_name, e=repr(e)))

Esempio n. 4
0
from bundlewrap.utils.text import bold, mark_for_translation as _, yellow
from bundlewrap.utils.ui import io
from passlib.hash import apr_md5_crypt, sha512_crypt
from requests import Session

CONFIG_PATH = expanduser(environ.get("BW_TEAMVAULT_SECRETS_FILE", "~/.bw_teamvault_secrets.cfg"))
DUMMY_MODE = environ.get("BW_TEAMVAULT_DUMMY_MODE", "0") == "1"

cache = {}
config = SafeConfigParser()
try:
    config.read([CONFIG_PATH])
except:
    io.stderr("{x} WARNING: Unable to read TeamVault config at {path}".format(
        path=CONFIG_PATH,
        x=yellow("!"),
    ))
sessions = {}


def _fetch_secret(site, secret_id):
    try:
        return cache[site][secret_id]
    except KeyError:
        pass

    session = sessions.setdefault(getpid(), Session())

    try:
        full_url = "{}/api/secrets/{}/".format(
            config.get(site, "url"),