diff --git a/backend/alembic/versions/08a73307418d_add_gitea_username_to_user_model.py b/backend/alembic/versions/08a73307418d_add_gitea_username_to_user_model.py
new file mode 100644
index 0000000..0453be0
--- /dev/null
+++ b/backend/alembic/versions/08a73307418d_add_gitea_username_to_user_model.py
@@ -0,0 +1,34 @@
+"""add gitea_username to user model
+
+Revision ID: 08a73307418d
+Revises: ecc7c0ff0957
+Create Date: 2026-01-05 13:36:16.845876
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '08a73307418d'
+down_revision = 'ecc7c0ff0957'
+branch_labels = None
+depends_on = None
+
+
+def upgrade() -> None:
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.add_column('users', sa.Column('gitea_username', sa.String(), nullable=True))
+ # ### end Alembic commands ###
+
+
+def downgrade() -> None:
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.drop_column('users', 'gitea_username')
+ # ### end Alembic commands ###
+
+
+
+
+
+
diff --git a/backend/app/core/security.py b/backend/app/core/security.py
index cb9ca20..e13d3ca 100644
--- a/backend/app/core/security.py
+++ b/backend/app/core/security.py
@@ -1,18 +1,10 @@
from datetime import datetime, timedelta, timezone
from typing import Any, Union
from jose import jwt
-import bcrypt # Import first
+import bcrypt
-# MonkeyPatch passlib/bcrypt compatibility (passlib expects __about__)
-if not hasattr(bcrypt, "__about__"):
- from types import SimpleNamespace
- bcrypt.__about__ = SimpleNamespace(__version__=bcrypt.__version__)
-
-from passlib.context import CryptContext
from app.core.config import settings
-pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
-
ALGORITHM = settings.ALGORITHM
def create_access_token(
@@ -29,10 +21,36 @@ def create_access_token(
return encoded_jwt
def verify_password(plain_password: str, hashed_password: str) -> bool:
- return pwd_context.verify(plain_password, hashed_password)
+ """
+ Verify a password against a hash.
+ Explicitly truncate to 72 bytes to avoid bcrypt ValueError and maintain compatibility.
+ """
+ if not plain_password or not hashed_password:
+ return False
+
+ try:
+ password_bytes = plain_password.encode("utf-8")
+ if len(password_bytes) > 72:
+ password_bytes = password_bytes[:72]
+
+ return bcrypt.checkpw(
+ password_bytes,
+ hashed_password.encode("utf-8")
+ )
+ except Exception:
+ return False
def get_password_hash(password: str) -> str:
- return pwd_context.hash(password)
+ """
+ Generate a bcrypt hash of the password.
+ Explicitly truncate to 72 bytes for consistency.
+ """
+ password_bytes = password.encode("utf-8")
+ if len(password_bytes) > 72:
+ password_bytes = password_bytes[:72]
+
+ salt = bcrypt.gensalt()
+ return bcrypt.hashpw(password_bytes, salt).decode("utf-8")
diff --git a/backend/app/models/user.py b/backend/app/models/user.py
index 89d6157..3f6148e 100644
--- a/backend/app/models/user.py
+++ b/backend/app/models/user.py
@@ -19,6 +19,7 @@ class User(Base):
role = Column(String, default="member")
github_username = Column(String, nullable=True)
gitlab_username = Column(String, nullable=True)
+ gitea_username = Column(String, nullable=True)
created_at = Column(DateTime(timezone=True), server_default=func.now())
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
diff --git a/backend/app/schemas/user.py b/backend/app/schemas/user.py
index 88825e9..0f53794 100644
--- a/backend/app/schemas/user.py
+++ b/backend/app/schemas/user.py
@@ -13,6 +13,7 @@ class UserBase(BaseModel):
role: str = "member"
github_username: Optional[str] = None
gitlab_username: Optional[str] = None
+ gitea_username: Optional[str] = None
class UserCreate(UserBase):
email: EmailStr
diff --git a/backend/app/services/init_templates.py b/backend/app/services/init_templates.py
index dbe4c8a..ef854c7 100644
--- a/backend/app/services/init_templates.py
+++ b/backend/app/services/init_templates.py
@@ -275,8 +275,8 @@ SYSTEM_RULE_SETS = [
"description": "基于 OWASP Top 10 2021 的安全审计规则集",
"language": "all",
"rule_type": "security",
- "is_default": True,
- "sort_order": 0,
+ "is_default": False,
+ "sort_order": 1,
"severity_weights": {"critical": 10, "high": 5, "medium": 2, "low": 1},
"rules": [
{
@@ -386,8 +386,8 @@ SYSTEM_RULE_SETS = [
"description": "通用代码质量检查规则集",
"language": "all",
"rule_type": "quality",
- "is_default": False,
- "sort_order": 1,
+ "is_default": True,
+ "sort_order": 0,
"severity_weights": {"critical": 10, "high": 5, "medium": 2, "low": 1},
"rules": [
{
@@ -550,6 +550,11 @@ async def init_system_templates(db: AsyncSession) -> None:
)
db.add(template)
logger.info(f"✓ 创建系统提示词模板: {template_data['name']}")
+ else:
+ # 更新已存在的系统模板的默认状态和排序
+ existing.is_default = template_data.get("is_default", False)
+ existing.sort_order = template_data.get("sort_order", 0)
+ db.add(existing)
await db.flush()
@@ -599,6 +604,11 @@ async def init_system_rule_sets(db: AsyncSession) -> None:
db.add(rule)
logger.info(f"✓ 创建系统规则集: {rule_set_data['name']} ({len(rule_set_data.get('rules', []))} 条规则)")
+ else:
+ # 更新已存在的系统规则集的默认状态和排序
+ existing.is_default = rule_set_data.get("is_default", False)
+ existing.sort_order = rule_set_data.get("sort_order", 0)
+ db.add(existing)
await db.flush()
diff --git a/frontend/src/components/audit/TerminalProgressDialog.tsx b/frontend/src/components/audit/TerminalProgressDialog.tsx
index 76c057f..ba4173b 100644
--- a/frontend/src/components/audit/TerminalProgressDialog.tsx
+++ b/frontend/src/components/audit/TerminalProgressDialog.tsx
@@ -467,7 +467,6 @@ export default function TerminalProgressDialog({