Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
- PR-scoped Strix scans must include trusted import context for changed backend
Python entrypoints; do not scan `backend/main.py` or routers as isolated
single files if that makes real repo modules look missing.
- PR-scoped Strix scans should include changed scanner/workflow/gate code but
exclude large CI self-test harnesses such as `scripts/ci/test_*.sh` from the
scanner target. Those harnesses remain covered by Strix self-tests; scanning
them as source can exhaust model context before security evidence finalizes.
- Prefer upgrading or removing vulnerable dependencies over downgrading patched
packages unless compatibility evidence is recorded in the PR.
- Strix Security Scan uses GitHub Models by default through
Expand Down Expand Up @@ -183,6 +187,15 @@
responses must sanitize stored subject/body/snippet/address display fields
before returning them. Preserve message/thread identifiers separately from
UI-safe subject/body, address, and attachment display text.
- Email file import must keep frontend file pickers, `/api/emails/import-files`,
and `services.email_import_service` in the same source-backed contract:
supported uploads are `.eml`, `.zip`, and `.mbox`; imported email and
attachment vectors must use the active organization LLM provider's
`embedding_model` and `base_url` when configured, fit provider vector
dimensions to storage, and fall back to zero vectors only when provider
embedding generation is unavailable. Tests must cover the local
`embeddinggemma` path so Data workspace imports do not silently bypass the
selected embedding model.
- Home/Today dashboard reply-wait surfaces must read signed
`/api/emails/pending-replies` data instead of inferring pending replies from
generic inbox fixtures or static copy. Tests and E2E mocks must verify the
Expand Down Expand Up @@ -210,6 +223,10 @@
roles. Platform-wide operators require the OIDC/JWKS path or a separately
audited support flow so compromise of an HMAC session secret cannot mint
platform administrator claims.
- `AUTH_SESSION_HMAC_SECRET` validation must enforce byte length, distinct
character count, character-class diversity, placeholder/public-fixture
rejection, and an explicit estimated entropy floor; keep runtime-secret tests
aligned so long low-entropy strings cannot pass by length alone.
- Reply-wait task escalation must reuse the server-authoritative pending reply
path, create or update source-linked `reply_sla` ticket tasks by opaque task
id, and sanitize generated task titles from email subjects before persistence.
Expand Down Expand Up @@ -245,6 +262,18 @@
`urllib.request.urlopen`; keep URL scheme validation and use explicit HTTP or
HTTPS clients so Bandit/Strix do not normalize test-only SSRF patterns into
production examples.
- Screenshot and browser-capture helper scripts must build navigation targets
from a fixed localhost origin and an explicit route allowlist before calling
Playwright `page.goto`; do not concatenate raw route or URL strings, and log
capture failures with fixed message templates plus sanitized fields.
- Alembic migrations must use structured Alembic/SQLAlchemy operation APIs such
as `op.create_index` and `op.drop_index` for schema objects. Do not build DDL
with `sa.text(f"...")` or interpolated identifier strings, even when the
current identifiers are static.
- Infrastructure Docker Compose services must inherit the repo hardening
contract: `no-new-privileges:true`, `read_only: true`, read-only config
mounts, and explicit `tmpfs` entries for the few runtime paths that must be
writable.
- Settings account screens must be source-backed by signed-session APIs rather
than static provider examples. Display only masked secret presence flags, keep
blank secret fields out of save payloads so stored values are preserved, and
Expand Down Expand Up @@ -280,6 +309,11 @@
the visible app language; do not rely on the SVG icon alone for Calendar,
Tasks, drawer, modal, or toolbar actions.
- Execution steps resulting in `Timeout`, `Fatal`, `Warn`, or `Denied` outputs are considered hard failures. Tests must run without these warnings to be considered passing.
- Strix success artifacts must also be scanned for `Timeout`, `Fatal`, `Warn`,
or `Denied` output before accepting clean evidence. Filter only narrowly known
third-party Strix internal warnings, such as the
`strix.core.execution` non-lifecycle continuation line, before artifact upload;
fail closed on any remaining warning-class report log output.
- DB-affecting API slices need both mocked fast tests and a real PostgreSQL
bootstrap/smoke path before PR merge evidence is considered complete.
- When a backend container reports missing `DATABASE_URL` or
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
## [Unreleased]

## [0.14.4] - 2026-06-18

### 추가
- Seongho Bae (@seonghobae): signed email import pipeline이 `.eml`, `.zip`에
더해 `.mbox` mailbox export를 받아 source-linked email record로 가져오도록
확장하고, 가져온 email body와 attachment content embedding을 조직의 active
provider `embedding_model`(local runtime 기본 `embeddinggemma`)로 생성해 저장
차원에 맞춰 보정하도록 했습니다.

