当前位置:首页>python>一天一个Python知识点——Day 132:Python安全编程基础

一天一个Python知识点——Day 132:Python安全编程基础

  • 2026-02-05 04:10:51
一天一个Python知识点——Day 132:Python安全编程基础

今天我们从代码质量转向一个更为关键的领域——安全编程。编写安全的Python代码是保护应用和数据的第一道防线。

1. 为什么安全编程至关重要?

安全漏洞可能导致数据泄露、服务中断甚至法律风险。Python应用常见的安全问题:

漏洞类型
潜在影响
Python中的常见原因
注入攻击
数据泄露、系统控制
未经验证的用户输入直接拼接SQL/命令
信息泄露
敏感数据暴露
错误消息包含堆栈跟踪、配置硬编码
身份验证绕过
未授权访问
弱密码策略、会话管理不当
反序列化漏洞
远程代码执行
不安全的pickle使用
依赖风险
供应链攻击
未及时更新有漏洞的第三方包

2. Python安全编程全景图

3. 常见安全漏洞与防护

3.1 SQL注入防护

危险代码示例:

# ❌ 危险:直接拼接用户输入import sqlite3def get_user_unsafe(username: str):    conn = sqlite3.connect('database.db')    cursor = conn.cursor()    # 攻击者可以输入: admin' OR '1'='1    query = f"SELECT * FROM users WHERE username = '{username}'"    cursor.execute(query)  # SQL注入漏洞!    return cursor.fetchall()
安全解决方案:
# ✅ 安全:使用参数化查询def get_user_safe(username: str):    conn = sqlite3.connect('database.db')    cursor = conn.cursor()    # 参数化查询(推荐)    query = "SELECT * FROM users WHERE username = ?"    cursor.execute(query, (username,))  # 自动转义    # 或使用命名参数    query = "SELECT * FROM users WHERE username = :username"    cursor.execute(query, {'username': username})    return cursor.fetchall()# ✅ 使用ORM(如SQLAlchemy)更安全from sqlalchemy import textfrom sqlalchemy.orm import Sessiondef get_user_orm(db: Session, username: str):    query = text("SELECT * FROM users WHERE username = :username")    result = db.execute(query, {'username': username})    return result.fetchall()

3.2 跨站脚本(XSS)防护

危险代码示例:

# ❌ 危险:直接渲染未转义的用户输入from flask import Flask, requestapp = Flask(__name__)@app.route('/unsafe')def unsafe_comment():    user_comment = request.args.get('comment', '')    # 攻击者可以输入: <script>alert('XSS')</script>    return f"""    <html>        <body>            <div>{user_comment}</div>  <!-- XSS漏洞! -->        </body>    </html>    """
安全解决方案:
# ✅ 安全:使用模板引擎自动转义from flask import Flask, render_template, requestimport htmlapp = Flask(__name__)@app.route('/safe')def safe_comment():    user_comment = request.args.get('comment''')    # 方案1:手动转义(不推荐,容易遗漏)    escaped_comment = html.escape(user_comment)    # 方案2:使用模板引擎(推荐)    return render_template('comment.html', comment=user_comment)    # 在Jinja2模板中:{{ comment|safe }} 仅当确定内容安全时使用# ✅ 使用现代框架的安全功能from markupsafe import Markup, escapedef render_user_content(content: str, is_trusted: bool = False):    if is_trusted:        # 仅当内容来自可信来源时        return Markup(content)    else:        # 默认转义所有HTML特殊字符        return escape(content)

3.3 命令注入防护

危险代码示例:

# ❌ 危险:直接执行用户输入import subprocessimport osdef ping_unsafe(hostname: str):    # 攻击者可以输入: google.com && rm -rf /    command = f"ping -c 4 {hostname}"    result = subprocess.run(command, shell=True, capture_output=True)  # 命令注入!    return result.stdout.decode()
安全解决方案:
# ✅ 安全:避免使用shell,使用参数列表def ping_safe(hostname: str):    # 验证输入    import re    if not re.match(r'^[a-zA-Z0-9.-]+$', hostname):        raise ValueError("Invalid hostname")    # 不使用shell参数,使用参数列表    command = ["ping""-c""4", hostname]    result = subprocess.run(command, capture_output=True)  # shell=False是默认值    return result.stdout.decode()# ✅ 更安全的替代方案:使用专用库import socketimport platformdef ping_library(hostname: str):    """使用系统库而不是执行命令"""    try:        # 尝试解析主机名        ip = socket.gethostbyname(hostname)        # 根据系统使用不同方法        system = platform.system()        if system == "Windows":            command = ["ping""-n""4", hostname]        else:            command = ["ping""-c""4", hostname]        result = subprocess.run(command, capture_output=True)        return result.stdout.decode()    except socket.error as e:        return f"Error: {e}"

