public/manifest: IterateSlices and IterateContents also match other packages and slices sharing the name as a prefix
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 42/100
Hướng nghiên cứu
Read public/manifest/manifest.go and inspect how IterateSlices and IterateContents build their jsonwall queries. The issue includes a reproducer for each prefix collision; compare the returned names and paths with the expected exact matches. Done means both methods return only the requested package's slices or slice's contents, while an empty name still lists all entries, with tests passing.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
IterateSlices(pkgName, ...) and IterateContents(slice, ...) in public/manifest/manifest.go pass the name to jsonwall as a raw prefix with no boundary:
func (manifest *Manifest) IterateSlices(pkgName string, onMatch func(*Slice) error) (err error) {
return iteratePrefix(manifest, &Slice{Kind: "slice", Name: pkgName}, onMatch)
}
func (manifest *Manifest) IterateContents(slice string, onMatch func(*Content) error) (err error) {
return iteratePrefix(manifest, &Content{Kind: "content", Slice: slice}, onMatch)
}
So a package or slice whose name starts with another one is returned too:
IterateSlices("libc6", ...)also yieldslibc6-dev_headers.IterateContents("libc6_libs", ...)also yields the contents oflibc6_libs-extra.
Inside chisel these are only called with "", so the existing tests never pass a name. For a consumer of the public package (an SBOM generator or scanner asking for one package's slices), the parameter names suggest a per-package and per-slice lookup.
Reproduction
On main (0a817bd), a test in public/manifest:
const prefixManifest = `{"jsonwall":"1.0","schema":"1.0","count":6}
{"kind":"content","slice":"libc6_libs","path":"/lib/a"}
{"kind":"content","slice":"libc6_libs-extra","path":"/lib/b"}
{"kind":"package","name":"libc6","version":"v1","sha256":"h1","arch":"amd64"}
{"kind":"package","name":"libc6-dev","version":"v1","sha256":"h2","arch":"amd64"}
{"kind":"slice","name":"libc6-dev_headers"}
{"kind":"slice","name":"libc6_libs"}
`
func (s *S) TestIterateSlicesOnlyMatchesPackage(c *C) {
mfest, err := manifest.Read(strings.NewReader(prefixManifest))
c.Assert(err, IsNil)
var names []string
err = mfest.IterateSlices("libc6", func(sl *manifest.Slice) error {
names = append(names, sl.Name)
return nil
})
c.Assert(err, IsNil)
c.Assert(names, DeepEquals, []string{"libc6_libs"})
}
obtained []string{"libc6-dev_headers", "libc6_libs"}
expected []string{"libc6_libs"}
The same test for IterateContents("libc6_libs") returns both /lib/a and /lib/b.
Possible fix
IterateSlices: whenpkgName != "", iterate with the prefixpkgName + "_"(slice names are<pkg>_<slice>).IterateContents: match the slice name exactly (jsonwallIterateinstead ofIteratePrefix); an empty name still lists all contents.
Since this changes what the public API returns, I wanted to confirm the intended semantics before sending a PR. I have the change with tests ready and go test ./... passing, and I have signed the CLA.
- Ngôn ngữ chính
- Go
- Star
- 434
- Fork
- 74
- Merge trung bình
- 1 ngày 30 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không 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 canonical/chisel
-
`mode` of a generated directory is random when it has a generated childCó thể đã có người làm @Amadeus-22 đã nhận 24 ngày trước. Đang mởBug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
-
cut fails on uncompressed debCó thể đã có người làm @yuminn-k đã nhận 29 ngày trước. Đang mởBug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
`prefer` drops a path when the preferred package lists it `until: mutate`Có thể đã có người làm @18Abhinav07 đã nhận 8 ngày trước. Đang mởBug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Tất cả issue của canonical/chisel
Issue tương tự
-
mcpx scan: flag unsafe tool namesCó thể đã có người làm @zeyadbadawyy đã nhận hôm nay. Đang mởarea/scan enhancement good first issue priority/medium size/small
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
rohitgollarahalli/mcpx#45 · 1 bình luận · 1 người được giao ·
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 68/100
-
Mend: dependency security vulnerability
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Windows 主机
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Lee-xeo/Claude-Cage#1550 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
(bug) ui: spanPaint can index spans past their end (panic: index out of range)Có thể đã có người làm @MaxMiksa đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
Maintainer thường phản hồi trong vòng 1 ngày