Skip to content

feat: 인바운드 안전 SDK 래퍼 — 인젝션 신호 + 발신자 규칙 (#369/#370) - #4

Merged
bluelucifer merged 2 commits into
mainfrom
feat/inbound-safety-369-370
Jun 25, 2026
Merged

feat: 인바운드 안전 SDK 래퍼 — 인젝션 신호 + 발신자 규칙 (#369/#370)#4
bluelucifer merged 2 commits into
mainfrom
feat/inbound-safety-369-370

Conversation

@bluelucifer

@bluelucifer bluelucifer commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

core #377(#369 인젝션 스캐너) + #378(#370 발신자 allow/block)의 Python SDK 래퍼.

변경

  • Message: injection_score(0~1) + injection_categories(#369) — 수신 메일 프롬프트-인젝션 휴리스틱 신호(차단 아님, 에이전트가 판단).
  • client.inbound_rules(#370): list/create/remove — 발신자 allow/block(per-mailbox/org-wide). InboundSenderRule 모델.
  • 버전 0.2.0 → 0.3.0. 테스트 4(인젝션 파싱·규칙 CRUD), README 인바운드 안전 섹션.

검증

17 pytest 통과, ruff·mypy clean.

Summary by CodeRabbit

  • New Features

    • Added inbound safety support with message-level heuristic signals for suspicious content.
    • Added inbound sender allow/block rule management to control which emails are accepted.
  • Bug Fixes

    • Inbound sender checks now use the SMTP envelope sender, with allow-lists blocking unmatched senders.
  • Chores

    • Updated the package version to 0.3.0.

- Message: injection_score / injection_categories(#369 프롬프트-인젝션 휴리스틱 신호).
- inbound_rules 리소스(#370): list/create/remove — 발신자 allow/block(per-mailbox/org-wide).
- InboundSenderRule 모델 + 패키지 export. 버전 0.2.0 → 0.3.0.
- 테스트 4(인젝션 파싱·규칙 CRUD), README 인바운드 안전 섹션. ruff/mypy clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@bluelucifer, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 53 minutes and 59 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d1058137-a19f-4347-a46d-e58abd6e07d4

📥 Commits

Reviewing files that changed from the base of the PR and between f1695d0 and 5583108.

📒 Files selected for processing (1)
  • tests/test_client.py
📝 Walkthrough

Walkthrough

The PR adds inbound safety documentation, inbound message heuristic fields, a new InboundSenderRule model, and client endpoints for listing, creating, and removing inbound sender rules. Package and user-agent versions were updated to 0.3.0.

Changes

Inbound safety and sender rules

Layer / File(s) Summary
Message and rule contracts
loftbox/models.py, loftbox/__init__.py, pyproject.toml, tests/test_client.py
Message adds injection_score and injection_categories, InboundSenderRule is introduced and exported, package version metadata moves to 0.3.0, and a test checks parsing of the new message fields.
Inbound rule client surface
loftbox/client.py, tests/test_client.py
LoftBox wires an inbound_rules namespace, and the new resource lists, creates, and removes inbound sender rules while tests verify the request shapes and parsed responses.
Inbound safety README
README.md
The README adds an inbound safety section with injection_score/injection_categories examples, inbound sender rule examples, and sender-matching notes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A rabbit hops through inbox glow,
With 0.3.0 in tidy flow.
He sniffs the signals, stamps the rule,
And guards the burrow, wise and cool.
🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 인바운드 안전 SDK 래퍼, 인젝션 신호, 발신자 규칙 추가라는 PR의 핵심 변경을 정확히 요약합니다.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/inbound-safety-369-370

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.

@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: 1

🤖 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 `@loftbox/client.py`:
- Around line 439-451: The pagination cursor name in InboundSenderRule list
methods is inconsistent with the rest of the client API. Update
InboundSenderRules.list to use cursor instead of before, and make the same
change in _Suppressions.list so callers can pass the Page.next_cursor value
through consistently. Keep the request parameter mapping aligned in the shared
list method implementations and preserve the existing Page model behavior.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2f5b95c9-525b-4979-91e7-9cb600aab51f

📥 Commits

Reviewing files that changed from the base of the PR and between fb224ae and f1695d0.

📒 Files selected for processing (6)
  • README.md
  • loftbox/__init__.py
  • loftbox/client.py
  • loftbox/models.py
  • pyproject.toml
  • tests/test_client.py

Comment thread loftbox/client.py
Comment on lines +439 to +451
def list(
self,
*,
mailbox_id: Optional[str] = None,
limit: Optional[int] = None,
before: Optional[str] = None,
) -> Page[InboundSenderRule]:
raw = self._c._request(
"GET",
"/v1/inbound-rules",
params={"mailbox_id": mailbox_id, "limit": limit, "before": before},
)
return _page(raw, InboundSenderRule)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Inspect all list() signatures and pagination param usage across resources.
rg -nP '\bdef list\s*\(' loftbox/client.py -A 8
rg -nP '\b(before|after|cursor|next_cursor)\b' loftbox/client.py loftbox/models.py

Repository: TheMagicTower/loftbox-sdk-python

Length of output: 3767


Inconsistent pagination parameter naming

The InboundSenderRules.list and _Suppressions.list methods use before as the pagination cursor parameter, whereas Agent, Folder, and Thread list methods use cursor. Additionally, the Page model explicitly exposes next_cursor, creating a naming mismatch for callers attempting to chain pages (e.g., next_cursor vs before). Align the input parameter name to cursor across all list methods for consistency.

    def list(
        self,
        *,
        mailbox_id: Optional[str] = None,
        limit: Optional[int] = None,
-       before: Optional[str] = None,
+       cursor: Optional[str] = None,
    ) -> Page[InboundSenderRule]:
        raw = self._c._request(
            "GET",
            "/v1/inbound-rules",
-           params={"mailbox_id": mailbox_id, "limit": limit, "before": before},
+           params={"mailbox_id": mailbox_id, "limit": limit, "cursor": cursor},
        )
        return _page(raw, InboundSenderRule)
📝 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
def list(
self,
*,
mailbox_id: Optional[str] = None,
limit: Optional[int] = None,
before: Optional[str] = None,
) -> Page[InboundSenderRule]:
raw = self._c._request(
"GET",
"/v1/inbound-rules",
params={"mailbox_id": mailbox_id, "limit": limit, "before": before},
)
return _page(raw, InboundSenderRule)
def list(
self,
*,
mailbox_id: Optional[str] = None,
limit: Optional[int] = None,
cursor: Optional[str] = None,
) -> Page[InboundSenderRule]:
raw = self._c._request(
"GET",
"/v1/inbound-rules",
params={"mailbox_id": mailbox_id, "limit": limit, "cursor": cursor},
)
return _page(raw, InboundSenderRule)
🤖 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 `@loftbox/client.py` around lines 439 - 451, The pagination cursor name in
InboundSenderRule list methods is inconsistent with the rest of the client API.
Update InboundSenderRules.list to use cursor instead of before, and make the
same change in _Suppressions.list so callers can pass the Page.next_cursor value
through consistently. Keep the request parameter mapping aligned in the shared
list method implementations and preserve the existing Page model behavior.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bluelucifer
bluelucifer merged commit 0d7cde1 into main Jun 25, 2026
3 checks passed
@bluelucifer
bluelucifer deleted the feat/inbound-safety-369-370 branch June 25, 2026 06:28
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