4. 身份验证与密码安全

4.1 安全密码处理

import hashlibimport secretsimport bcryptimport argon2# ❌ 不安全:使用简单哈希def hash_password_unsafe(password: str) -> str:    """不安全:无盐的MD5哈希"""    return hashlib.md5(password.encode()).hexdigest()# ✅ 安全:使用bcrypt(推荐)def hash_password_bcrypt(password: str) -> str:    """使用bcrypt自动加盐和哈希"""    # 生成盐并哈希,自动处理盐的存储    salt = bcrypt.gensalt(rounds=12)  # 适当的工作因子    hashed = bcrypt.hashpw(password.encode(), salt)    return hashed.decode()def verify_password_bcrypt(password: str, hashed: str) -> bool:    """验证bcrypt密码"""    return bcrypt.checkpw(password.encode(), hashed.encode())# ✅ 安全:使用Argon2(现代选择)def hash_password_argon2(password: str) -> str:    """使用Argon2,抗GPU/ASIC攻击"""    argon2_hasher = argon2.PasswordHasher(        time_cost=3,      # 迭代次数        memory_cost=65536# 内存使用(KiB)        parallelism=4,    # 并行线程数        hash_len=32,      # 哈希长度        salt_len=16       # 盐长度    )    return argon2_hasher.hash(password)# ✅ 使用secrets模块生成安全令牌def generate_tokens():    """生成各种安全令牌"""    # 安全的随机令牌(适合密码重置、会话令牌)    reset_token = secrets.token_urlsafe(32)  # URL安全的Base64    session_token = secrets.token_hex(32)    # 十六进制    # 临时密码生成    import string    alphabet = string.ascii_letters + string.digits    temp_password = ''.join(secrets.choice(alphabet) for _ in range(16))    return {        'reset_token': reset_token,        'session_token': session_token,        'temp_password': temp_password    }

4.2 会话安全管理

import uuidimport timefrom datetime import datetime, timedeltafrom typing import DictOptionalclass SecureSessionManager:    """安全的会话管理示例"""    def __init__(self):        self.sessions: Dict[strdict] = {}        self.session_timeout = 3600  # 1小时    def create_session(self, user_id: str, user_agent: str, ip_address: str) -> str:        """创建新会话"""        session_id = str(uuid.uuid4())        self.sessions[session_id] = {            'user_id': user_id,            'created_at': time.time(),            'last_activity': time.time(),            'user_agent': user_agent,            'ip_address': ip_address,            'is_valid'True        }        # 定期清理过期会话        self._cleanup_expired_sessions()        return session_id    def validate_session(self, session_id: str, user_agent: str, ip_address: str) -> bool:        """验证会话是否有效"""        if session_id not in self.sessions:            return False        session = self.sessions[session_id]        # 检查是否过期        if time.time() - session['last_activity'] > self.session_timeout:            self._invalidate_session(session_id)            return False        # 检查会话是否被撤销        if not session['is_valid']:            return False        # 可选:检查用户代理和IP是否匹配(加强安全)        # if session['user_agent'] != user_agent:        #     self._invalidate_session(session_id)        #     return False        # 更新最后活动时间        session['last_activity'] = time.time()        return True    def _invalidate_session(self, session_id: str):        """使会话失效"""        if session_id in self.sessions:            self.sessions[session_id]['is_valid'] = False            # 或者直接删除:del self.sessions[session_id]    def _cleanup_expired_sessions(self):        """清理过期会话"""        current_time = time.time()        expired = [            sid for sid, session in self.sessions.items()            if current_time - session['last_activity'] > self.session_timeout * 2        ]        for sid in expired:            del self.sessions[sid]

5. 安全配置与依赖管理

5.1 安全配置管理

import osfrom typing import Anyimport jsonimport hmacfrom cryptography.fernet import Fernetclass SecureConfig:    """安全配置管理"""    def __init__(self):        # 从环境变量读取配置(而不是硬编码或配置文件)        self.config = {            'database_url'self._get_env_with_default('DATABASE_URL'),            'secret_key'self._get_required_env('SECRET_KEY'),            'debug'self._get_bool_env('DEBUG'False),            'allowed_hosts'self._get_list_env('ALLOWED_HOSTS', ['localhost']),            'encryption_key'self._get_required_env('ENCRYPTION_KEY'),        }        # 验证关键配置        self._validate_config()    def _get_env_with_default(self, key: str, default: Any = None) -> Any:        """从环境变量获取值,支持默认值"""        value = os.environ.get(key)        return value if value is not None else default    def _get_required_env(self, key: str) -> str:        """获取必需的环境变量"""        value = os.environ.get(key)        if not value:            raise ValueError(f"Required environment variable {key} is not set")        return value    def _get_bool_env(self, key: str, default: bool = False) -> bool:        """获取布尔环境变量"""        value = os.environ.get(key, '').lower()        if value in ('true''1''yes''on'):            return True        elif value in ('false''0''no''off'):            return False        return default    def _get_list_env(self, key: str, default: list = None) -> list:        """获取列表环境变量"""        value = os.environ.get(key)        if value:            return [item.strip() for item in value.split(',')]        return default or []    def _validate_config(self):        """验证配置安全性"""        # 检查密钥长度        if len(self.config['secret_key']) < 32:            raise ValueError("SECRET_KEY must be at least 32 characters")        # 生产环境应禁用debug        if os.environ.get('ENVIRONMENT') == 'production' and self.config['debug']:            raise ValueError("Debug mode must be disabled in production")# 加密敏感配置值class ConfigEncryptor:    """配置值加密"""    def __init__(self, encryption_key: str):        # 确保密钥是32字节的URL安全的base64编码        if len(encryption_key) != 44:  # Fernet密钥长度            raise ValueError("Invalid encryption key length")        self.cipher = Fernet(encryption_key.encode())    def encrypt_value(self, plaintext: str) -> str:        """加密配置值"""        return self.cipher.encrypt(plaintext.encode()).decode()    def decrypt_value(self, ciphertext: str) -> str:        """解密配置值"""        return self.cipher.decrypt(ciphertext.encode()).decode()

5.2 依赖安全检查

import subprocessimport jsonfrom typing import ListDictimport requestsclass DependencyScanner:    """依赖安全扫描"""    @staticmethod    def check_vulnerabilities():        """检查项目依赖中的已知漏洞"""        # 方案1:使用safety检查(需要安装safety包)        try:            result = subprocess.run(                ['safety''check''--json'],                capture_output=True,                text=True            )            if result.returncode != 0:                vulnerabilities = json.loads(result.stdout)                print(f"Found {len(vulnerabilities)} vulnerabilities:")                for vuln in vulnerabilities:                    print(f"- {vuln['package_name']}{vuln['vulnerability_id']}")        except Exception as e:            print(f"Safety check failed: {e}")        # 方案2:使用pip-audit        try:            result = subprocess.run(                ['pip-audit'],                capture_output=True,                text=True            )            print(result.stdout)        except FileNotFoundError:            print("pip-audit not installed. Install with: pip install pip-audit")    @staticmethod    def get_outdated_packages() -> List[Dict]:        """检查过期的依赖包"""        try:            result = subprocess.run(                ['pip''list''--outdated''--format=json'],                capture_output=True,                text=True            )            if result.returncode == 0:                return json.loads(result.stdout)            return []        except Exception as e:            print(f"Failed to check outdated packages: {e}")            return []    @staticmethod    def generate_requirements_with_hashes():        """生成带哈希值的requirements文件"""        try:            result = subprocess.run(                ['pip''hash''-r''requirements.txt'],                capture_output=True,                text=True            )            print(result.stdout)        except Exception as e:            print(f"Failed to generate hashes: {e}")

6. 完整的安全Web应用示例