### 수정
- Seongho Bae (@seonghobae): OpenCode Agent가 실패한 Strix/GitHub Checks를
승인 전 직접 조회하고, failed log/annotation에서 확인한 각 line별 수정사항과
Strix multi-model vulnerability report를 리뷰에 모두 포함하도록 release
governance self-test와 workflow 계약을 동기화했습니다.

### 추가
- Seongho Bae (@seonghobae): Render.com Blueprint(`render.yaml`)와
`docs/operations/render-deployment.md` runbook을 추가해 frontend와 backend를
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ ARG OCI_IMAGE_AUTHORS="Seongho Bae"
ARG OCI_IMAGE_URL="https://github.com/Seongho-Bae/naruon"
ARG OCI_IMAGE_DOCUMENTATION="https://github.com/Seongho-Bae/naruon#readme"
ARG OCI_IMAGE_SOURCE="https://github.com/Seongho-Bae/naruon"
ARG OCI_IMAGE_VERSION="0.14.3"
ARG OCI_IMAGE_VERSION="0.14.4"
ARG OCI_IMAGE_REVISION=""
ARG OCI_IMAGE_VENDOR="Seongho-Bae"
ARG OCI_IMAGE_LICENSES="LicenseRef-Naruon-Proprietary"
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ runner. Raise those values only with explicit build evidence.
`Reply-To` headers.
- Importers persist the canonical service-assigned `thread_id`; they do not
recompute their own thread IDs.
- Signed email file imports accept `.eml`, `.zip`, and `.mbox` uploads through
`/api/emails/import-files`; imported email and attachment vectors use the
active organization embedding model such as local `embeddinggemma` when an
LLM provider is configured.
- Duplicate ZIP/forward candidates can be checked through signed
`/api/emails/unique-thread-intent`. The intent uses normalized Message-ID and
strong body fingerprint matches, returns canonical thread metadata, and does
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.14.3
0.14.4
Comment thread
seonghobae marked this conversation as resolved.
Resolved
14 changes: 6 additions & 8 deletions backend/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def _verify_signed_session_token(token: str) -> tuple[dict[str, Any], SessionVer
raise _authentication_error()
try:
payload = _decode_cached_oidc_session_payload(token)
_reject_signed_session_system_admin_payload(payload)
_reject_signed_session_admin_payload(payload)
return payload, "oidc"
except Exception:
raise _authentication_error() from None
Expand Down Expand Up @@ -407,19 +407,17 @@ def _verify_signed_session_token(token: str) -> tuple[dict[str, Any], SessionVer
raise _authentication_error()
if not isinstance(payload, dict):
raise _authentication_error()
_reject_signed_session_system_admin_payload(payload)
_reject_signed_session_admin_payload(payload)
return payload, "hmac"


def _reject_signed_session_system_admin_payload(payload: dict[str, Any]) -> None:
def _reject_signed_session_admin_payload(payload: dict[str, Any]) -> None:
role_claim = payload.get("role")
if not isinstance(role_claim, str):
raise _authentication_error()
# SaaS control-plane roles require explicit server-side assignment, not
# externally supplied HMAC or enterprise OIDC session claims.
if role_claim in SYSTEM_ADMIN_ROLES:
raise _authentication_error()
if role_claim in TENANT_ADMIN_ROLES:
# Admin roles require explicit server-side assignment, not externally
# supplied HMAC or enterprise OIDC session claims.
if role_claim in ADMIN_ROLES:
raise _authentication_error()


Expand Down
22 changes: 21 additions & 1 deletion backend/api/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@
email_strong_fingerprint,
)
from services.email_import_service import (
EmailImportEmbeddingProvider,
EmailImportQuotaExceeded,
MAX_IMPORT_UPLOAD_BYTES,
MAX_IMPORT_UPLOADS,
EmailImportItemStatus,
EmailImportUpload,
import_email_uploads,
)
from services.llm_provider_selection import resolve_runtime_llm_provider
from services.text_safety import strip_html_markup
import logging
from api.auth import AuthContext, get_auth_context
Expand Down Expand Up @@ -495,7 +497,11 @@ async def import_email_files(
uploads: list[EmailImportUpload] = []
for upload in files:
normalized_filename = upload.filename.lower().strip() if upload.filename else ""
if not upload.filename or not (normalized_filename.endswith(".eml") or normalized_filename.endswith(".zip") or normalized_filename.endswith(".mbox")):
if not upload.filename or not (
normalized_filename.endswith(".eml")
or normalized_filename.endswith(".zip")
or normalized_filename.endswith(".mbox")
):
raise HTTPException(status_code=400, detail="invalid_file_type")

content = await upload.read(MAX_IMPORT_UPLOAD_BYTES + 1)
Expand All @@ -508,12 +514,26 @@ async def import_email_files(
)
)

runtime_provider = await resolve_runtime_llm_provider(
db,
user_id=auth_context.user_id,
organization_id=auth_context.organization_id,
)
embedding_provider = None
if runtime_provider is not None:
embedding_provider = EmailImportEmbeddingProvider(
api_key=runtime_provider.api_key,
base_url=runtime_provider.base_url,
embedding_model=runtime_provider.embedding_model,
)

try:
import_result = await import_email_uploads(
db,
uploads=uploads,
user_id=auth_context.user_id,
organization_id=auth_context.organization_id,
embedding_provider=embedding_provider,
)
except EmailImportQuotaExceeded as exc:
raise HTTPException(
Expand Down
21 changes: 21 additions & 0 deletions backend/core/runtime_secrets.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import math
from collections import Counter


MIN_AUTH_SESSION_HMAC_SECRET_BYTES = 32
MIN_AUTH_SESSION_HMAC_SECRET_UNIQUE_CHARS = 12
MIN_AUTH_SESSION_HMAC_SECRET_CHARACTER_CLASSES = 3
MIN_AUTH_SESSION_HMAC_SECRET_ENTROPY_BITS = 128.0
_LOW_ENTROPY_PLACEHOLDER_TERMS = ("change", "example", "password", "secret")
_KNOWN_PUBLIC_AUTH_SESSION_HMAC_SECRETS = frozenset(
{"naruon-session-hmac-token-32-byte-minimum"}
Expand All @@ -18,6 +23,18 @@ def _character_class_count(secret: str) -> int:
)


def _shannon_entropy_bits(secret: str) -> float:
length = len(secret)
counts = Counter(secret)
return (
-sum(
(count / length) * math.log2(count / length)
for count in counts.values()
)
* length
)


def validate_auth_session_hmac_secret_value(secret: str) -> None:
if not secret:
raise ValueError(
Expand All @@ -43,3 +60,7 @@ def validate_auth_session_hmac_secret_value(secret: str) -> None:
raise ValueError(
"AUTH_SESSION_HMAC_SECRET must use at least three character classes"
)
if _shannon_entropy_bits(secret) < MIN_AUTH_SESSION_HMAC_SECRET_ENTROPY_BITS:
raise ValueError(
"AUTH_SESSION_HMAC_SECRET must provide at least 128 bits of estimated entropy"
)
46 changes: 34 additions & 12 deletions backend/db/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import base64
import binascii
import datetime
import logging
import uuid
Expand Down Expand Up @@ -25,19 +27,37 @@
Base = declarative_base()


def _validated_fernet_key() -> bytes:
if settings.ENCRYPTION_KEY is None:
raise RuntimeError(
"ENCRYPTION_KEY is required. Refusing to encrypt without a configured key."
)

key = settings.ENCRYPTION_KEY.get_secret_value().encode("utf-8")
try:
decoded_key = base64.urlsafe_b64decode(key)
except (binascii.Error, ValueError) as exc:
raise RuntimeError(
"ENCRYPTION_KEY must be a valid Fernet key generated by "
"Fernet.generate_key()."
) from exc
if len(decoded_key) != 32:
raise RuntimeError(
"ENCRYPTION_KEY must be a valid Fernet key generated by "
"Fernet.generate_key()."
)
return key


def get_fernet() -> Fernet:
if settings.ENCRYPTION_KEY is not None:
key = settings.ENCRYPTION_KEY.get_secret_value().encode("utf-8")
try:
return Fernet(key)
except ValueError as exc:
raise RuntimeError(
"ENCRYPTION_KEY must be a valid Fernet key generated by "
"Fernet.generate_key()."
) from exc
raise RuntimeError(
"ENCRYPTION_KEY is required. Refusing to encrypt without a configured key."
)
key = _validated_fernet_key()
try:
return Fernet(key)
except ValueError as exc:
raise RuntimeError(
"ENCRYPTION_KEY must be a valid Fernet key generated by "
"Fernet.generate_key()."
) from exc


class EncryptedString(TypeDecorator):
Expand Down Expand Up @@ -334,6 +354,8 @@ class Email(Base):
)

id: Mapped[int] = mapped_column(primary_key=True)
# Owner scope columns are intentionally plaintext and indexed: signed-session
# ABAC filters must be enforced by SQL before email rows are returned.
user_id: Mapped[str] = mapped_column(String, index=True, nullable=False)
organization_id: Mapped[str] = mapped_column(String, index=True, nullable=False)
message_id: Mapped[str] = mapped_column(String, index=True)
Expand Down
Loading
Loading