fix: skip filling in empty fields in APK metadata (#1484)

Signed-off-by: Nils Hanke <nils.hanke@outlook.de>

Signed-off-by: Nils Hanke <nils.hanke@outlook.de>
This commit is contained in:
Nils Hanke 2023-01-20 15:03:30 +01:00 committed by GitHub
parent 285112fe29
commit 99f55f6a81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 0 deletions

View File

@ -71,6 +71,14 @@ func parseApkDB(_ source.FileResolver, env *generic.Environment, reader source.L
log.Warnf("unable to parse field data from line %q", line)
continue
}
if len(field.name) == 0 {
log.Warnf("failed to parse field name from line %q", line)
continue
}
if len(field.value) == 0 {
log.Debugf("line %q: parsed field %q appears to have an empty value, skipping", line, field.name)
continue
}
entryParsingInProgress = true

View File

@ -160,6 +160,43 @@ func TestSinglePackageDetails(t *testing.T) {
},
},
},
{
fixture: "test-fixtures/empty-deps-and-provides",
expected: pkg.ApkMetadata{
Package: "alpine-baselayout-data",
OriginPackage: "alpine-baselayout",
Version: "3.4.0-r0",
Description: "Alpine base dir structure and init scripts",
Maintainer: "Natanael Copa <ncopa@alpinelinux.org>",
License: "GPL-2.0-only",
Architecture: "x86_64",
URL: "https://git.alpinelinux.org/cgit/aports/tree/main/alpine-baselayout",
Size: 11664,
InstalledSize: 77824,
Dependencies: []string{},
Provides: []string{},
Checksum: "Q15ffjKT28lB7iSXjzpI/eDdYRCwM=",
GitCommit: "bd965a7ebf7fd8f07d7a0cc0d7375bf3e4eb9b24",
Files: []pkg.ApkFileRecord{
{Path: "/etc"},
{Path: "/etc/fstab"},
{Path: "/etc/group"},
{Path: "/etc/hostname"},
{Path: "/etc/hosts"},
{Path: "/etc/inittab"},
{Path: "/etc/modules"},
{Path: "/etc/mtab", OwnerUID: "0", OwnerGID: "0", Permissions: "0777"},
{Path: "/etc/nsswitch.conf"},
{Path: "/etc/passwd"},
{Path: "/etc/profile"},
{Path: "/etc/protocols"},
{Path: "/etc/services"},
{Path: "/etc/shadow", OwnerUID: "0", OwnerGID: "148", Permissions: "0640"},
{Path: "/etc/shells"},
{Path: "/etc/sysctl.conf"},
},
},
},
{
fixture: "test-fixtures/base",
expected: pkg.ApkMetadata{

View File

@ -0,0 +1,35 @@
P:alpine-baselayout-data
V:3.4.0-r0
A:x86_64
L:GPL-2.0-only
T:Alpine base dir structure and init scripts
o:alpine-baselayout
m:Natanael Copa <ncopa@alpinelinux.org>
U:https://git.alpinelinux.org/cgit/aports/tree/main/alpine-baselayout
D:
p:
c:bd965a7ebf7fd8f07d7a0cc0d7375bf3e4eb9b24
i:[]
t:1667573027
S:11664
I:77824
k:0
C:Q15ffjKT28lB7iSXjzpI/eDdYRCwM=
F:etc
R:fstab
R:group
R:hostname
R:hosts
R:inittab
R:modules
R:mtab
a:0:0:0777
R:nsswitch.conf
R:passwd
R:profile
R:protocols
R:services
R:shadow
a:0:148:0640
R:shells
R:sysctl.conf