BomLink accepts non-positive BOM versions and non-canonical shorthand UUIDs

未关闭 适合新手
#1,002 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
java
领域
data

调研方向

从 src/main/java/org/cyclonedx/util/BomLink.java 开始,这里的 BomLink(String) 构造函数会解析序列号和版本,isBomLink 会检查 urn:cdx 前缀。在 master 上运行 issue 中的复现步骤,确认三个 true 结果。src/main/resources/bom-1.7.schema.json 中的 schema pattern 展示了需要匹配的规则。完成的标准是:对于版本 0、负数版本以及长度不是 36 个字符的 UUID,构造函数抛出 BomLinkException,isBomLink 返回 false,并且现有测试全部通过。

由索引模型根据 Issue 内容生成。

描述

BomLink and BomLink.isBomLink accept urn:cdx: URNs with zero or negative BOM versions (/0, /-5) and non-36-character shorthand UUIDs (1-1-1-1-1), disagreeing with the urn:cdx specification and CycloneDX's bomLinkDocumentType / bomLinkElementType schema definitions. Because fields such as vulnerabilities[].affects[].ref and externalReferences[].url union bomLink with refLinkType or iri-reference/xs:anyURI, schema validation lets malformed urn:cdx: strings through and callers rely on BomLink.isBomLink to distinguish valid BOM-Links.

cat > Repro.java <<'EOF'
import org.cyclonedx.util.BomLink;

public class Repro {
    public static void main(String[] args) {
        boolean v0 = BomLink.isBomLink("urn:cdx:3e671687-395b-41f5-a30f-a58921a69b79/0");
        boolean vNeg = BomLink.isBomLink("urn:cdx:3e671687-395b-41f5-a30f-a58921a69b79/-5");
        boolean shortUuid = BomLink.isBomLink("urn:cdx:1-1-1-1-1/1");
        System.out.println("v0=" + v0 + " vNeg=" + vNeg + " shortUuid=" + shortUuid);
    }
}
EOF
curl -fsSLO https://repo1.maven.org/maven2/org/cyclonedx/cyclonedx-core-java/13.5.0/cyclonedx-core-java-13.5.0.jar
javac -cp cyclonedx-core-java-13.5.0.jar Repro.java
java -cp .:cyclonedx-core-java-13.5.0.jar Repro

Actual output:

v0=true vNeg=true shortUuid=true

Expected v0=false vNeg=false shortUuid=false (and BomLinkException from new BomLink(...)), matching the IANA urn:cdx registration referenced in BomLink's Javadoc (bom-version >= 1 and 36-character RFC 9562 UUID) and bomLinkDocumentType / bomLinkElementType (^urn:cdx:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/[1-9][0-9]*) in src/main/resources/bom-1.7.schema.json.

Verified on master (e591b11c6aaba7fa9cc859a9e9badfe3e1dd4cad, 13.6.0-SNAPSHOT) on Linux x86_64; BomLink.java is unchanged in release 13.5.0.

In src/main/java/org/cyclonedx/util/BomLink.java, BomLink(String) parses the serial number and version via UUID.fromString(...) and Integer.parseInt(parts[1]) without checking canonical 36-character UUID syntax or version >= 1.

Credit: https://ucsbplse.github.io/

主要语言
Java
星标
124
派生
97
平均合并
2 天 14 小时
30 天内合并 PR
11

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

CycloneDX/cyclonedx-core-java 的其他 Issue

查看 CycloneDX/cyclonedx-core-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。