Satisfies ignores a LicenseRef alternative of an OR
@elrayle đang làm issue này rồi.
Từ ngày 5/10/2026.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
Hướng nghiên cứu
The bug is in the Satisfies function's handling of LicenseRef within OR and AND expressions. Start by examining the spdxexp package, particularly the Satisfies function and its helpers for evaluating expressions. The provided test cases in the issue body show the exact failure; run them to confirm. Look at how license identifiers are matched, focusing on the logic for OR and AND nodes when a LicenseRef is involved. The fix likely involves adjusting the comparison or normalization step for LicenseRef values.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
A LicenseRef that is an alternative of an OR does not count towards Satisfies: MIT OR LicenseRef-x is not satisfied by an allowed list of just LicenseRef-x, and MIT AND (LicenseRef-a OR LicenseRef-b) is satisfied by MIT alone, although neither reference is allowed. The same two shapes with list identifiers in place of the references give the expected answers:
package main
import (
"fmt"
"github.com/github/go-spdx/v2/spdxexp"
)
func main() {
cases := []struct {
expr string
allowed []string
}{
{"MIT OR LicenseRef-x", []string{"LicenseRef-x"}},
{"MIT OR ISC", []string{"ISC"}},
{"MIT AND (LicenseRef-a OR LicenseRef-b)", []string{"MIT"}},
{"MIT AND (ISC OR BSD-3-Clause)", []string{"MIT"}},
}
for _, c := range cases {
ok, err := spdxexp.Satisfies(c.expr, c.allowed)
fmt.Printf("Satisfies(%q, %q) = %v, %v\n", c.expr, c.allowed, ok, err)
}
}
Output:
Satisfies("MIT OR LicenseRef-x", ["LicenseRef-x"]) = false, <nil>
Satisfies("MIT OR ISC", ["ISC"]) = true, <nil>
Satisfies("MIT AND (LicenseRef-a OR LicenseRef-b)", ["MIT"]) = true, <nil>
Satisfies("MIT AND (ISC OR BSD-3-Clause)", ["MIT"]) = false, <nil>
I expected the first call to return true, like the second, and the third to return false, like the fourth. Putting the reference first (LicenseRef-x OR MIT) gives the same false, and the third result means an expression that requires a license absent from the allowed list passes the check.
Tested on v2.7.0 and on current main (48a80b3).
BTW, this was found by an automated program that writes property-based tests for various open source projects using hegel (but it has been reviewed by hand before reporting). We've also potentially found (but not yet hand validated) 15 other bugs in go-spdx. You can see the tests at https://github.com/hegeldev/hegel-zoo/tree/main/targets/go/go-spdx. Let us know if you would like us to file the other bugs found and/or contribute the tests. NB the tests are currently LLM generated and probably not yet suitable for inclusion as is, but we're happy to help get them into a better state if you want them.
- Ngôn ngữ chính
- Go
- Star
- 55
- Fork
- 18
- Merge trung bình
- 5 giờ 55 phút
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của github/go-spdx
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
-
fix noisy update license PRCó thể đã có người làm @elrayle đã nhận 277 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 38/100
-
Update processing to comply with SPDX spec 3.xCó thể làm lại được @deo002 đã nhận 167 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
maintenance
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 45/100
-
documentation
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Tất cả issue của github/go-spdx
Issue tương tự
-
agent-butler-finding chore
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
jordansmall/spindrift#5575 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
JakeChampion/lang#12684 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
goose sub-agent runs are never indexed: blame finds no session for any file a `delegate` child wroteĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
C-bug O-community X-blathers-triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
cockroachdb/cockroach#176150 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 12 ngày
-
triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
wakatime/wakatime-cli#1649 ·
Maintainer thường phản hồi trong vòng 1 ngày