Four silent bugs: IsRequiredPhrase.license_expression returns None, find_in_path ignores later PATH changes, duplicate dict keys override license mappings
维护者通常 2 天内回复
评估
调研方向
从 src/licensedcode/required_phrases.py 第 205 行附近的第 1 项开始,其中 license_expression 属性计算了 self.rule.license_expression 却没有返回它,然后检查该类中其他属性如何读取它们的值。第 2 项位于 src/commoncode/command.py 第 319 行附近,其中 find_in_path 在导入时计算 searchable_paths()。运行一个小脚本,在导入后修改 PATH 来复现问题。第 3 项需要维护者就 src/packagedcode/rubygems.py 和 src/packagedcode/alpine.py 中的预期值作出决定,因此除非讨论线程已经确定,否则不要改动。完成的标准是修复后的属性返回预期值,并且相关测试通过。
由索引模型根据 Issue 内容生成。
描述
Summary
A static scan of src/ found four bugs that fail silently (no exception).
Each was reproduced with a small standalone script.
1. IsRequiredPhrase.license_expression always returns None
src/licensedcode/required_phrases.py (~line 205):
@property
def license_expression(self):
self.rule.license_expression # missing `return`
Repro: IsRequiredPhrase(rule=<rule with license_expression="mit">, ...) .license_expression returns None.
Fix: return self.rule.license_expression.
2. find_in_path ignores PATH changes made after import
src/commoncode/command.py (~line 319):
def find_in_path(filename, searchable_paths=searchable_paths()):
The default is evaluated once at import time, so PATH changes made afterwards
are ignored. The parameter also shadows the searchable_paths() function.
Repro: import the module, then prepend a directory containing mytool to
os.environ["PATH"]. find_in_path("mytool") returns None, but
find_in_path("mytool", searchable_paths()) returns the path.
Fix: default to None and call searchable_paths() inside the function.
3. Duplicate dict keys with conflicting values silently override mappings
Python keeps only the last value, so the earlier entries are dead.
src/packagedcode/rubygems.py(LICENSES_MAPPING, lines 679-680):
'LGPL'maps to'lgpl'and then to'lgpl-2.0-plus'.src/packagedcode/alpine.py(DECLARED_TO_SPDX):'as-is'(lines 1619, 1701):licenseref-scancode-free-unknownvs
licenseref-scancode-unknown-license-reference'custom:tu-berlin-2.0'(lines 1690, 1715):
licenseref-scancode-unknown-license-referencevstu-berlin-2.0
The maintainers should decide which value is intended and remove the other.
4. Duplicate key in default ignores (harmless, cleanup)
src/commoncode/ignore.py lines 204-205 repeat "autogen.sh".
Environment
Found by static analysis (ruff F601, B008, B018) at commit 05a98f66.
Please verify the intended values for item 3 before changing them.
- 主要语言
- Python
- 星标
- 2.7k
- 派生
- 848
- 平均合并
- 2 天 19 小时
- 30 天内合并 PR
- 8
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
aboutcode-org/scancode-toolkit 的其他 Issue
-
scancode aborts when encountering a broken RPM archive可能已有人在做 @adeba4343-web 于 2 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 62/100
aboutcode-org/scancode-toolkit#5407 · 1 条评论 ·
维护者通常 2 天内回复
-
parse_maintainer_name_email returns empty name and wrong email when string has "@" but no angle brackets可能已有人在做 @pujitha24 于 3 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 84/100
aboutcode-org/scancode-toolkit#5402 ·
维护者通常 2 天内回复
-
bug: Unreachable JSON extension and format validation in validate_input_path可能已有人在做 @0Cymantek0 于 24 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
aboutcode-org/scancode-toolkit#5351 · 1 条评论 ·
维护者通常 2 天内回复
-
CycloneDX output: metadata.properties[].value emits JSON array instead of string可能已有人在做 @0Cymantek0 于 24 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 62/100
aboutcode-org/scancode-toolkit#5349 · 1 条评论 ·
维护者通常 2 天内回复
-
Duplicate 'COPYLEFT' entries in legal file classification names in legal.py and classify.py可能已有人在做 @Pradeepbeleri 于 51 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
aboutcode-org/scancode-toolkit#5319 · 2 条评论 ·
维护者通常 2 天内回复
查看 aboutcode-org/scancode-toolkit 的全部 Issue
相似的 Issue
-
needs-area-label
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 2 天内回复
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 84/100
Official-Space-AI/OpenPhysGraspGen#114 ·
维护者通常 2 天内回复
-
changelog investigate
难度 2/5 1-3 小时 新手友好度 62/100
ramnes/notion-sdk-py#441 ·
-
qa_bug
难度 2/5 1-3 小时 新手友好度 78/100
NVIDIA-NeMo/Gym#5644 ·
维护者通常 2 天内回复
-
BUG: catalog database credentials printed to logs at startup可能已有人在做 @cjboyle 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复