diff --git a/updater/fetchers/debian/debian.go b/updater/fetchers/debian/debian.go index e21bd3f216..356613eb73 100644 --- a/updater/fetchers/debian/debian.go +++ b/updater/fetchers/debian/debian.go @@ -69,6 +69,7 @@ func (fetcher *DebianFetcher) FetchUpdate(datastore database.Datastore) (resp up log.Errorf("could not download Debian's update: %s", err) return resp, cerrors.ErrCouldNotDownload } + defer r.Body.Close() // Get the SHA-1 of the latest update's JSON data latestHash, err := datastore.GetKeyValue(updaterFlag) diff --git a/updater/fetchers/debian/debian_test.go b/updater/fetchers/debian/debian_test.go index 42e81d3c3f..0719ccdc39 100644 --- a/updater/fetchers/debian/debian_test.go +++ b/updater/fetchers/debian/debian_test.go @@ -30,6 +30,7 @@ func TestDebianParser(t *testing.T) { // Test parsing testdata/fetcher_debian_test.json testFile, _ := os.Open(path.Join(path.Dir(filename)) + "/testdata/fetcher_debian_test.json") + defer testFile.Close() response, err := buildResponse(testFile, "") if assert.Nil(t, err) && assert.Len(t, response.Vulnerabilities, 3) { for _, vulnerability := range response.Vulnerabilities { diff --git a/updater/fetchers/rhel/rhel.go b/updater/fetchers/rhel/rhel.go index de4072d12a..895bb0bc18 100644 --- a/updater/fetchers/rhel/rhel.go +++ b/updater/fetchers/rhel/rhel.go @@ -107,6 +107,7 @@ func (f *RHELFetcher) FetchUpdate(datastore database.Datastore) (resp updater.Fe log.Errorf("could not download RHEL's update list: %s", err) return resp, cerrors.ErrCouldNotDownload } + defer r.Body.Close() // Get the list of RHSAs that we have to process. var rhsaList []int @@ -129,6 +130,7 @@ func (f *RHELFetcher) FetchUpdate(datastore database.Datastore) (resp updater.Fe log.Errorf("could not download RHEL's update file: %s", err) return resp, cerrors.ErrCouldNotDownload } + defer r.Body.Close() // Parse the XML. vs, err := parseRHSA(r.Body) diff --git a/updater/fetchers/rhel/rhel_test.go b/updater/fetchers/rhel/rhel_test.go index 90998c78f2..f764ecdcfd 100644 --- a/updater/fetchers/rhel/rhel_test.go +++ b/updater/fetchers/rhel/rhel_test.go @@ -32,6 +32,7 @@ func TestRHELParser(t *testing.T) { // Test parsing testdata/fetcher_rhel_test.1.xml testFile, _ := os.Open(path + "/testdata/fetcher_rhel_test.1.xml") vulnerabilities, err := parseRHSA(testFile) + testFile.Close() if assert.Nil(t, err) && assert.Len(t, vulnerabilities, 1) { assert.Equal(t, "RHSA-2015:1193", vulnerabilities[0].Name) assert.Equal(t, "https://rhn.redhat.com/errata/RHSA-2015-1193.html", vulnerabilities[0].Link) @@ -70,6 +71,7 @@ func TestRHELParser(t *testing.T) { // Test parsing testdata/fetcher_rhel_test.2.xml testFile, _ = os.Open(path + "/testdata/fetcher_rhel_test.2.xml") vulnerabilities, err = parseRHSA(testFile) + testFile.Close() if assert.Nil(t, err) && assert.Len(t, vulnerabilities, 1) { assert.Equal(t, "RHSA-2015:1207", vulnerabilities[0].Name) assert.Equal(t, "https://rhn.redhat.com/errata/RHSA-2015-1207.html", vulnerabilities[0].Link)