Skip to content

feat: release config signing + moka cache - #370

Open
yuvrajjsingh0 wants to merge 3 commits into
mainfrom
rc-signing
Open

feat: release config signing + moka cache#370
yuvrajjsingh0 wants to merge 3 commits into
mainfrom
rc-signing

Conversation

@yuvrajjsingh0

@yuvrajjsingh0 yuvrajjsingh0 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Added an Integrity settings area for viewing and managing application signing keys.
    • Create, view, copy, download, enable, disable, and promote signing keys as default.
    • Release configurations can now include verifiable signatures, with optional key selection.
    • Added access-controlled Settings navigation and automatic default-key provisioning.
  • Bug Fixes
    • Improved cache invalidation when signing keys, releases, or application properties change.
  • Documentation
    • Added guidance for managing keys, verifying signatures, rotating keys, and configuring signing caches.

@semanticdiff-com

semanticdiff-com Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  airborne_dashboard/next.config.mjs  97% smaller
  airborne_server/src/release.rs  21% smaller
  airborne_server/src/main.rs  7% smaller
  airborne_server/src/types.rs  1% smaller
  airborne_server/src/utils/db/models.rs  1% smaller
  Cargo.lock Unsupported file format
  airborne_dashboard/app/dashboard/[orgId]/[appId]/settings/integrity/page.tsx  0% smaller
  airborne_dashboard/app/dashboard/[orgId]/[appId]/settings/layout.tsx  0% smaller
  airborne_dashboard/app/dashboard/[orgId]/[appId]/settings/page.tsx  0% smaller
  airborne_dashboard/components/settings/integrity/create-key-dialog.tsx  0% smaller
  airborne_dashboard/components/settings/integrity/key-actions.tsx  0% smaller
  airborne_dashboard/components/settings/integrity/public-key-dialog.tsx  0% smaller
  airborne_dashboard/components/settings/integrity/signing-keys-card.tsx  0% smaller
  airborne_dashboard/components/settings/settings-tabs.tsx  0% smaller
  airborne_dashboard/components/shared-layout.tsx  0% smaller
  airborne_dashboard/lib/name-validation.ts  0% smaller
  airborne_dashboard/types/integrity.ts  0% smaller
  airborne_docs/docs/dashboard/integrity.mdx Unsupported file format
  airborne_docs/docs/dashboard/overview.mdx Unsupported file format
  airborne_docs/docs/guides/verify-the-release-config-signature.mdx Unsupported file format
  airborne_docs/docs/server/configuration.md Unsupported file format
  airborne_docs/openapi/airborne.openapi.json  0% smaller
  airborne_docs/sidebars.ts  0% smaller
  airborne_docs/static/docs_static/img/screenshots/dark/integrity-keys.png Unsupported file format
  airborne_docs/static/docs_static/img/screenshots/light/integrity-keys.png Unsupported file format
  airborne_server/.env.example Unsupported file format
  airborne_server/Cargo.toml Unsupported file format
  airborne_server/migrations/20260714120000_add_signing_keys/down.sql Unsupported file format
  airborne_server/migrations/20260714120000_add_signing_keys/up.sql Unsupported file format
  airborne_server/src/config.rs Unsupported file format
  airborne_server/src/organisation/application.rs Unsupported file format
  airborne_server/src/organisation/application/properties.rs  0% smaller
  airborne_server/src/release/utils.rs  0% smaller
  airborne_server/src/signing.rs  0% smaller
  airborne_server/src/signing/types.rs  0% smaller
  airborne_server/src/signing/utils.rs  0% smaller
  airborne_server/src/utils.rs  0% smaller
  airborne_server/src/utils/advisory_lock.rs  0% smaller
  airborne_server/src/utils/db/schema.rs  0% smaller
  airborne_server/src/utils/moka.rs  0% smaller
  airborne_server/src/utils/redis.rs  0% smaller
  smithy/models/errors.smithy Unsupported file format
  smithy/models/main.smithy Unsupported file format
  smithy/models/release.smithy Unsupported file format
  smithy/models/signing.smithy Unsupported file format

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds end-to-end ES256 release-config signing, signing-key lifecycle APIs and persistence, cache invalidation, dashboard management screens, authorization checks, and documentation.

Changes

Signing contracts, persistence, and runtime state

