Skip to content

fix(revoke): fail-closed is_attached_to_endpoint for non-AWS source plugins - #361

Open
evan-datadog wants to merge 1 commit into
masterfrom
evan/CLOUDR-2089/is-attached-to-endpoint-fail-closed
Open

fix(revoke): fail-closed is_attached_to_endpoint for non-AWS source plugins#361
evan-datadog wants to merge 1 commit into
masterfrom
evan/CLOUDR-2089/is-attached-to-endpoint-fail-closed

Conversation

@evan-datadog

Copy link
Copy Markdown

Summary

Problem: is_attached_to_endpoint() returns False ("not attached") whenever endpoint.source.plugin lacks get_endpoint_certificate_names(). Only the lemur_aws source plugin implements this method — GCP, Azure, and COA source plugins do not, and there's no base-class contract in plugins/bases/source.py. The sole caller is the revoke endpoint (certificates/views.py), which uses the result to gate a 403 "cannot revoke, still deployed" response. Returning False lets service.revoke() proceed even though the certificate may still be serving traffic on a non-AWS endpoint.

Fixes (fail-closed):

  • When the source plugin cannot verify attachment (does not implement get_endpoint_certificate_names()), return True (assume attached) + error log + capture_exception() — so a possibly still-deployed cert is never silently revoked. Previously: fail-open False (and before that, an uncaught AttributeError/500 that accidentally blocked revocation).
  • When the endpoint no longer exists (get_by_nameNone), return False (nothing to be attached to) instead of crashing.
  • Docstring documents both fail-closed and endpoint-missing semantics.

Changes

File Change
lemur/certificates/service.py is_attached_to_endpoint: fail-closed for plugins lacking get_endpoint_certificate_names() (True + error log + capture_exception()); None-endpoint guard returns False instead of raising
lemur/tests/test_certificates.py Unit tests: missing-method (fail-closed True), endpoint-not-found (False), method-present-with-cert (True), method-present-without-cert (False)

Test plan

  • Unit: plugin without get_endpoint_certificate_names → returns True (fail-closed, no AttributeError)
  • Unit: endpoint lookup returns None → returns False (no AttributeError)
  • Unit: plugin with method, cert present → True; cert absent → False
  • flake8 clean

Note: split out of PR #355 (rotation-window fix) — this is an unrelated safety fix for the revoke path.

Fixes CLOUDR-2089

Workspace: local

🤖 Generated with Claude Code

…get_endpoint_certificate_names

is_attached_to_endpoint() returns False whenever endpoint.source.plugin lacks
get_endpoint_certificate_names() (only lemur_aws implements it; GCP/Azure/COA
do not). The sole caller is the revoke endpoint, which uses the result to gate
a 403 'cannot revoke, still deployed' response. Returning False lets revoke()
proceed even though the cert may still be serving traffic on a non-AWS endpoint.

- Return True (fail-closed) + error log + capture_exception() when the plugin
  cannot verify attachment, so a possibly still-deployed cert is never silently
  revoked (was fail-open False, and before that an uncaught AttributeError/500)
- Return False (no crash) when the endpoint no longer exists
- Add unit tests for missing-method (fail-closed), endpoint-not-found, present, absent

Workspace: local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant