 01. 邓良驹 编写更安全的Python代码 "__main__": payload = "!!python/object/apply:__main__.ShellExp ['/bin/sh']" yaml.load(payload) 小心 服务端模板注入(SSTI) from flask import Flask from flask request, render_template_string app = Flask(__name__) @app person=person) if __name__ == "__main__": app.run(debug=True 应对: 不要使用%s,而应在模板中直接使用{{var}}。 小心 注入攻击 query = “SELECT * FROM accounts WHERE uid = ‘” + request.args.get(“uid”) + ”’” resuts = mysql.execute(query) uid = '' or '1'='1' 应对: 对外部输入进行完善的检查、过滤、转义操作后,再进行执行。 参考资料:“驹说码事”《注入的原理与防御措施》 https://mp.weixin.qq.com/s/Zd81qlcWJi4H1AD9WzPX7w 小心 PyPI 依赖包 不要以为 Star 多的包就不存在漏洞; 更不要以为 PyPI 源中的包就不存在恶意代码; 不要以为你import的就是你实际要import的*;0 码力 | 18 页 | 988.40 KB | 1 年前3 01. 邓良驹 编写更安全的Python代码 "__main__": payload = "!!python/object/apply:__main__.ShellExp ['/bin/sh']" yaml.load(payload) 小心 服务端模板注入(SSTI) from flask import Flask from flask request, render_template_string app = Flask(__name__) @app person=person) if __name__ == "__main__": app.run(debug=True 应对: 不要使用%s,而应在模板中直接使用{{var}}。 小心 注入攻击 query = “SELECT * FROM accounts WHERE uid = ‘” + request.args.get(“uid”) + ”’” resuts = mysql.execute(query) uid = '' or '1'='1' 应对: 对外部输入进行完善的检查、过滤、转义操作后,再进行执行。 参考资料:“驹说码事”《注入的原理与防御措施》 https://mp.weixin.qq.com/s/Zd81qlcWJi4H1AD9WzPX7w 小心 PyPI 依赖包 不要以为 Star 多的包就不存在漏洞; 更不要以为 PyPI 源中的包就不存在恶意代码; 不要以为你import的就是你实际要import的*;0 码力 | 18 页 | 988.40 KB | 1 年前3
 Flask入门教程保持全局环境的干净 指定不同的依赖版本 方便记录和管理依赖 我们将使用 Pipenv 来创建和管理虚拟环境、以及在虚拟环境中安装和卸载依赖 包。它集成了 pip 和 virtualenv,可以替代这两个工具的惯常用法。另外,它还集 成了 Pipfile,它是新的依赖记录标准,使用 Pipfile 文件记录项目依赖,使用 Pipfile.lock 文件记录固定版本的依赖列表。这两个文件替代了手动通过 通过 requirements.txt 文件记录依赖的方式。 我们首先使用 pip 安装 Pipenv,Windows 系统使用下面的命令: $ pip install pipenv Linux 和 macOS 使用下面的命令: $ sudo -H pip install pipenv 使用 Pipenv 创建虚拟环境非常简单,使用 pipenv install 命令即可为当前项 为当前目录创建一个 Python 解释器环境,按照 pip、setuptool、virtualenv 等 工具库。 如果当前目录有 Pipfile 文件或 requirements.txt 文件,那么从中读取依赖列表 并安装。 如果没有发现 Pipfile 文件,就自动创建。 创建虚拟环境后,我们可以使用 pipenv shell 命令来激活虚拟环境,如下所示 (执行 exit 可以退出虚拟环境):0 码力 | 127 页 | 7.62 MB | 1 年前3 Flask入门教程保持全局环境的干净 指定不同的依赖版本 方便记录和管理依赖 我们将使用 Pipenv 来创建和管理虚拟环境、以及在虚拟环境中安装和卸载依赖 包。它集成了 pip 和 virtualenv,可以替代这两个工具的惯常用法。另外,它还集 成了 Pipfile,它是新的依赖记录标准,使用 Pipfile 文件记录项目依赖,使用 Pipfile.lock 文件记录固定版本的依赖列表。这两个文件替代了手动通过 通过 requirements.txt 文件记录依赖的方式。 我们首先使用 pip 安装 Pipenv,Windows 系统使用下面的命令: $ pip install pipenv Linux 和 macOS 使用下面的命令: $ sudo -H pip install pipenv 使用 Pipenv 创建虚拟环境非常简单,使用 pipenv install 命令即可为当前项 为当前目录创建一个 Python 解释器环境,按照 pip、setuptool、virtualenv 等 工具库。 如果当前目录有 Pipfile 文件或 requirements.txt 文件,那么从中读取依赖列表 并安装。 如果没有发现 Pipfile 文件,就自动创建。 创建虚拟环境后,我们可以使用 pipenv shell 命令来激活虚拟环境,如下所示 (执行 exit 可以退出虚拟环境):0 码力 | 127 页 | 7.62 MB | 1 年前3
 PyWebIO v1.4.0 使用手册Documentation PyWebIO, 发布 1.4.0 onchange 回调函数接收一个参数——输入项改变后的值。onchange 的典型用途 是配合input_update() 来在一个表单中实现相互依赖的输入。 • placeholder (str) –输入框的提示内容。提示内容会在输入框未输入值时以浅色 字体显示在输入框中 • required (bool) –当前输入是否为必填项,默认为 回调的输入 项 • spec –需要更新的输入项参数。注意一下参数无法被更新:type, name, validate, action, code, onchange, multiple 一个具有依赖关系的输入项的示例: country2city = { 'China': ['Beijing', 'Shanghai', 'Hong Kong'], 'USA': ['New York', 'Los FastAPI/Starlette support 当使用 FastAPI/Starlette 作为 PyWebIO 的后端 server 时,你需要手动安装 fastapi 或 starlette ,另外还 需要安装一些其他的依赖库,可以使用以下命令安装: pip3 install -U fastapi starlette uvicorn aiofiles websockets pywebio.platform.fastapi0 码力 | 115 页 | 1.70 MB | 1 年前3 PyWebIO v1.4.0 使用手册Documentation PyWebIO, 发布 1.4.0 onchange 回调函数接收一个参数——输入项改变后的值。onchange 的典型用途 是配合input_update() 来在一个表单中实现相互依赖的输入。 • placeholder (str) –输入框的提示内容。提示内容会在输入框未输入值时以浅色 字体显示在输入框中 • required (bool) –当前输入是否为必填项,默认为 回调的输入 项 • spec –需要更新的输入项参数。注意一下参数无法被更新:type, name, validate, action, code, onchange, multiple 一个具有依赖关系的输入项的示例: country2city = { 'China': ['Beijing', 'Shanghai', 'Hong Kong'], 'USA': ['New York', 'Los FastAPI/Starlette support 当使用 FastAPI/Starlette 作为 PyWebIO 的后端 server 时,你需要手动安装 fastapi 或 starlette ,另外还 需要安装一些其他的依赖库,可以使用以下命令安装: pip3 install -U fastapi starlette uvicorn aiofiles websockets pywebio.platform.fastapi0 码力 | 115 页 | 1.70 MB | 1 年前3
 PyWebIO v1.5.2 使用手册(callable) –当输入项的值发生变化时的回调函数。 onchange 回调函数接收一个参数——输入项改变后的值。onchange 的典型用途 是配合input_update() 来在一个表单中实现相互依赖的输入。 • placeholder (str) –输入框的提示内容。提示内容会在输入框未输入值时以浅色 字体显示在输入框中 • required (bool) –当前输入是否为必填项,默认为 回调的输入 项 • spec –需要更新的输入项参数。注意一下参数无法被更新:type, name, validate, action, code, onchange, multiple 一个具有依赖关系的输入项的示例: country2city = { 'China': ['Beijing', 'Shanghai', 'Hong Kong'], 'USA': ['New York', 'Los FastAPI/Starlette support 当使用 FastAPI/Starlette 作为 PyWebIO 的后端 server 时,你需要手动安装 fastapi 或 starlette ,另外还 需要安装一些其他的依赖库,可以使用以下命令安装: pip3 install -U fastapi starlette uvicorn aiofiles websockets pywebio.platform.fastapi0 码力 | 125 页 | 1.72 MB | 1 年前3 PyWebIO v1.5.2 使用手册(callable) –当输入项的值发生变化时的回调函数。 onchange 回调函数接收一个参数——输入项改变后的值。onchange 的典型用途 是配合input_update() 来在一个表单中实现相互依赖的输入。 • placeholder (str) –输入框的提示内容。提示内容会在输入框未输入值时以浅色 字体显示在输入框中 • required (bool) –当前输入是否为必填项,默认为 回调的输入 项 • spec –需要更新的输入项参数。注意一下参数无法被更新:type, name, validate, action, code, onchange, multiple 一个具有依赖关系的输入项的示例: country2city = { 'China': ['Beijing', 'Shanghai', 'Hong Kong'], 'USA': ['New York', 'Los FastAPI/Starlette support 当使用 FastAPI/Starlette 作为 PyWebIO 的后端 server 时,你需要手动安装 fastapi 或 starlette ,另外还 需要安装一些其他的依赖库,可以使用以下命令安装: pip3 install -U fastapi starlette uvicorn aiofiles websockets pywebio.platform.fastapi0 码力 | 125 页 | 1.72 MB | 1 年前3
 PyWebIO v1.6.0 使用手册value of this input field. onchange 回调函数接收一个参数——输入项改变后的值。onchange 的典型用途 是配合input_update() 来在一个表单中实现相互依赖的输入。 • placeholder (str) –输入框的提示内容。提示内容会在输入框未输入值时以浅色 字体显示在输入框中 • required (bool) –当前输入是否为必填项,默认为 回调的输入 项 • spec –需要更新的输入项参数。注意一下参数无法被更新:type, name, validate, action, code, onchange, multiple 一个具有依赖关系的输入项的示例: country2city = { 'China': ['Beijing', 'Shanghai', 'Hong Kong'], 'USA': ['New York', 'Los FastAPI/Starlette support 当使用 FastAPI/Starlette 作为 PyWebIO 的后端 server 时,你需要手动安装 fastapi 或 starlette ,另外还 需要安装一些其他的依赖库,可以使用以下命令安装: pip3 install -U fastapi starlette uvicorn aiofiles websockets pywebio.platform.fastapi0 码力 | 123 页 | 1.72 MB | 1 年前3 PyWebIO v1.6.0 使用手册value of this input field. onchange 回调函数接收一个参数——输入项改变后的值。onchange 的典型用途 是配合input_update() 来在一个表单中实现相互依赖的输入。 • placeholder (str) –输入框的提示内容。提示内容会在输入框未输入值时以浅色 字体显示在输入框中 • required (bool) –当前输入是否为必填项,默认为 回调的输入 项 • spec –需要更新的输入项参数。注意一下参数无法被更新:type, name, validate, action, code, onchange, multiple 一个具有依赖关系的输入项的示例: country2city = { 'China': ['Beijing', 'Shanghai', 'Hong Kong'], 'USA': ['New York', 'Los FastAPI/Starlette support 当使用 FastAPI/Starlette 作为 PyWebIO 的后端 server 时,你需要手动安装 fastapi 或 starlette ,另外还 需要安装一些其他的依赖库,可以使用以下命令安装: pip3 install -U fastapi starlette uvicorn aiofiles websockets pywebio.platform.fastapi0 码力 | 123 页 | 1.72 MB | 1 年前3
 PyWebIO v1.4.0 使用手册(callable) – 当输入项的值发生变化时的回调函数。 onchange 回调函数接收一个参数——输入项改变后的 值。 onchange 的典型用途是配合 input_update() 来在 一个表单中实现相互依赖的输入。 placeholder (str) – 输入框的提示内容。提示内容会在输 入框未输入值时以浅色字体显示在输入框中 required (bool) – 当前输入是否为必填项,默认为 False 回调的输入项 spec – 需要更新的输入项参数。注意一下参数无法被更 新:type, name, validate, action, code, onchange, multiple 一个具有依赖关系的输入项的示例: data = input_group("Basic info",[ input('Input your name', name='name'), input('Repeat FastAPI/Starlette support 当使用FastAPI/Starlette作为PyWebIO的后端server时,你需要手动安装 fastapi 或 starlette ,另外还需要安装一些其他的依赖库,可以使用以下命令安装: pip3 install -U fastapi starlette uvicorn aiofiles websockets pywebio.platform.fastapi0 码力 | 135 页 | 7.45 MB | 1 年前3 PyWebIO v1.4.0 使用手册(callable) – 当输入项的值发生变化时的回调函数。 onchange 回调函数接收一个参数——输入项改变后的 值。 onchange 的典型用途是配合 input_update() 来在 一个表单中实现相互依赖的输入。 placeholder (str) – 输入框的提示内容。提示内容会在输 入框未输入值时以浅色字体显示在输入框中 required (bool) – 当前输入是否为必填项,默认为 False 回调的输入项 spec – 需要更新的输入项参数。注意一下参数无法被更 新:type, name, validate, action, code, onchange, multiple 一个具有依赖关系的输入项的示例: data = input_group("Basic info",[ input('Input your name', name='name'), input('Repeat FastAPI/Starlette support 当使用FastAPI/Starlette作为PyWebIO的后端server时,你需要手动安装 fastapi 或 starlette ,另外还需要安装一些其他的依赖库,可以使用以下命令安装: pip3 install -U fastapi starlette uvicorn aiofiles websockets pywebio.platform.fastapi0 码力 | 135 页 | 7.45 MB | 1 年前3
 PyWebIO v1.5.0 使用手册(callable) –当输入项的值发生变化时的回调函数。 onchange 回调函数接收一个参数——输入项改变后的值。onchange 的典型用途 是配合input_update() 来在一个表单中实现相互依赖的输入。 • placeholder (str) –输入框的提示内容。提示内容会在输入框未输入值时以浅色 字体显示在输入框中 • required (bool) –当前输入是否为必填项,默认为 回调的输入 项 • spec –需要更新的输入项参数。注意一下参数无法被更新:type, name, validate, action, code, onchange, multiple 一个具有依赖关系的输入项的示例: country2city = { 'China': ['Beijing', 'Shanghai', 'Hong Kong'], 'USA': ['New York', 'Los FastAPI/Starlette support 当使用 FastAPI/Starlette 作为 PyWebIO 的后端 server 时,你需要手动安装 fastapi 或 starlette ,另外还 需要安装一些其他的依赖库,可以使用以下命令安装: pip3 install -U fastapi starlette uvicorn aiofiles websockets pywebio.platform.fastapi0 码力 | 125 页 | 1.72 MB | 1 年前3 PyWebIO v1.5.0 使用手册(callable) –当输入项的值发生变化时的回调函数。 onchange 回调函数接收一个参数——输入项改变后的值。onchange 的典型用途 是配合input_update() 来在一个表单中实现相互依赖的输入。 • placeholder (str) –输入框的提示内容。提示内容会在输入框未输入值时以浅色 字体显示在输入框中 • required (bool) –当前输入是否为必填项,默认为 回调的输入 项 • spec –需要更新的输入项参数。注意一下参数无法被更新:type, name, validate, action, code, onchange, multiple 一个具有依赖关系的输入项的示例: country2city = { 'China': ['Beijing', 'Shanghai', 'Hong Kong'], 'USA': ['New York', 'Los FastAPI/Starlette support 当使用 FastAPI/Starlette 作为 PyWebIO 的后端 server 时,你需要手动安装 fastapi 或 starlette ,另外还 需要安装一些其他的依赖库,可以使用以下命令安装: pip3 install -U fastapi starlette uvicorn aiofiles websockets pywebio.platform.fastapi0 码力 | 125 页 | 1.72 MB | 1 年前3
 PyWebIO v1.6.3 使用手册value of this input field. onchange 回调函数接收一个参数——输入项改变后的值。onchange 的典型用途 是配合input_update() 来在一个表单中实现相互依赖的输入。 • placeholder (str) –输入框的提示内容。提示内容会在输入框未输入值时以浅色 字体显示在输入框中 • required (bool) –当前输入是否为必填项,默认为 回调的输入 项 • spec –需要更新的输入项参数。注意一下参数无法被更新:type, name, validate, action, code, onchange, multiple 一个具有依赖关系的输入项的示例: country2city = { 'China': ['Beijing', 'Shanghai', 'Hong Kong'], 'USA': ['New York', 'Los FastAPI/Starlette support 当使用 FastAPI/Starlette 作为 PyWebIO 的后端 server 时,你需要手动安装 fastapi 或 starlette ,另外还 需要安装一些其他的依赖库,可以使用以下命令安装: pip3 install -U fastapi starlette uvicorn aiofiles websockets pywebio.platform.fastapi0 码力 | 123 页 | 1.72 MB | 1 年前3 PyWebIO v1.6.3 使用手册value of this input field. onchange 回调函数接收一个参数——输入项改变后的值。onchange 的典型用途 是配合input_update() 来在一个表单中实现相互依赖的输入。 • placeholder (str) –输入框的提示内容。提示内容会在输入框未输入值时以浅色 字体显示在输入框中 • required (bool) –当前输入是否为必填项,默认为 回调的输入 项 • spec –需要更新的输入项参数。注意一下参数无法被更新:type, name, validate, action, code, onchange, multiple 一个具有依赖关系的输入项的示例: country2city = { 'China': ['Beijing', 'Shanghai', 'Hong Kong'], 'USA': ['New York', 'Los FastAPI/Starlette support 当使用 FastAPI/Starlette 作为 PyWebIO 的后端 server 时,你需要手动安装 fastapi 或 starlette ,另外还 需要安装一些其他的依赖库,可以使用以下命令安装: pip3 install -U fastapi starlette uvicorn aiofiles websockets pywebio.platform.fastapi0 码力 | 123 页 | 1.72 MB | 1 年前3
 PyWebIO v1.7.1 使用手册value of this input field. onchange 回调函数接收一个参数——输入项改变后的值。onchange 的典型用途 是配合input_update() 来在一个表单中实现相互依赖的输入。 • placeholder (str) –输入框的提示内容。提示内容会在输入框未输入值时以浅色 字体显示在输入框中 • required (bool) –当前输入是否为必填项,默认为 回调的输入 项 • spec –需要更新的输入项参数。注意一下参数无法被更新:type, name, validate, action, code, onchange, multiple 一个具有依赖关系的输入项的示例: country2city = { 'China': ['Beijing', 'Shanghai', 'Hong Kong'], 'USA': ['New York', 'Los FastAPI/Starlette support 当使用 FastAPI/Starlette 作为 PyWebIO 的后端 server 时,你需要手动安装 fastapi 或 starlette ,另外还 需要安装一些其他的依赖库,可以使用以下命令安装: pip3 install -U fastapi starlette uvicorn aiofiles websockets pywebio.platform.fastapi0 码力 | 127 页 | 1.73 MB | 1 年前3 PyWebIO v1.7.1 使用手册value of this input field. onchange 回调函数接收一个参数——输入项改变后的值。onchange 的典型用途 是配合input_update() 来在一个表单中实现相互依赖的输入。 • placeholder (str) –输入框的提示内容。提示内容会在输入框未输入值时以浅色 字体显示在输入框中 • required (bool) –当前输入是否为必填项,默认为 回调的输入 项 • spec –需要更新的输入项参数。注意一下参数无法被更新:type, name, validate, action, code, onchange, multiple 一个具有依赖关系的输入项的示例: country2city = { 'China': ['Beijing', 'Shanghai', 'Hong Kong'], 'USA': ['New York', 'Los FastAPI/Starlette support 当使用 FastAPI/Starlette 作为 PyWebIO 的后端 server 时,你需要手动安装 fastapi 或 starlette ,另外还 需要安装一些其他的依赖库,可以使用以下命令安装: pip3 install -U fastapi starlette uvicorn aiofiles websockets pywebio.platform.fastapi0 码力 | 127 页 | 1.73 MB | 1 年前3
 PyWebIO v1.5.1 使用手册(callable) –当输入项的值发生变化时的回调函数。 onchange 回调函数接收一个参数——输入项改变后的值。onchange 的典型用途 是配合input_update() 来在一个表单中实现相互依赖的输入。 • placeholder (str) –输入框的提示内容。提示内容会在输入框未输入值时以浅色 字体显示在输入框中 • required (bool) –当前输入是否为必填项,默认为 回调的输入 项 • spec –需要更新的输入项参数。注意一下参数无法被更新:type, name, validate, action, code, onchange, multiple 一个具有依赖关系的输入项的示例: country2city = { 'China': ['Beijing', 'Shanghai', 'Hong Kong'], 'USA': ['New York', 'Los FastAPI/Starlette support 当使用 FastAPI/Starlette 作为 PyWebIO 的后端 server 时,你需要手动安装 fastapi 或 starlette ,另外还 需要安装一些其他的依赖库,可以使用以下命令安装: pip3 install -U fastapi starlette uvicorn aiofiles websockets pywebio.platform.fastapi0 码力 | 125 页 | 1.72 MB | 1 年前3 PyWebIO v1.5.1 使用手册(callable) –当输入项的值发生变化时的回调函数。 onchange 回调函数接收一个参数——输入项改变后的值。onchange 的典型用途 是配合input_update() 来在一个表单中实现相互依赖的输入。 • placeholder (str) –输入框的提示内容。提示内容会在输入框未输入值时以浅色 字体显示在输入框中 • required (bool) –当前输入是否为必填项,默认为 回调的输入 项 • spec –需要更新的输入项参数。注意一下参数无法被更新:type, name, validate, action, code, onchange, multiple 一个具有依赖关系的输入项的示例: country2city = { 'China': ['Beijing', 'Shanghai', 'Hong Kong'], 'USA': ['New York', 'Los FastAPI/Starlette support 当使用 FastAPI/Starlette 作为 PyWebIO 的后端 server 时,你需要手动安装 fastapi 或 starlette ,另外还 需要安装一些其他的依赖库,可以使用以下命令安装: pip3 install -U fastapi starlette uvicorn aiofiles websockets pywebio.platform.fastapi0 码力 | 125 页 | 1.72 MB | 1 年前3
共 109 条
- 1
- 2
- 3
- 4
- 5
- 6
- 11














 
 