Layer / File(s) Summary
Signing contracts and storage
airborne_server/migrations/..., airborne_server/src/utils/db/..., smithy/models/*
Defines signing-key schemas, database persistence, API operations, release signature headers, and conflict responses.
Configuration and caching infrastructure
airborne_server/src/config.rs, airborne_server/src/types.rs, airborne_server/src/utils/*, airborne_server/.env.example, airborne_server/Cargo.toml
Adds encryption-key propagation, signature-cache configuration, Moka and Redis cache helpers, and boot migration settings.

Signing-key operations and provisioning

Layer / File(s) Summary
Cryptography and key lifecycle
airborne_server/src/signing/utils.rs, airborne_server/src/signing/types.rs
Generates, encrypts, resolves, caches, signs, provisions, disables, and promotes signing keys, with unit tests for signing and validation.
Management routes and startup wiring
airborne_server/src/signing.rs, airborne_server/src/main.rs, airborne_server/src/organisation/application.rs
Registers authorized signing-key endpoints, provisions keys for applications, and performs migration-gated boot backfills.

Release response signing and invalidation

Layer / File(s) Summary
Signed release responses
airborne_server/src/release.rs, airborne_server/src/signing/utils.rs
Serializes release responses as bytes, signs them using selected keys, caches signatures, and invalidates release/signature caches after relevant mutations.

Dashboard integrity settings

Layer / File(s) Summary
Settings navigation and authorization
airborne_dashboard/components/shared-layout.tsx, airborne_dashboard/app/dashboard/.../settings/*, airborne_dashboard/components/settings/settings-tabs.tsx
Adds permission-gated Settings navigation, settings routing, tab navigation, and the Integrity page.
Signing-key management UI
airborne_dashboard/components/settings/integrity/*, airborne_dashboard/types/integrity.ts, airborne_dashboard/lib/name-validation.ts, airborne_dashboard/next.config.mjs
Adds listing, creation, viewing, copying, downloading, enabling, disabling, and default-key management with client-side validation and API routing.

Documentation and generated API descriptions

Layer / File(s) Summary
Signing and verification documentation
airborne_docs/docs/dashboard/integrity.mdx, airborne_docs/docs/guides/verify-the-release-config-signature.mdx, airborne_docs/docs/server/configuration.md
Documents key management, signature verification, rotation, caching, encryption, and boot-time provisioning.
API descriptions and navigation
airborne_docs/openapi/airborne.openapi.json, airborne_docs/sidebars.ts, airborne_docs/docs/dashboard/overview.mdx
Adds signing-key endpoints, schemas, conflict responses, release signature headers, and documentation navigation entries.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

Suggested reviewers: jamesgeorg

Poem

I’m a rabbit with keys in a row,
Signing configs wherever they go.
Rotate, cache, verify—
No tampering nearby!
Hop through Settings, and watch headers glow.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: release config signing plus Moka cache integration.
Docstring Coverage ✅ Passed Docstring coverage is 96.25% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rc-signing

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@yuvrajjsingh0

Copy link
Copy Markdown
Contributor Author

@coderabbitai help

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai rate limit to show your current review rate limit status.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
  • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
  • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai emit path instructions to emit generated path-specific review instructions for this repository.
  • @coderabbitai resolve merge conflict to automatically resolve merge conflicts.
  • @coderabbitai autofix to automatically fix issues identified in unresolved review comments.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@yuvrajjsingh0

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 13

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
smithy/models/release.smithy (1)

358-364: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Remove @requiresauth from these public release operations.

Both operations are documented and routed as unauthenticated SDK endpoints, but the Smithy trait still declares authentication mandatory. Generated clients and OpenAPI consumers may consequently require credentials for public boot requests.

Proposed contract fix
 `@http`(method: "GET", uri: "/release/{organisation}/{application}")
 `@readonly`
-@requiresauth
 operation ServeRelease {
@@
 `@http`(method: "GET", uri: "/release/v2/{organisation}/{application}")
 `@readonly`
-@requiresauth
 operation ServeReleaseV2 {

Also applies to: 375-381

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@smithy/models/release.smithy` around lines 358 - 364, Remove the
`@requiresauth` trait from both public release operations: the operation shown in
the diff and the corresponding operation near the second referenced location.
Preserve their existing HTTP routes and documentation so generated clients treat
these SDK boot endpoints as unauthenticated.
airborne_server/src/main.rs (1)

185-195: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Run database migrations before the signingkeys backfill.

signingkeys triggers the backfill but does not set should_run_db_migrations. With MIGRATIONS_TO_RUN_ON_BOOT=signingkeys, startup skips the table migration, the backfill queries a missing signing_keys table, logs the failure, and continues without provisioning keys.

Proposed fix
 let should_run_db_migrations = migrations_to_run_on_boot.iter().any(|m| m == "db");
+let should_run_signing_key_backfill =
+    migrations_to_run_on_boot.iter().any(|m| m == "signingkeys");

-if should_run_db_migrations || should_run_keycloak_to_casbin {
+if should_run_db_migrations
+    || should_run_keycloak_to_casbin
+    || should_run_signing_key_backfill
+{
@@
-if migrations_to_run_on_boot.iter().any(|m| m == "signingkeys") {
+if should_run_signing_key_backfill {

Also applies to: 499-513

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@airborne_server/src/main.rs` around lines 185 - 195, Update the startup
migration selection in main so the database migration block also runs when
migrations_to_run_on_boot contains "signingkeys", ensuring the signing_keys
table exists before the signingkeys backfill executes. Preserve the existing
behavior for "db" and "keycloaktocasbin" entries and keep the backfill flow
unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@airborne_dashboard/components/settings/integrity/signing-keys-card.tsx`:
- Around line 48-53: Update the useSWR state in the signing-keys card to capture
error alongside data, isLoading, and mutate, then render a dedicated error state
with a retry action using mutate when the request fails. Ensure the “No signing
keys” empty state is shown only after a successful response with no keys, not
when data is undefined because of an error.

In `@airborne_docs/docs/dashboard/integrity.mdx`:
- Around line 39-43: Update the key ID validation list in the integrity
documentation to state that IDs must be no longer than 50 characters, alongside
the existing character, dash, and boundary constraints.

In `@airborne_docs/openapi/airborne.openapi.json`:
- Line 2120: Update the signing-key list description associated with the
relevant OpenAPI endpoint to remove the guarantee that the list is never empty.
State that automatic default-key provisioning applies to newly created or
backfilled applications, while preserving the existing details about ordering,
public-key-only responses, headers, and authentication.
- Line 2865: Add operation-level security overrides with an empty array to both
ServeReleaseV2 at airborne_docs/openapi/airborne.openapi.json:2865-2865 and
ServeRelease at airborne_docs/openapi/airborne.openapi.json:2989-2989, so these
public operations do not inherit the document-level bearer authentication
requirement.
- Around line 2891-2897: Update the signing-key parameter schemas for
ServeReleaseV2 at airborne_docs/openapi/airborne.openapi.json:2891-2897 and
ServeRelease at airborne_docs/openapi/airborne.openapi.json:3015-3021 to accept
either an empty string or a valid non-empty key ID. Replace the conflicting
minLength/pattern constraints with a schema expression that preserves the
existing key-ID validation while allowing the documented empty-value default
behavior.

In `@airborne_server/src/config.rs`:
- Around line 173-175: Update the master_encryption_key handling near its
initialization and the encrypt_private_key provisioning flow so signing
private-key encryption remains mandatory regardless of USE_ENCRYPTED_SECRETS.
Require a dedicated encryption key for signing keys, or reject provisioning when
none is configured; never allow encrypt_private_key to persist plaintext PEM
data.

In `@airborne_server/src/release.rs`:
- Around line 1465-1469: Update the signing-key ID extraction in the request
handling flow to distinguish a missing header from a present header containing
invalid UTF-8. Reject the request when x-signing-key-id cannot be converted to
text, rather than passing None to signing::utils::requested_key_id and selecting
the default key; preserve existing behavior for valid and absent headers.

In `@airborne_server/src/release/utils.rs`:
- Around line 496-509: Update invalidate_release_cache to invalidate both the
existing /release/{organisation}/{application}* path and the v2 endpoint path
/release/v2/{organisation}/{application}. Submit both paths together through
invalidate_cf as a single invalidation batch, preserving the current best-effort
error logging.

In `@airborne_server/src/signing/utils.rs`:
- Around line 323-336: Update signature_cache_key and the surrounding signing
flow to resolve the authoritative active signing key before reading the cache,
then include the resolved key identity and a digest of body in the cache key
alongside the existing release context. Ensure cache hits cannot bypass key
resolution or return signatures for disabled/replaced keys, and update all
affected call sites in the signing and invalidation paths. Add regression
coverage for body mutation and concurrent mutation/invalidation so stale
in-flight signatures are not served.
- Around line 153-168: Require a configured master encryption key in
encrypt_private_key and fail with the existing ABError mechanism when it is
absent, rather than returning the plaintext key. Update the corresponding
decrypt_private_key behavior as needed to preserve encrypted-key handling, and
ensure provisioning propagates the failure instead of persisting or exposing the
raw private key.

In `@airborne_server/src/utils/db/models.rs`:
- Line 250: Remove the Debug derive from both private-key-bearing model structs
near the Queryable/Selectable declarations, including the model containing
private_key_encrypted, so debug formatting cannot expose encrypted private keys;
preserve the other derives unchanged.

In `@airborne_server/src/utils/redis.rs`:
- Around line 200-253: Make index_add and index_drop atomic by replacing their
multi-command Redis flows with Lua scripts executed through the existing Redis
connection. The index_add script must perform SADD and EXPIRE together, while
the index_drop script must read the set members, delete those members, and
delete the index within one atomic operation. Preserve the current error metrics
and ABError handling around the script executions.

In `@smithy/models/signing.smithy`:
- Around line 32-34: Update the signing model documentation around the
default-key description and the list guarantees at the referenced symbols to
state that an application may temporarily have no keys and therefore no default
key when provisioning fails; remove any claim that the key list is never empty
or that exactly one default always exists, while preserving the behavior for
applications with a configured default.

---

Outside diff comments:
In `@airborne_server/src/main.rs`:
- Around line 185-195: Update the startup migration selection in main so the
database migration block also runs when migrations_to_run_on_boot contains
"signingkeys", ensuring the signing_keys table exists before the signingkeys
backfill executes. Preserve the existing behavior for "db" and
"keycloaktocasbin" entries and keep the backfill flow unchanged.

In `@smithy/models/release.smithy`:
- Around line 358-364: Remove the `@requiresauth` trait from both public release
operations: the operation shown in the diff and the corresponding operation near
the second referenced location. Preserve their existing HTTP routes and
documentation so generated clients treat these SDK boot endpoints as
unauthenticated.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f601f139-b710-49ec-8e89-00e3e44b228a

📥 Commits

Reviewing files that changed from the base of the PR and between a706e7f and e87ab88.

⛔ Files ignored due to path filters (3)
  • Cargo.lock is excluded by !**/*.lock
  • airborne_docs/static/docs_static/img/screenshots/dark/integrity-keys.png is excluded by !**/*.png
  • airborne_docs/static/docs_static/img/screenshots/light/integrity-keys.png is excluded by !**/*.png
