-
Notifications
You must be signed in to change notification settings - Fork 0
Tag managed secrets to prevent cleanup of unmanaged secrets #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
paul-watkins-croud
wants to merge
1
commit into
main
Choose a base branch
from
feature/tag-managed-secrets
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| `croudtech-bootstrap` is a CLI tool for pushing and pulling application configuration (secrets, S3 config, SSM parameters) to/from AWS services. It uses AWS S3 for config storage, AWS SSM Parameter Store for parameters, and AWS Secrets Manager for secrets. It also manages Redis database allocation across environments/apps. | ||
|
|
||
| ## Build & Development | ||
|
|
||
| - **Package manager**: Poetry (`pyproject.toml`) | ||
| - **Python**: >=3.9, <3.14 | ||
| - **Install deps**: `poetry install` | ||
| - **CLI entry point**: `croudtech-bootstrap` (mapped to `croudtech_bootstrap_app.cli:cli`) | ||
|
|
||
| ## Testing | ||
|
|
||
| - **Run all tests**: `py.test --disable-warnings` or `make test` | ||
| - **Run a single test**: `py.test croudtech_bootstrap_app/tests/bootstrap_test.py::test_manager` | ||
| - **Test config**: `setup.cfg` under `[tool:pytest]` — test discovery looks in `croudtech_bootstrap_app/` for files matching `test_*.py`, `tests/*.py`, `tests.py` | ||
| - **Test fixtures**: Tests use local YAML files in `croudtech_bootstrap_app/tests/test_values/` to test config parsing without AWS | ||
|
|
||
| ## Linting | ||
|
|
||
| - **Flake8**: `flake8` (config in `setup.cfg` — ignores E203, E501, W503; max line length 88) | ||
| - **isort**: `isort --recursive --check-only -p . --diff` (fix with `isort --recursive -p .`) | ||
| - **Black**: configured at line length 88 | ||
| - **Run all quality checks**: `make quality` | ||
|
|
||
| ## Architecture | ||
|
|
||
| The core domain is in `croudtech_bootstrap_app/bootstrap.py` with four main classes: | ||
|
|
||
| - **`BootstrapManager`** — Top-level orchestrator. Holds AWS clients (S3, SSM, Secrets Manager), discovers environments from a directory structure, and coordinates push/pull/cleanup operations. | ||
| - **`BootstrapEnvironment`** — Represents a single environment (e.g., staging, production). Discovered from subdirectories of the values path. Contains multiple `BootstrapApp` instances. | ||
| - **`BootstrapApp`** — Represents one application's config within an environment. Handles reading local YAML files (`.yaml` for params, `.secret.yaml` for secrets), uploading to S3, pushing to SSM/Secrets Manager, fetching remote values, and cleaning up orphaned parameters/secrets. | ||
| - **`BootstrapParameters`** — Facade for pulling config. Merges app-specific and common params, handles Redis DB auto-allocation, and formats output as env vars. | ||
|
|
||
| **CLI** (`cli.py`): Click-based CLI with commands `init`, `get-config`, `put-config`, `cleanup-secrets`, `list-apps`, and a `manage-redis` subgroup (`show-db`, `show-dbs`, `allocate-db`, `deallocate-db`). | ||
|
|
||
| **Redis allocation** (`redis_config.py`): Uses Redis DB 15 as a config database to track which DB index (0-14) is allocated to which app/environment combination. | ||
|
|
||
| **Config file convention**: Values directories contain per-environment subdirectories, each with `<AppName>.yaml`, `<AppName>.secret.yaml`, `common.yaml`, and `common.secret.yaml`. Nested YAML keys are flattened with `_` separators. | ||
|
|
||
| ## Key Details | ||
|
|
||
| - Default AWS region is `eu-west-2` | ||
| - `AWS_ENDPOINT_URL` env var overrides AWS endpoints (for local testing with LocalStack etc.) | ||
| - S3 bucket naming convention: `app-bootstrap-{AWS_ACCOUNT_ID}` | ||
| - Log level controlled by `LOG_LEVEL` env var (defaults to CRITICAL) | ||
| - Empty secret values are stored as `__EMPTY__` in Secrets Manager and converted back on retrieval | ||
| - SSM parameters larger than 4096 bytes or empty are skipped during push | ||
| - Retry logic uses exponential backoff for AWS API throttling |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High
Copilot Autofix
AI 4 days ago
In general, to fix clear-text logging of sensitive data, you should avoid including sensitive values (or their directly identifying metadata) in log messages. If some context is needed for troubleshooting, prefer high-level descriptors (like environment or app name) or redacted/hashed versions that do not allow reconstructing or directly identifying the secret.
In this specific case, the vulnerable sink is
logger.debug(f"Could not ensure ManagedBy tag on {secret_id}")in_ensure_managed_by_tag. The simplest, least intrusive fix is to stop interpolatingsecret_idinto the log message. We can still log that something went wrong, potentially including non-sensitive context such as the exception itself (which may already be logged elsewhere) or a generic message. To keep behavior close to current functionality, we’ll change the message to drop the secret identifier and optionally log the exception withlogger.debug("Could not ensure ManagedBy tag on a secret.", exc_info=True)so stack trace is available when debug logs are enabled. This avoids logging the taintedsecret_idwhile maintaining useful diagnostics.Concretely:
croudtech_bootstrap_app/bootstrap.py, in_ensure_managed_by_tag, replace theexceptblock’s logging line to not referencesecret_id.loggeris already initialized andloggingis already imported.