"""安全Flask Web应用示例"""from flask import Flask, request, session, render_template, redirect, url_forfrom flask_wtf import CSRFProtectfrom flask_limiter import Limiterfrom flask_limiter.util import get_remote_addressimport bcryptimport secretsfrom typing import Optionalimport osapp = Flask(__name__)# 安全配置app.config.update(    SECRET_KEY=os.environ.get('SECRET_KEY', secrets.token_hex(32)),    SESSION_COOKIE_HTTPONLY=True,      # 防止JavaScript访问cookie    SESSION_COOKIE_SECURE=True,        # 仅HTTPS传输    SESSION_COOKIE_SAMESITE='Lax',     # CSRF防护    PERMANENT_SESSION_LIFETIME=3600,   # 会话过期时间    WTF_CSRF_ENABLED=True,             # 启用CSRF保护)# 启用CSRF保护csrf = CSRFProtect(app)# 启用速率限制limiter = Limiter(    get_remote_address,    app=app,    default_limits=["200 per day""50 per hour"],    storage_uri="memory://",)# 模拟用户存储users_db = {    'alice': {        'password_hash': bcrypt.hashpw('secure_password123'.encode(), bcrypt.gensalt()),        'failed_attempts'0,        'locked_until'None    }}@app.route('/')def index():    return render_template('index.html')@app.route('/login', methods=['GET''POST'])@limiter.limit("5 per minute")  # 登录速率限制def login():    if request.method == 'POST':        username = request.form.get('username''').strip()        password = request.form.get('password''')        # 输入验证        if not username or not password:            return "Username and password required"400        # 防止用户名枚举攻击:统一响应时间        import time        start_time = time.time()        user = users_db.get(username)        if user and not is_account_locked(user):            # 验证密码(恒定时间比较)            if bcrypt.checkpw(password.encode(), user['password_hash']):                # 重置失败计数                user['failed_attempts'] = 0                # 创建会话                session['user_id'] = username                session['login_time'] = time.time()                session['user_agent'] = request.headers.get('User-Agent''')                return redirect(url_for('dashboard'))            else:                # 增加失败计数                user['failed_attempts'] += 1                if user['failed_attempts'] >= 5:                    user['locked_until'] = time.time() + 300  # 锁定5分钟        # 恒定延迟以防止时序攻击        elapsed = time.time() - start_time        if elapsed < 0.5:  # 最小响应时间            time.sleep(0.5 - elapsed)        return "Invalid credentials"401    return render_template('login.html')def is_account_locked(user: dict) -> bool:    """检查账户是否被锁定"""    import time    if user.get('locked_until'):        return time.time() < user['locked_until']    return False@app.route('/dashboard')def dashboard():    if 'user_id' not in session:        return redirect(url_for('login'))    return render_template('dashboard.html', user=session['user_id'])@app.route('/logout')def logout():    # 安全地清除会话    session.clear()    return redirect(url_for('index'))if __name__ == '__main__':    # 生产环境应使用WSGI服务器,而不是开发服务器    app.run(        host='0.0.0.0',        port=5000,        debug=False,  # 生产环境必须为False        ssl_context='adhoc'  # 开发环境使用自签名证书    )

7. 安全工具推荐

工具
用途
安装
bandit
代码安全漏洞扫描
pip install bandit
safety
检查依赖漏洞
pip install safety
pip-audit
审计Python包漏洞
pip install pip-audit
truffleHog
检测代码中的敏感信息
pip install trufflehog
cryptography
加密/解密库
pip install cryptography
pyjwt
JWT安全实现
pip install pyjwt

总结

Python安全编程的核心原则:

  • 零信任原则:不信任任何输入,验证所有数据

  • 最小权限原则:只授予必要的最小权限

  • 纵深防御:多层安全防护,避免单点失效

  • 安全默认值:默认配置应该是安全的

  • 持续监控:安全不是一次性的,需要持续关注

关键行动点

  • 在项目初期就考虑安全设计

  • 使用安全框架和库,而不是自己实现

  • 定期进行安全代码审查

  • 保持依赖包更新

  • 实施自动化安全测试

明天我们将探讨常见漏洞防范,深入了解如何识别和防护特定类型的攻击。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-08 20:16:29 HTTP/2.0 GET : https://f.mffb.com.cn/a/461169.html
  2. 运行时间 : 0.116778s [ 吞吐率:8.56req/s ] 内存消耗:4,609.48kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=aaf34c2e155ce4ba56e23dfb13ab131d
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000609s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001661s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000675s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000626s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001349s ]
  6. SELECT * FROM `set` [ RunTime:0.000559s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001475s ]
  8. SELECT * FROM `article` WHERE `id` = 461169 LIMIT 1 [ RunTime:0.001094s ]
  9. UPDATE `article` SET `lasttime` = 1770552989 WHERE `id` = 461169 [ RunTime:0.015406s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000597s ]
  11. SELECT * FROM `article` WHERE `id` < 461169 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001083s ]
  12. SELECT * FROM `article` WHERE `id` > 461169 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001219s ]
  13. SELECT * FROM `article` WHERE `id` < 461169 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001445s ]
  14. SELECT * FROM `article` WHERE `id` < 461169 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.001506s ]
  15. SELECT * FROM `article` WHERE `id` < 461169 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.002057s ]
0.120531s