Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vulnsrc: Refactor debian and alpine sources #647

Merged
merged 4 commits into from
Oct 23, 2018

Conversation

KeyboardNerd
Copy link
Contributor

  • Add fsutil to handle listing directory function
  • Add FindKeyValue wrapper in database module
  • Refactor debian and alpine sources to use them

)

func TestYAMLParsing(t *testing.T) {
_, filename, _, _ := runtime.Caller(0)
path := filepath.Join(filepath.Dir(filename))
secdb, err := parseSecDBFile(path + "/testdata/v34_main.yaml")
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use filepath.Join() again here instead of +.
While it's obvious now, we you refactor and change code, it becomes less obvious over time.

ext/vulnsrc/alpine/alpine.go Show resolved Hide resolved

// Dir lists the files or folders under the given path and filter based on the
// dirFilter.
func Dir(path string, filter dirFilter) ([]string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd name this Readdir for transparency.

pkg/fsutil/fsutil.go Show resolved Hide resolved
return
}

func extractVulnerabilities(file *secDBFile) (vulns []database.VulnerabilityWithAffected) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a good place to make this a method and turn parseSecDBFile into a constructor:

secDBFile => secDB
parseSecDBFile => newSecDB
extractVulnerabilites => secDB.Vulnerabilities()

@jzelinskie jzelinskie added kind/cleanup no functional changes, only reorganization component/ext/vulnsrc labels Oct 22, 2018
@KeyboardNerd
Copy link
Contributor Author

Updated according to comments

@KeyboardNerd KeyboardNerd merged commit 05cbf32 into quay:master Oct 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup no functional changes, only reorganization
Development

Successfully merging this pull request may close these issues.

None yet

2 participants