Files
notifications-admin/app/cloudfoundry_config.py
dependabot[bot] c5cbe1d0dd Bump bandit from 1.9.2 to 1.9.3 (#3208)
* Bump bandit from 1.9.2 to 1.9.3

Bumps [bandit](https://github.com/PyCQA/bandit) from 1.9.2 to 1.9.3.
- [Release notes](https://github.com/PyCQA/bandit/releases)
- [Commits](https://github.com/PyCQA/bandit/compare/1.9.2...1.9.3)

---
updated-dependencies:
- dependency-name: bandit
  dependency-version: 1.9.3
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fixed issue

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alex Janousek <alex.janousek@gsa.gov>
2026-01-21 14:43:23 +00:00

31 lines
937 B
Python

import json
import os
class CloudfoundryConfig:
def __init__(self):
self.parsed_services = json.loads(os.environ.get("VCAP_SERVICES") or "{}")
buckets = self.parsed_services.get("s3") or []
self.s3_buckets = {bucket["name"]: bucket["credentials"] for bucket in buckets}
self._empty_bucket_credentials = {
"bucket": "",
"access_key_id": "",
"secret_access_key": "", # nosec B105 - empty default, not a real password
"region": "",
}
@property
def redis_url(self):
try:
return self.parsed_services["aws-elasticache-redis"][0]["credentials"][
"uri"
]
except KeyError:
return os.environ.get("REDIS_URL")
def s3_credentials(self, service_name):
return self.s3_buckets.get(service_name) or self._empty_bucket_credentials
cloud_config = CloudfoundryConfig()