Skip to content

feat(api): warn at startup when webhook or Slack secrets are unset - #177

Merged
OkiriGabriel merged 1 commit into
open-devops-agent:mainfrom
OpeyemiAdeniji:feat/warn-missing-webhook-secrets
Nov 21, 2026
Merged

OkiriGabriel merged 1 commit into
open-devops-agent:mainfrom
OpeyemiAdeniji:feat/warn-missing-webhook-secrets

Conversation

@OpeyemiAdeniji

@OpeyemiAdeniji OpeyemiAdeniji commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

Step 1 of the plan in #64 (comment) (non-breaking).

When WEBHOOK_SECRET is unset, /webhook/* requests are accepted without signature or token verification; when SLACK_SIGNING_SECRET is unset, /slack/action is accepted without signature verification. Nothing in the logs showed this, so a production misconfiguration was silent.

This adds _warn_missing_webhook_secrets() in api/server.py, called in lifespan right after the existing API_AUTH_DISABLED warning. It logs one warning per missing secret:

  • WEBHOOK_SECRET is not set: /webhook/* requests are accepted without signature or token verification
  • SLACK_SIGNING_SECRET is not set: /slack/action requests are accepted without signature verification

Request handling is unchanged: nothing is rejected that was accepted before. An empty value counts as unset, matching how get_webhook_secret() / get_slack_signing_secret() are already checked.

SECURITY_GUARANTEES.md gets one sentence documenting the warning next to the existing "accepts requests when the secret is unset" text.

Part of #64 (does not close it: test alignment and the fail-closed decision are still open there)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring
  • New platform/collector support

Platform/Component

  • Core Agent
  • Kubernetes
  • CI/CD (specify: )
  • Cloud Provider
  • ArgoCD
  • Docker
  • API Server
  • Tools/Executor
  • Documentation
  • Tests

Testing

  • Unit tests added/updated

  • Integration tests pass

  • Manual testing performed

  • Tested with dummy data

  • Tested in production-like environment

  • New tests/test_startup_warnings.py (6 tests, using structlog.testing.capture_logs): both secrets unset → two warnings; both set → none; each one unset on its own → only that warning; an empty WEBHOOK_SECRET counts as unset; and entering lifespan calls the check (background-worker lock and legacy-review adoption patched out, so no queue worker starts).

  • Related suites locally: tests/test_startup_warnings.py, test_api.py, test_webhook_auth.py, test_security_middleware.py, test_api_auth.py, plus test_security.py and test_services.py (the other tests that enter lifespan): all pass.

  • Full suite locally (Windows): 1068 passed, 30 skipped, 1 failed. The failure is tests/test_nginx_bamboo.py::TestNginxTools::test_write_file_command_prevents_shell_expansion, which shells out to python3 (not on my Windows PATH), the same unrelated failure noted in test(ci): assert status codes and response shape for /webhook/manual in integration job #107; it runs on Linux in CI.

  • Blocking Flake8 check (E9,F63,F7,F82) is clean on the changed files.

  • CI result on this PR: all checks pass, including the three Test Agent jobs (3.10/3.11/3.12) and the Integration Test job; only deploy is skipped. The Test Agent log shows all 6 test_startup_warnings.py tests running and passing.

Test Configuration

OS: Windows (Git Bash)
Python Version: 3.12
Kubernetes Version: N/A
Cloud Provider: N/A

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings (other than the intended startup log warnings)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (1 Windows-only failure unrelated to this change, see Testing)
  • Any dependent changes have been merged and published

Screenshots (if applicable)

N/A

Breaking Changes

None. Deployments without the secrets will see two new warnings at startup; behavior is otherwise identical.

Additional Notes

  • The CI integration job runs without WEBHOOK_SECRET, so its server log will now show the warning. That is expected; step 2 on [SECURITY] Fail-closed webhook defaults and rate limiting for credential endpoints #64 would have CI sign its requests.
  • Unrelated, noticed while editing: the existing api/server.py#L... line anchors in SECURITY_GUARANTEES.md already point at the wrong lines on main (e.g. #L264 is no longer the webhook gate). I left them alone to keep this PR small; the new link I added points at the right line. Happy to fix the rest in a separate docs PR.

Reviewer Checklist

  • Code quality is acceptable
  • Tests are comprehensive
  • Documentation is updated
  • No security concerns
  • Performance impact is acceptable

With WEBHOOK_SECRET unset, /webhook/* requests are accepted without
signature or token verification, and with SLACK_SIGNING_SECRET unset,
/slack/action is accepted without signature verification. Nothing in
the logs showed that, so a production misconfiguration was silent.

Log a warning in lifespan for each missing secret, next to the existing
API_AUTH_DISABLED warning. Request handling is unchanged.

Document the warning in SECURITY_GUARANTEES.md and add tests for each
combination of set/unset secrets and for lifespan calling the check.

Part of open-devops-agent#64

@OkiriGabriel OkiriGabriel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @OpeyemiAdeniji, a clean, non-breaking step 1: one warning per missing secret, empty counts as unset (matching the getters), and test_lifespan_calls_the_check proves it's actually wired into startup. The SECURITY_GUARANTEES sentence is accurate. Approving.

@OkiriGabriel OkiriGabriel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this

@OkiriGabriel
OkiriGabriel merged commit 48bf848 into open-devops-agent:main Nov 21, 2026
16 checks passed
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.

2 participants