[Bug]: Overly permissive regular expression range
还没有人认领这个 Issue。
评估
调研方向
该 issue 指向 tests/integration/stackscripts/test_stackscripts.py 第 95 行;检查其中的正则表达式及其现有覆盖范围。确认字符范围只接受预期的字符,更新相关测试或表达式,并运行关联的集成测试。
由索引模型根据 Issue 内容生成。
描述
CLI Version
v5.56.2
Command
It's easy to write a regular expression range that matches a wider range of characters than you intended. /[a-zA-z]/ matches all lowercase and all uppercase letters, as you would expect, but it also matches the characters: `[ \ ] ^ _ ``.
Another common problem is failing to escape the dash character in a regular expression. An unescaped dash is interpreted as part of a range. For example, in the character class [a-zA-Z0-9%=.,-_] the last character range matches the 55 characters between , and _ (both included), which overlaps with the range [0-9] and is clearly not intended by the writer.
Output
No response
Expected Behavior
[CWE-20
Actual Behavior
Improper Neutralization of Special Elements used in a Command in Shell-quote
Exploiting CVE-2021-42740
no-obscure-range
The regex [,-.]
CWE-20.
Steps to Reproduce
POC
The following code is intended to check whether a string is a valid 6 digit hex color.
import re
def is_valid_hex_color(color):
return re.match(r'^#[0-9a-fA-f]{6}$', color) is not None
However, the A-f range is overly large and matches every uppercase character. It would parse a "color" like #XXYYZZ as valid.
The fix is to use an uppercase A-F range instead.
import re
def is_valid_hex_color(color):
return re.match(r'^#[0-9a-fA-F]{6}$', color) is not None
Recommendation
Avoid any confusion about which characters are included in the range by writing unambiguous regular expressions. Always check that character ranges match only the expected characters.
- 主要语言
- Python
- 星标
- 442
- 派生
- 159
- 平均合并
- 7 天 21 小时
- 30 天内合并 PR
- 8
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
linode/linode-cli 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
linode/linode-cli#894 ·
-
enhancement
难度 1/5 1 小时以内 新手友好度 85/100
linode/linode-cli#859 · 1 条评论 ·
-
enhancement
难度 4/5 3-5 天 新手友好度 35/100
linode/linode-cli#868 ·
-
bug
难度 3/5 1-2 天 新手友好度 45/100
linode/linode-cli#825 · 1 条评论 ·
-
enhancement
难度 4/5 3-5 天 新手友好度 35/100
linode/linode-cli#788 ·
查看 linode/linode-cli 的全部 Issue
相似的 Issue
-
agent-ready documentation needs-triage
难度 1/5 1-3 小时 新手友好度 88/100
-
documentation
难度 1/5 1 小时以内 新手友好度 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" 未关闭
难度 1/5 1 小时以内 新手友好度 92/100
-
instance instance add
难度 1/5 1 小时以内 新手友好度 72/100
searxng/searx-instances#939 · 1 条评论 ·
-
area-deployment area-integrations triage:bot-seen
难度 2/5 半天 新手友好度 86/100