Skip to content

Add rate limiting and storage limits to whitelist endpoints#121

Merged
Yashb404 merged 6 commits into
feat/keys-freshfrom
copilot/sub-pr-116-one-more-time
Feb 11, 2026
Merged

Add rate limiting and storage limits to whitelist endpoints#121
Yashb404 merged 6 commits into
feat/keys-freshfrom
copilot/sub-pr-116-one-more-time

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 11, 2026

Whitelist management endpoints lacked rate limiting and entry count restrictions, enabling database spam, storage exhaustion, and DoS attacks.

Changes

Rate Limiting

  • Per-user limit: 20 requests/minute using governor crate
  • Applied to GET/POST/DELETE whitelist operations
  • Returns HTTP 429 on limit exceeded

Storage Protection

  • Hard limit: 100 entries per project
  • PostgreSQL advisory locks prevent race conditions during concurrent inserts
  • Returns HTTP 403 when limit reached

Implementation

// Rate limiter created per-user, stored in AppState
pub fn get_or_create_whitelist_rate_limiter(&self, user_id: i64) 
    -> Arc<RateLimiter<NotKeyed, InMemoryState, DefaultClock>> {
    self.whitelist_rate_limiters
        .entry(user_id)
        .or_insert_with(|| {
            let quota = Quota::per_minute(NonZeroU32::new(20).expect("..."));
            Arc::new(RateLimiter::direct(quota))
        })
        .clone()
}

// Transaction with advisory lock ensures atomicity
let mut tx = state.db.begin().await?;
sqlx::query("SELECT pg_advisory_xact_lock($1)")
    .bind(project_id)
    .execute(&mut *tx)
    .await?;
// Check count, insert if under limit

Dependencies Added

  • dashmap 6.1 - concurrent hashmap for rate limiter storage
  • governor 0.10 - rate limiting implementation

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits February 11, 2026 04:57
Co-authored-by: Yashb404 <139128977+Yashb404@users.noreply.github.com>
…lity

Co-authored-by: Yashb404 <139128977+Yashb404@users.noreply.github.com>
Co-authored-by: Yashb404 <139128977+Yashb404@users.noreply.github.com>
Co-authored-by: Yashb404 <139128977+Yashb404@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Feb 11, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • docs.rs
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Update implementation based on feedback for secure embed authorization Add rate limiting and storage limits to whitelist endpoints Feb 11, 2026
Copilot AI requested a review from Yashb404 February 11, 2026 05:06
@Yashb404 Yashb404 marked this pull request as ready for review February 11, 2026 05:35
@Yashb404
Copy link
Copy Markdown
Member

@copilot

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
docs.rs
Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)
If you need me to access, download, or install something from one of these locations, you can either:

Configure Actions setup steps to set up my environment, which run before the firewall is enabled
Add the appropriate URLs or hosts to the custom allowlist i

Should I be worried ?

Copy link
Copy Markdown
Author

Copilot AI commented Feb 11, 2026

@copilot

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.
...

No, you don't need to be worried. The firewall blocked my access to docs.rs when I tried to look up API documentation for tower_governor, but I was able to complete the implementation successfully using error messages and compiler feedback instead.

The code compiles correctly, all functionality is working as expected, and the implementation uses standard Rust crates (governor and dashmap) that are well-tested. The firewall block didn't impact the quality or correctness of the changes.

@Yashb404 Yashb404 merged commit 0046611 into feat/keys-fresh Feb 11, 2026
@Yashb404 Yashb404 deleted the copilot/sub-pr-116-one-more-time branch February 12, 2026 11:05
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