📒 Files selected for processing (42)
  • airborne_dashboard/app/dashboard/[orgId]/[appId]/settings/integrity/page.tsx
  • airborne_dashboard/app/dashboard/[orgId]/[appId]/settings/layout.tsx
  • airborne_dashboard/app/dashboard/[orgId]/[appId]/settings/page.tsx
  • airborne_dashboard/components/settings/integrity/create-key-dialog.tsx
  • airborne_dashboard/components/settings/integrity/key-actions.tsx
  • airborne_dashboard/components/settings/integrity/public-key-dialog.tsx
  • airborne_dashboard/components/settings/integrity/signing-keys-card.tsx
  • airborne_dashboard/components/settings/settings-tabs.tsx
  • airborne_dashboard/components/shared-layout.tsx
  • airborne_dashboard/lib/name-validation.ts
  • airborne_dashboard/next.config.mjs
  • airborne_dashboard/types/integrity.ts
  • airborne_docs/docs/dashboard/integrity.mdx
  • airborne_docs/docs/dashboard/overview.mdx
  • airborne_docs/docs/guides/verify-the-release-config-signature.mdx
  • airborne_docs/docs/server/configuration.md
  • airborne_docs/openapi/airborne.openapi.json
  • airborne_docs/sidebars.ts
  • airborne_server/.env.example
  • airborne_server/Cargo.toml
  • airborne_server/migrations/20260714120000_add_signing_keys/down.sql
  • airborne_server/migrations/20260714120000_add_signing_keys/up.sql
  • airborne_server/src/config.rs
  • airborne_server/src/main.rs
  • airborne_server/src/organisation/application.rs
  • airborne_server/src/organisation/application/properties.rs
  • airborne_server/src/release.rs
  • airborne_server/src/release/utils.rs
  • airborne_server/src/signing.rs
  • airborne_server/src/signing/types.rs
  • airborne_server/src/signing/utils.rs
  • airborne_server/src/types.rs
  • airborne_server/src/utils.rs
  • airborne_server/src/utils/advisory_lock.rs
  • airborne_server/src/utils/db/models.rs
  • airborne_server/src/utils/db/schema.rs
  • airborne_server/src/utils/moka.rs
  • airborne_server/src/utils/redis.rs
  • smithy/models/errors.smithy
  • smithy/models/main.smithy
  • smithy/models/release.smithy
  • smithy/models/signing.smithy

