bdrc-db-lib2
Rewrite of package which uses a direct config file for the database connection.
Developer notes
The most significant change is that users no longer need to specify a section of a config file to locate a database connection. The former form, -d | --drsConfig prod:~someone/somewhere/somefile is no longer needed. Clients now siimply specify a section name: -d | --drsConfig prod, for example.
The name of the section is free-form.
Critical information is now given in to environment variables:
- BDRC_DB_CONFIG
The path to the database configuration file can be given using ~ notation to designate a user.
- BDRC_DB_PASSWORD
this is the password to the database named in the section given in the drsConfig parameter.
Development
pyproject.toml
python -m build --wheel bdist_wheel
Deployment
twine upload --verbose -r testpypi dist/bdrc_db_lib-x.MM.mm-py3-none-any.whl
Installation
Implementation
The architecture lends itself to a Docker Secrets + KMS Decryption Scheme. The interested user can refer to Buda-base/ao-workflows
Steps (Thanks to Perplexity)
Encrypt password (One-Time, secure workstation)
# AWS KMS example (use AWS CLI)
aws kms encrypt \
--key-id arn:aws:kms:us-east-1:123456789012:key/1234abcd-12ab-34cd \
--plaintext "mypassword123" \
--output text \
--query CiphertextBlob | base64 > encrypted_db_pass.b64
Docker Secret (Encrypted Blob)
Add the encrypted blob into the docker image. “But wait,” I hear you say, won’t a hacker have access to the encrypted image?” “Yes, but only until the Docker container is started. The encrypted blob is removed at Docker startup. (See Step 3)
# docker-compose.yml
version: '3.8'
services:
app:
image: myapp:latest
secrets:
- db_password
environment:
DB_PASSWORD_FILE: /run/secrets/db_password
secrets:
db_password:
file: ./encrypted_db_pass.b64
external: false # Don't commit
Decrypt at Runtime (Entry script)
This decrypts the password blob at runtime, and then removes the blob from the container’s file system The only hacker access would be if they could inspect the running container (or has injected code into some open source library that grants access to the Docker inspector)
#!/usr/bin/env python3
import boto3
import base64
import os
import sys
kms = boto3.client('kms')
encrypted_pass = base64.b64decode(open('/run/secrets/db_password').read())
decrypted_pass = kms.decrypt(CiphertextBlob=encrypted_pass)['Plaintext'].decode()
os.environ['DB_PASSWORD'] = decrypted_pass
os.unlink('/run/secrets/db_password') # Wipe secret file
# Start app
exec(sys.argv[1])
Changelog
version |
Commit |
Comments |
|
|---|---|---|---|
2.0.1 |
Initial |
||
2.0.2 |
|||
2.0.2 |
401b6b0a |
Move Models out |
Breaks support for older clients |
2.0.5 |
10cc6000 |
Complete refactoring |
|
2.0.7 |
a55af435 |
un-hardwire ‘dev’. |
Read parameters for echo and dev from environment |
Metadata
Release files for bdrc-db-lib2 2.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bdrc_db_lib2-2.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Release files / bdrc_db_lib2-2.0.7-py3-none-any.whl
| Download URL | bdrc_db_lib2-2.0.7-py3-none-any.whl |
|---|---|
| Size | 17.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c79bca8dce4e92c676a3365135909644b09306510b1c4d25842407a70df81ef9
|
|
BLAKE2b-256 checksum How to use checksums |
95b7fd6d74abcefbeb5e707620f5302d15f4bbc7f35d560db74a5d389269880d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Security for bdrc-db-lib2 2.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.