Skip to content

fix: remove deprecate way of implementaion#121

Open
pohanhuang wants to merge 1 commit into
neuvector:mainfrom
pohanhuang:refactor/remove-legacy-implemntation
Open

fix: remove deprecate way of implementaion#121
pohanhuang wants to merge 1 commit into
neuvector:mainfrom
pohanhuang:refactor/remove-legacy-implemntation

Conversation

@pohanhuang

@pohanhuang pohanhuang commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Description

  • ioutils
  • Sprintf (to minimize the memory usage)
  • replac(.., -1)

- ioutils
- Sprintf
- replac(.., -1)

Signed-off-by: pohanhuang <pohan.huang@suse.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes and streamlines multiple fetchers/utilities by removing deprecated io/ioutil usage, reducing fmt.Sprintf usage in favor of direct string building, and switching legacy strings.Replace(..., -1) calls to strings.ReplaceAll.

Changes:

  • Replace deprecated io/ioutil helpers with io.ReadAll, os.ReadFile, os.ReadDir, os.MkdirTemp, os.CreateTemp, etc.
  • Reduce formatting overhead by replacing many fmt.Sprintf calls with string concatenation / strconv conversions.
  • Replace strings.Replace(..., -1) with strings.ReplaceAll in multiple fetchers.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated no comments.

Show a summary per file
File Description
updater/nvd/xml.go Removes fmt.Sprintf from CVSS vector construction in favor of direct concatenation.
updater/fetchers/ubuntu/ubuntu.go Replaces ioutil.TempDir and various Sprintf uses with os.MkdirTemp and concatenation.
updater/fetchers/suse/suse.go Uses direct concatenation for local file paths and namespace construction; switches to ReplaceAll.
updater/fetchers/rocky/rocky.go Replaces fmt.Sprintf in namespaces and pagination URL construction with strconv + concatenation.
updater/fetchers/rhel2/rhel.go Replaces ioutil usage and multiple Sprintf-built keys/URLs with io/os and concatenation.
updater/fetchers/photon/photon.go Removes fmt usage; uses strconv.FormatFloat for namespace string building.
updater/fetchers/oracle/oracle.go Replaces strings.Replace(..., -1) with ReplaceAll and removes some Sprintf usage.
updater/fetchers/mariner/mariner.go Replaces Sprintf path building with concatenation; replaces fmt.Println with structured logging and skips invalid entries.
updater/fetchers/debian/debian.go Replaces Sprintf path building with concatenation.
updater/fetchers/chainguardv2/chainguardv2.go Replaces formatted advisory URL template with prefix/suffix concatenation.
updater/fetchers/apps/ruby.go Replaces ioutil.TempDir/ReadFile with os.MkdirTemp/os.ReadFile; adjusts comment formatting.
updater/fetchers/apps/openssl.go Replaces ioutil.ReadAll with io.ReadAll.
updater/fetchers/apps/nginx.go Replaces ioutil.ReadAll with io.ReadAll and switches several Replace calls to ReplaceAll.
updater/fetchers/apps/manual.go Replaces fmt.Sprintf path building with concatenation.
updater/fetchers/apps/k8s.go Replaces ioutil.ReadAll with io.ReadAll and uses concatenation for local file path building.
updater/fetchers/apps/govuln.go Replaces fmt.Sprintf local file path building with concatenation.
updater/fetchers/apps/ghsa.go Replaces some Sprintf usage with concatenation (keys and description assembly).
updater/fetchers/apps/cvedetails.go Replaces ioutil.ReadAll with io.ReadAll and removes a Sprintf string-contains usage.
updater/fetchers/apps/apps.go Replaces fmt.Sprintf key building with concatenation.
updater/fetchers/amazon/amazon.go Replaces ioutil.ReadAll with io.ReadAll and switches namespace formatting to strconv.Itoa.
updater/fetchers/alpine/alpine.go Removes ioutil/fmt, adds response read error handling, and reuses a package-level namespace regex.
updater/fetchers/alpine/alpine_test.go Updates tests to use package-level nsRegexp and os.ReadFile instead of ioutil.
share/utils.go Replaces ioutil.ReadAll with io.ReadAll.
share/tar.go Replaces multiple ioutil helpers with io/os equivalents and switches to ReplaceAll for path sanitization.
share/set.go Replaces fmt.Sprintf in String() with direct concatenation around strings.Join.
common/debug.go Replaces fmt.Sprintf("%s...", ...) with direct concatenation.
Comments suppressed due to low confidence (1)

updater/fetchers/photon/photon.go:120

  • The version parsing error check uses the wrong variable (err instead of err2), so parse failures from common.NewVersion may be silently ignored (or the check may trigger incorrectly based on an unrelated earlier error).
			namespace := "photon:" + strconv.FormatFloat(file.Version, 'f', -1, 64)
			if vuln.ResolvedVersion == "N/A" || vuln.ResolvedVersion == "NA" {
				vuln.ResolvedVersion = common.MaxVersion.String()
			}
			version, err2 := common.NewVersion(vuln.ResolvedVersion)
			if err != nil {
				log.WithFields(log.Fields{"err": err2, "vuln": vuln.CveId}).Info("Unable to resolve version for photon vulnerability.")
				continue
			}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants