-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
KeyboardNerd
commented
Oct 19, 2018
- Add fsutil to handle listing directory function
- Add FindKeyValue wrapper in database module
- Refactor debian and alpine sources to use them
a4a291b
to
4baf1cd
Compare
ext/vulnsrc/alpine/alpine_test.go
Outdated
) | ||
|
||
func TestYAMLParsing(t *testing.T) { | ||
_, filename, _, _ := runtime.Caller(0) | ||
path := filepath.Join(filepath.Dir(filename)) | ||
secdb, err := parseSecDBFile(path + "/testdata/v34_main.yaml") |
There was a problem hiding this comment.
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.
pkg/fsutil/fsutil.go
Outdated
|
||
// Dir lists the files or folders under the given path and filter based on the | ||
// dirFilter. | ||
func Dir(path string, filter dirFilter) ([]string, error) { |
There was a problem hiding this comment.
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.
ext/vulnsrc/alpine/alpine.go
Outdated
return | ||
} | ||
|
||
func extractVulnerabilities(file *secDBFile) (vulns []database.VulnerabilityWithAffected) { |
There was a problem hiding this comment.
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()
* Update gopkg.in/yaml.v2 package and glide setting * Update other packages
4baf1cd
to
4106322
Compare
Updated according to comments |