Comment on lines +48 to +53
const { data, isLoading, mutate } = useSWR(canRead && token && org && app ? ["/signing-keys", org, app] : null, () =>
apiFetch<SigningKeysResponse>("/signing-keys", {}, { token, org, app })
);

const keys = data?.data ?? [];
const loading = !canRead || isLoading;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the file structure first
ast-grep outline airborne_dashboard/components/settings/integrity/signing-keys-card.tsx --view expanded || true

# Read the relevant section with line numbers
sed -n '1,260p' airborne_dashboard/components/settings/integrity/signing-keys-card.tsx | cat -n

# Look for related signing-keys UI and error handling patterns
rg -n "signing-keys|No signing keys|error|retry|mutate\\(" airborne_dashboard/components/settings/integrity -S

Repository: juspay/airborne

Length of output: 16114


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1,220p' airborne_dashboard/components/settings/integrity/create-key-dialog.tsx | cat -n

printf '\n---\n'

rg -n "error|retry|No signing keys|useSWR\\(" airborne_dashboard/components/settings/integrity -S

Repository: juspay/airborne

Length of output: 6529


Show a dedicated error state instead of “No signing keys” on list failure.
When the SWR request errors, data stays undefined and this branch falls through to the empty state, which implies release configs are unsigned and invites key creation. Handle error separately and offer a retry action; only render the empty state after a successful empty response.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@airborne_dashboard/components/settings/integrity/signing-keys-card.tsx`
around lines 48 - 53, Update the useSWR state in the signing-keys card to
capture error alongside data, isLoading, and mutate, then render a dedicated
error state with a retry action using mutate when the request fails. Ensure the
“No signing keys” empty state is shown only after a successful response with no
keys, not when data is undefined because of an error.

Source: Learnings

Comment on lines +39 to +43
Key IDs must be unique within the application and are immutable. They must:

- contain only lowercase letters (`a-z`), digits (`0-9`), and dashes (`-`);
- use no consecutive dashes; and
- neither start nor end with a dash.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Document the 50-character key ID limit.

The server rejects key IDs longer than 50 characters, but this validation list omits that constraint.

Proposed fix
 Key IDs must be unique within the application and are immutable. They must:

+- be at most 50 characters long;
 - contain only lowercase letters (`a-z`), digits (`0-9`), and dashes (`-`);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Key IDs must be unique within the application and are immutable. They must:
- contain only lowercase letters (`a-z`), digits (`0-9`), and dashes (`-`);
- use no consecutive dashes; and
- neither start nor end with a dash.
Key IDs must be unique within the application and are immutable. They must:
- be at most 50 characters long;
- contain only lowercase letters (`a-z`), digits (`0-9`), and dashes (`-`);
- use no consecutive dashes; and
- neither start nor end with a dash.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@airborne_docs/docs/dashboard/integrity.mdx` around lines 39 - 43, Update the
key ID validation list in the integrity documentation to state that IDs must be
no longer than 50 characters, alongside the existing character, dash, and
boundary constraints.

}
"/api/signing-keys": {
"get": {
"description": "List the signing keys of an application, with the default key first. Every application\nis provisioned with a default key when it is created, so this is never empty. The\nprivate key is never returned — only the public key, which is enough to verify a\nsigned release config. Pass the organisation and application in the x-organisation and\nx-application headers. Requires a bearer token.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Do not promise that the signing-key list is never empty.

Applications created before signing can return an empty list until the signingkeys backfill runs. Describe automatic provisioning as applying to new or backfilled applications.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@airborne_docs/openapi/airborne.openapi.json` at line 2120, Update the
signing-key list description associated with the relevant OpenAPI endpoint to
remove the guarantee that the list is never empty. State that automatic
default-key provisioning applies to newly created or backfilled applications,
while preserving the existing details about ordering, public-key-only responses,
headers, and authentication.

},
"/release/v2/{organisation}/{application}": {
"get": {
"description": "Version 2 of the release-resolution endpoint: resolves and returns the active release configuration for an application based on the caller's targeting dimensions. This is the endpoint newer SDKs call at boot. Public — no auth token required.\n\nThe response is signed: the x-airborne-signature response header carries an ES256 signature over the exact raw JSON response body bytes, so a client can verify the config was served by Airborne and not tampered with in transit. Send the x-signing-key-id header to choose which key signs the response; omit it to use the application's default key. See the \"Signing keys\" endpoints for managing keys and downloading the public key to verify against.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Override global bearer authentication for the public release endpoints.

Both operations inherit the document-level bearer requirement despite being public. Generated clients and API documentation will therefore incorrectly require credentials.

  • airborne_docs/openapi/airborne.openapi.json#L2865-L2865: add operation-level "security": [] to ServeReleaseV2.
  • airborne_docs/openapi/airborne.openapi.json#L2989-L2989: add operation-level "security": [] to ServeRelease.
📍 Affects 1 file
  • airborne_docs/openapi/airborne.openapi.json#L2865-L2865 (this comment)
  • airborne_docs/openapi/airborne.openapi.json#L2989-L2989
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@airborne_docs/openapi/airborne.openapi.json` at line 2865, Add
operation-level security overrides with an empty array to both ServeReleaseV2 at
airborne_docs/openapi/airborne.openapi.json:2865-2865 and ServeRelease at
airborne_docs/openapi/airborne.openapi.json:2989-2989, so these public
operations do not inherit the document-level bearer authentication requirement.

Comment on lines +2891 to +2897
"description": "ID of the signing key to sign the response with. This is the readable ID chosen\nwhen the key was created. Optional — when omitted, or sent with an empty value,\nthe application's default signing key is used. A non-empty key ID that is\ninvalid, unknown, disabled, or belongs to another application is rejected with\na 400.",
"schema": {
"type": "string",
"maxLength": 50,
"minLength": 1,
"pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
"description": "ID of the signing key to sign the response with. This is the readable ID chosen\nwhen the key was created. Optional — when omitted, or sent with an empty value,\nthe application's default signing key is used. A non-empty key ID that is\ninvalid, unknown, disabled, or belongs to another application is rejected with\na 400."

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Align the empty-header behavior with the parameter schemas.

The descriptions say an empty value selects the default key, but minLength: 1 and the regex reject it. Generated validators will reject a request the server accepts.

  • airborne_docs/openapi/airborne.openapi.json#L2891-L2897: allow either an empty string or a valid key ID for ServeReleaseV2.
  • airborne_docs/openapi/airborne.openapi.json#L3015-L3021: apply the same schema to ServeRelease.
📍 Affects 1 file
  • airborne_docs/openapi/airborne.openapi.json#L2891-L2897 (this comment)
  • airborne_docs/openapi/airborne.openapi.json#L3015-L3021
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@airborne_docs/openapi/airborne.openapi.json` around lines 2891 - 2897, Update
the signing-key parameter schemas for ServeReleaseV2 at
airborne_docs/openapi/airborne.openapi.json:2891-2897 and ServeRelease at
airborne_docs/openapi/airborne.openapi.json:3015-3021 to accept either an empty
string or a valid non-empty key ID. Replace the conflicting minLength/pattern
constraints with a schema expression that preserves the existing key-ID
validation while allowing the documented empty-value default behavior.

Comment on lines +153 to +168
/// Encrypt a private key for at-rest storage with the same master key used for
/// encrypted environment secrets.
async fn encrypt_private_key(plaintext: &str, key: Option<&str>) -> Result<String, ABError> {
match key {
Some(key) => crate::utils::encryption::encrypt_string(plaintext, key).await,
None => Ok(plaintext.to_string()),
}
}

/// Decrypt a private key produced by [`encrypt_private_key`].
async fn decrypt_private_key(ciphertext: &str, key: Option<&str>) -> Result<String, ABError> {
match key {
Some(key) => crate::utils::encryption::decrypt_string(ciphertext, key).await,
None => Ok(ciphertext.to_string()),
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Never fall back to plaintext private-key storage.

When master_encryption_key is absent, the raw PKCS#8 key is persisted and may also enter Redis through ActiveSigningKey. Fail provisioning instead of silently removing at-rest protection.

Proposed fix
 async fn encrypt_private_key(plaintext: &str, key: Option<&str>) -> Result<String, ABError> {
-    match key {
-        Some(key) => crate::utils::encryption::encrypt_string(plaintext, key).await,
-        None => Ok(plaintext.to_string()),
-    }
+    let key = key.ok_or_else(|| {
+        ABError::InternalServerError(
+            "A master encryption key is required for release-config signing".to_string(),
+        )
+    })?;
+    crate::utils::encryption::encrypt_string(plaintext, key).await
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// Encrypt a private key for at-rest storage with the same master key used for
/// encrypted environment secrets.
async fn encrypt_private_key(plaintext: &str, key: Option<&str>) -> Result<String, ABError> {
match key {
Some(key) => crate::utils::encryption::encrypt_string(plaintext, key).await,
None => Ok(plaintext.to_string()),
}
}
/// Decrypt a private key produced by [`encrypt_private_key`].
async fn decrypt_private_key(ciphertext: &str, key: Option<&str>) -> Result<String, ABError> {
match key {
Some(key) => crate::utils::encryption::decrypt_string(ciphertext, key).await,
None => Ok(ciphertext.to_string()),
}
}
/// Encrypt a private key for at-rest storage with the same master key used for
/// encrypted environment secrets.
async fn encrypt_private_key(plaintext: &str, key: Option<&str>) -> Result<String, ABError> {
let key = key.ok_or_else(|| {
ABError::InternalServerError(
"A master encryption key is required for release-config signing".to_string(),
)
})?;
crate::utils::encryption::encrypt_string(plaintext, key).await
}
/// Decrypt a private key produced by [`encrypt_private_key`].
async fn decrypt_private_key(ciphertext: &str, key: Option<&str>) -> Result<String, ABError> {
match key {
Some(key) => crate::utils::encryption::decrypt_string(ciphertext, key).await,
None => Ok(ciphertext.to_string()),
}
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@airborne_server/src/signing/utils.rs` around lines 153 - 168, Require a
configured master encryption key in encrypt_private_key and fail with the
existing ABError mechanism when it is absent, rather than returning the
plaintext key. Update the corresponding decrypt_private_key behavior as needed
to preserve encrypted-key handling, and ensure provisioning propagates the
failure instead of persisting or exposing the raw private key.

Comment on lines +323 to +336
/// Cache key for one (release config, signing key) pair.
fn signature_cache_key(
cache: &RedisCache,
organisation: &str,
application: &str,
selector: &str,
config_version: &str,
) -> RedisKey {
cache.key_unlabeled(
organisation,
application,
&["release_sig", selector, config_version],
)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

Bind cached signatures to the exact body and authoritative key state.

The cache key only contains the selector and config_version, while property edits can change the signed body without changing that version. An in-flight writer after invalidation can therefore cache an old-body signature. Additionally, a cache hit bypasses key resolution, so failed invalidation can continue serving a disabled or replaced key.

Resolve the active key before lookup and key entries by the resolved key identity plus a digest of body; add regression coverage for concurrent mutation/invalidation.

Also applies to: 370-405, 429-441, 447-500

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@airborne_server/src/signing/utils.rs` around lines 323 - 336, Update
signature_cache_key and the surrounding signing flow to resolve the
authoritative active signing key before reading the cache, then include the
resolved key identity and a digest of body in the cache key alongside the
existing release context. Ensure cache hits cannot bypass key resolution or
return signatures for disabled/replaced keys, and update all affected call sites
in the signing and invalidation paths. Add regression coverage for body mutation
and concurrent mutation/invalidation so stale in-flight signatures are not
served.

/// The internal row UUID, `org_id`, `app_id`, and `updated_at` are omitted: every
/// query is already scoped to one application, and clients identify keys by
/// `name`, so selecting them back would be dead weight.
#[derive(Queryable, Selectable, Debug, Clone)]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Do not derive Debug for private-key-bearing models.

Both structs expose private_key_encrypted through debug formatting. Remove Debug or implement a redacted formatter.

Proposed fix
-#[derive(Queryable, Selectable, Debug, Clone)]
+#[derive(Queryable, Selectable, Clone)]
 ...
-#[derive(Insertable, Debug)]
+#[derive(Insertable)]

Also applies to: 263-274

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@airborne_server/src/utils/db/models.rs` at line 250, Remove the Debug derive
from both private-key-bearing model structs near the Queryable/Selectable
declarations, including the model containing private_key_encrypted, so debug
formatting cannot expose encrypted private keys; preserve the other derives
unchanged.

Comment on lines +200 to +253
/// Record `member` in the SET at `index`, so a family of cache entries can be
/// dropped together later. The SET is given the same TTL as its members, so a
/// forgotten index cannot outlive them.
pub async fn index_add(
&self,
index: &RedisKey,
member: &RedisKey,
ttl_secs: usize,
) -> Result<(), ABError> {
let mut r = (*self.conn).clone();
let (index_key, member_key) = (index.key.clone(), member.key.clone());

let _: () = r.sadd(&index_key, &member_key).await.map_err(|e| {
error!("Failed to SADD {member_key} to {index_key}: {e}");
CACHE_FAILS.with_label_values(&index.labels).inc();
ABError::InternalServerError("service error".to_string())
})?;

let _: () = r.expire(&index_key, ttl_secs as i64).await.map_err(|e| {
error!("Failed to EXPIRE {index_key}: {e}");
CACHE_FAILS.with_label_values(&index.labels).inc();
ABError::InternalServerError("service error".to_string())
})?;

Ok(())
}

/// Delete every key recorded in the SET at `index`, then the index itself.
pub async fn index_drop(&self, index: &RedisKey) -> Result<(), ABError> {
let mut r = (*self.conn).clone();
let index_key = index.key.clone();

let members: Vec<String> = r.smembers(&index_key).await.map_err(|e| {
error!("Failed to SMEMBERS {index_key}: {e}");
CACHE_FAILS.with_label_values(&index.labels).inc();
ABError::InternalServerError("service error".to_string())
})?;

if !members.is_empty() {
let _: () = r.del(members).await.map_err(|e| {
error!("Failed to DEL members of {index_key}: {e}");
CACHE_FAILS.with_label_values(&index.labels).inc();
ABError::InternalServerError("service error".to_string())
})?;
}

let _: () = r.del(&index_key).await.map_err(|e| {
error!("Failed to DEL {index_key}: {e}");
CACHE_FAILS.with_label_values(&index.labels).inc();
ABError::InternalServerError("service error".to_string())
})?;

Ok(())
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Make signature indexing and invalidation atomic.

index_add can add a member after index_drop reads SMEMBERS but before it deletes the index. The new cached signature then survives invalidation while its index entry is removed, allowing stale signatures after key rotation or disabling. Use Redis Lua scripts to atomically perform SADD+EXPIRE and member/index deletion.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@airborne_server/src/utils/redis.rs` around lines 200 - 253, Make index_add
and index_drop atomic by replacing their multi-command Redis flows with Lua
scripts executed through the existing Redis connection. The index_add script
must perform SADD and EXPIRE together, while the index_drop script must read the
set members, delete those members, and delete the index within one atomic
operation. Preserve the current error metrics and ABError handling around the
script executions.

Comment on lines +32 to +34
/// Whether this is the application's default key. Exactly one key per application is
/// the default: it signs every release config served without an explicit
/// x-signing-key-id header.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Do not guarantee that every application already has a default key.

Lines 164-166 say the list is never empty, but add_application deliberately succeeds when provisioning fails. Document that an application may temporarily have no keys/default instead of exposing a false API invariant.

Also applies to: 164-166, 242-244

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@smithy/models/signing.smithy` around lines 32 - 34, Update the signing model
documentation around the default-key description and the list guarantees at the
referenced symbols to state that an application may temporarily have no keys and
therefore no default key when provisioning fails; remove any claim that the key
list is never empty or that exactly one default always exists, while preserving
the behavior for applications with a configured default.

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