diff options
Diffstat (limited to 'internal/slackware_com/changelog_test.go')
-rw-r--r-- | internal/slackware_com/changelog_test.go | 228 |
1 files changed, 228 insertions, 0 deletions
diff --git a/internal/slackware_com/changelog_test.go b/internal/slackware_com/changelog_test.go new file mode 100644 index 0000000..308c419 --- /dev/null +++ b/internal/slackware_com/changelog_test.go @@ -0,0 +1,228 @@ +package slackware_com + +import ( + "strings" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestPackageEntryUnmarshalText(t *testing.T) { + tests := []struct { + Text string + Exp EntryItem + }{ + { + Text: strings.TrimSpace(` +patches/packages/libX11-1.8.7-x86_64-1_slack15.0.txz: Upgraded. + This update fixes security issues: + libX11: out-of-bounds memory access in _XkbReadKeySyms(). + libX11: stack exhaustion from infinite recursion in PutSubImage(). + libX11: integer overflow in XCreateImage() leading to a heap overflow. + For more information, see: + https://lists.x.org/archives/xorg-announce/2023-October/003424.html + https://www.cve.org/CVERecord?id=CVE-2023-43785 + https://www.cve.org/CVERecord?id=CVE-2023-43786 + https://www.cve.org/CVERecord?id=CVE-2023-43787 + (* Security fix *)`), + Exp: &PathUpgraded{ + Path: "patches/packages/libX11-1.8.7-x86_64-1_slack15.0.txz", + Description: strings.TrimSpace(` +This update fixes security issues: +libX11: out-of-bounds memory access in _XkbReadKeySyms(). +libX11: stack exhaustion from infinite recursion in PutSubImage(). +libX11: integer overflow in XCreateImage() leading to a heap overflow. +For more information, see: + https://lists.x.org/archives/xorg-announce/2023-October/003424.html + https://www.cve.org/CVERecord?id=CVE-2023-43785 + https://www.cve.org/CVERecord?id=CVE-2023-43786 + https://www.cve.org/CVERecord?id=CVE-2023-43787 +(* Security fix *)`), + }, + }, + { + Text: strings.TrimSpace(` +#################################################################### +# NOTICE OF INPENDING EOL (END OF LIFE) FOR OLD SLACKWARE VERSIONS # +# # +# Effective July 5, 2018, security patches will no longer be # +# provided for the following versions of Slackware (which will all # +# be more than 7 years old at that time): # +# Slackware 13.0, Slackware 13.1, Slackware 13.37. # +# If you are still running these versions you should consider # +# migrating to a newer version (preferably as recent as possible). # +# Alternately, you may make arrangements to handle your own # +# security patches. # +####################################################################`), + Exp: EndOfLifeNotice(strings.TrimSpace(` +#################################################################### +# NOTICE OF INPENDING EOL (END OF LIFE) FOR OLD SLACKWARE VERSIONS # +# # +# Effective July 5, 2018, security patches will no longer be # +# provided for the following versions of Slackware (which will all # +# be more than 7 years old at that time): # +# Slackware 13.0, Slackware 13.1, Slackware 13.37. # +# If you are still running these versions you should consider # +# migrating to a newer version (preferably as recent as possible). # +# Alternately, you may make arrangements to handle your own # +# security patches. # +####################################################################`), + ), + }, + { + Text: strings.TrimSpace(` +kde/stellarsolver-2.5-x86_64-1.txz: Added. + This is required by kstars-3.6.7.`), + Exp: &PathAdded{ + Path: "kde/stellarsolver-2.5-x86_64-1.txz", + Description: "This is required by kstars-3.6.7.", + }, + }, + { + Text: `l/at-spi2-atk-2.38.0-x86_64-3.txz: Removed.`, + Exp: &PathRemoved{ + Path: "l/at-spi2-atk-2.38.0-x86_64-3.txz", + }, + }, + { + Text: `isolinux/initrd.img: Rebuilt.`, + Exp: &PathRebuild{ + Path: "isolinux/initrd.img", + }, + }, + { + Text: `kernels/*: Upgraded.`, + Exp: &PathUpgraded{ + Path: "kernels/*", + }, + }, + } + + for _, test := range tests { + entry := ParseChangeLogEntry(test.Text) + assert.Equal(t, test.Exp, entry) + } +} + +func MustTime(str string) time.Time { + ret, err := time.Parse(time.UnixDate, str) + if err != nil { + panic(err) + } + return ret +} + +func TestDayEntryUnmarshalText(t *testing.T) { + tests := []struct { + Text []byte + Exp Entry + }{ + { + Text: []byte(strings.TrimSpace(` +Fri Feb 18 05:29:00 UTC 2022 +a/btrfs-progs-5.16.2-x86_64-1.txz: Upgraded. +a/kernel-generic-5.16.10-x86_64-1.txz: Upgraded. +k/kernel-source-5.16.10-noarch-1.txz: Upgraded. + AMD_PTDMA n -> m + Thanks to walecha. +n/php-7.4.28-x86_64-1.txz: Upgraded. + This update fixes bugs and a security issue: + UAF due to php_filter_float() failing for ints. + For more information, see: + https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-21708 + (* Security fix *) +x/libdrm-2.4.110-x86_64-1.txz: Upgraded. +`)), + Exp: Entry{ + Time: MustTime("Fri Feb 18 05:29:00 UTC 2022"), + Items: []EntryItem{ + &PathUpgraded{Path: "a/btrfs-progs-5.16.2-x86_64-1.txz"}, + &PathUpgraded{Path: "a/kernel-generic-5.16.10-x86_64-1.txz"}, + &PathUpgraded{ + Path: "k/kernel-source-5.16.10-noarch-1.txz", + Description: strings.TrimSpace(` +AMD_PTDMA n -> m +Thanks to walecha.`, + ), + }, + &PathUpgraded{ + Path: "n/php-7.4.28-x86_64-1.txz", + Description: strings.TrimSpace(` +This update fixes bugs and a security issue: +UAF due to php_filter_float() failing for ints. +For more information, see: + https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-21708 +(* Security fix *)`, + ), + }, + &PathUpgraded{ + Path: "x/libdrm-2.4.110-x86_64-1.txz", + }, + }, + }, + }, + { + Text: []byte(strings.TrimSpace(` +Fri Apr 6 20:47:43 UTC 2018 +#################################################################### +# NOTICE OF INPENDING EOL (END OF LIFE) FOR OLD SLACKWARE VERSIONS # +# # +# Effective July 5, 2018, security patches will no longer be # +# provided for the following versions of Slackware (which will all # +# be more than 7 years old at that time): # +# Slackware 13.0, Slackware 13.1, Slackware 13.37. # +# If you are still running these versions you should consider # +# migrating to a newer version (preferably as recent as possible). # +# Alternately, you may make arrangements to handle your own # +# security patches. # +#################################################################### +patches/packages/patch-2.7.4-i486-2_slack13.37.txz: Rebuilt. + Fix arbitrary shell execution possible with obsolete ed format patches. + For more information, see: + https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-1000156 + (* Security fix *)`)), + Exp: Entry{ + Time: MustTime("Fri Apr 6 20:47:43 UTC 2018"), + Items: []EntryItem{EndOfLifeNotice(strings.TrimSpace(` +#################################################################### +# NOTICE OF INPENDING EOL (END OF LIFE) FOR OLD SLACKWARE VERSIONS # +# # +# Effective July 5, 2018, security patches will no longer be # +# provided for the following versions of Slackware (which will all # +# be more than 7 years old at that time): # +# Slackware 13.0, Slackware 13.1, Slackware 13.37. # +# If you are still running these versions you should consider # +# migrating to a newer version (preferably as recent as possible). # +# Alternately, you may make arrangements to handle your own # +# security patches. # +####################################################################`)), + &PathRebuild{ + Path: "patches/packages/patch-2.7.4-i486-2_slack13.37.txz", + Description: strings.TrimSpace(` +Fix arbitrary shell execution possible with obsolete ed format patches. +For more information, see: + https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-1000156 +(* Security fix *)`), + }, + }, + }, + }, + } + + for _, test := range tests { + var entry Entry + err := entry.UnmarshalText(test.Text) + require.NoError(t, err) + assert.Equal(t, test.Exp, entry) + } +} + +func TestOpenChangelog(t *testing.T) { + changelog, err := OpenChangeLog("testdata/ChangeLog.txt") + require.NoError(t, err) + + //require.Len(t, changelog.Day, 20) + _ = changelog +} |