Пример #1
0
    def handle(self, filepath):
        print("Here")
        csvfile = open(filepath, "rb")
        reader = csv.reader(csvfile, delimiter='\t', quotechar='\"')

        credentials = []

        next(reader)  # this is file fingerprint
        next(reader)  # this is table header

        for row in reader:
            # uuid = row[0] # currently unused
            group = row[1]
            name = row[2]
            login = row[3]
            passwd = row[4]
            notes = row[5]

            passpie_name = self.make_passpie_name(group, name)

            credential_dict = {
                'fullname': make_fullname(login, passpie_name),
                'name': passpie_name,
                'login': login,
                'password': passwd,
                'comment': notes,
                'modified': datetime.now(),
            }

            credentials.append(credential_dict)

        return credentials
Пример #2
0
    def handle(self, filepath):
        db = Database(path=filepath)
        passphrase = click.prompt('Pysswords passphrase', hide_input=True)
        if not db.check(passphrase):
            return []

        credentials = []
        for cred in db.credentials:
            credential_dict = {
                'fullname': make_fullname(cred.login, cred.name),
                'name': cred.name,
                'login': cred.login,
                'password': db.decrypt(cred.password, passphrase),
                'comment': cred.comment,
                'modified': datetime.now(),
            }
            credentials.append(credential_dict)

        return credentials
Пример #3
0
    def handle(self, filepath):
        db = Database(path=filepath)
        passphrase = click.prompt('Pysswords passphrase', hide_input=True)
        if not db.check(passphrase):
            return []

        credentials = []
        for cred in db.credentials:
            credential_dict = {
                'fullname': make_fullname(cred.login, cred.name),
                'name': cred.name,
                'login': cred.login,
                'password': db.decrypt(cred.password, passphrase),
                'comment': cred.comment,
                'modified': datetime.now(),
            }
            credentials.append(credential_dict)

        return credentials
Пример #4
0
    def handle(self, filepath):
        passphrase = click.prompt('Keepass passphrase', hide_input=True)

        try:
            # TODO add keyfile support
            db = KPDBv1(filepath=str(filepath),
                        password=str(passphrase),
                        read_only=True)
            db.load()
        except KPError as e:
            self.log(str(e))
            return []
        except Exception as e:
            self.log(str(e))
            return []
        else:
            try:
                credentials = []

                for entry in db.entries:
                    group_names_str = self.compute_group_name(entry)

                    entry_fullname = make_fullname(entry.username,
                                                   group_names_str)

                    credential_dict = {
                        'fullname': entry_fullname,
                        'name': group_names_str,
                        'login': entry.username,
                        'password': entry.password,
                        'comment': (entry.comment or '').strip(),
                        'modified': entry.creation,
                    }
                    credentials.append(credential_dict)

                return credentials
            finally:
                db.close()
    def handle(self, filepath):
        passphrase = click.prompt('Keepass passphrase', hide_input=True)

        try:
            # TODO add keyfile support
            db = KPDBv1(filepath=str(filepath), password=str(passphrase),
                        read_only=True)
            db.load()
        except KPError as e:
            self.log(str(e))
            return []
        except Exception as e:
            self.log(str(e))
            return []
        else:
            try:
                credentials = []

                for entry in db.entries:
                    group_names_str = self.compute_group_name(entry)

                    entry_fullname = make_fullname(
                        entry.username, group_names_str)

                    credential_dict = {
                        'fullname': entry_fullname,
                        'name': group_names_str,
                        'login': entry.username,
                        'password': entry.password,
                        'comment': (entry.comment or '').strip(),
                        'modified': entry.creation,
                    }
                    credentials.append(credential_dict)

                return credentials
            finally:
                db.close()
Пример #6
0
 def test_make_fullname_returns_expected_fullname(self):
     self.assertEqual(make_fullname("foo", "bar"), "foo@bar")
     self.assertEqual(make_fullname("_", "bar"), "_@bar")
     self.assertEqual(make_fullname(None, "bar"), "_@bar")
Пример #7
0
 def test_make_fullname_returns_expected_fullname(self):
     self.assertEqual(make_fullname("foo", "bar"), "foo@bar")
     self.assertEqual(make_fullname("_", "bar"), "_@bar")
     self.assertEqual(make_fullname(None, "bar"), "_@bar")
Пример #8
0
def test_make_fullname_returns_expected_fullname(mocker):
    assert make_fullname("foo", "bar") == "foo@bar"
    assert make_fullname("_", "bar") == "_@bar"
    assert make_fullname(None, "bar") == "@bar"