-
Notifications
You must be signed in to change notification settings - Fork 99
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
feat(wrlinux): Add Wind River Linux vulnerability data (#177) #178
base: main
Are you sure you want to change the base?
Conversation
Hi, do I need to do anything else for this PR? |
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.
Hello @ssajal-wrl
Thanks for your work!
I added some comments.
wrlinux/wrlinux_test.go
Outdated
{ | ||
name: "perfect data", | ||
args: args{ | ||
filePath: "./testdata/golden", |
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.
Looks like it is not golden file.
It is source file.
Better to use names/filepaths from source.
e.g. testdata/foo/bar/CVE-1234-12345
wrlinux/wrlinux_test.go
Outdated
"Status": "ignored", | ||
"Note": "" | ||
}, | ||
10.19.45.1": { |
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.
Tests cases are broken.
Fix them or better use golden files.
} | ||
lines := strings.Split(string(all), "\n") | ||
|
||
for i := 0; i < len(lines); i++ { |
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 try to use same logic, if it is possible.
Can you use bufio
here:
vuln-list-update/debian/tracker/debian.go
Lines 177 to 179 in 728ebae
s := bufio.NewScanner(f) | |
for s.Scan() { | |
line := s.Text() |
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 can use bufio to read the file, but I still have to read in the whole file and iterate over it the same way since I have inner loops which modify iterator "i".
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.
oh... now i understand what you meant.
wrlinux/wrlinux.go
Outdated
status := strings.TrimSpace(s[1]) | ||
|
||
// Some advisories have status with "Patches_" prefix and it should be skipped | ||
// e.g. Patches_qtwebkit-opensource-src: needs-triage |
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.
can you create tests case for this?
wrlinux/wrlinux.go
Outdated
if isPatch(status) && !strings.HasPrefix(s[0], "Patches_") { | ||
pkgRel := strings.SplitN(s[0], "_", 2) | ||
release := Release(pkgRel[0]) | ||
pkgName := Package(strings.Trim(pkgRel[1], ":")) |
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.
looks like we don't need trim :
, because we did this here:
vuln-list-update/wrlinux/wrlinux.go
Line 230 in 0b161fc
s := strings.SplitN(line, ":", 2) |
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.
correct
status := Status{ | ||
Status: fields[0], | ||
} | ||
if len(fields) > 1 { |
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.
can you add comment with example, please?
} | ||
|
||
// Parse References | ||
if strings.HasPrefix(line, "References:") { |
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.
it would be better if the test case contains multiple References
values.
} | ||
|
||
// Parse Notes | ||
if strings.HasPrefix(line, "Notes:") { |
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.
Same
0b161fc
to
7224d5f
Compare
7224d5f
to
88d9f77
Compare
@DmitriyLewen I have addressed all your comments/concerns and pushed the changes. |
Hi, any updates? |
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.
sorry for waiting!
Looks good.
added some small notes.
wrlinux/wrlinux.go
Outdated
"io" | ||
"bufio" | ||
"log" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
"time" | ||
|
||
"github.com/aquasecurity/vuln-list-update/git" | ||
"github.com/araddon/dateparse" | ||
"golang.org/x/xerrors" | ||
"github.com/aquasecurity/vuln-list-update/utils" |
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.
format import with gofmt
please.
wrlinux/wrlinux.go
Outdated
vuln = &Vulnerability{} | ||
vuln.Patches = map[Package]Statuses{} | ||
|
||
lines := []string{} |
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.
lines := []string{} | |
var lines []string |
} | ||
lines := strings.Split(string(all), "\n") | ||
|
||
for i := 0; i < len(lines); i++ { |
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.
oh... now i understand what you meant.
wrlinux/wrlinux_test.go
Outdated
type args struct { | ||
filePath string | ||
} |
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 thinks we can move filePath
to testCases
struct.
Looks liike we don't need args
struct.
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.
correct
wrlinux/wrlinux_test.go
Outdated
Candidate: "CVE-2020-24241", | ||
PublicDate: time.Date(2020, 8, 25, 0, 0, 0, 0, time.UTC), | ||
Description: "In Netwide Assembler (NASM) 2.15rc10, there is heap use-after-free in saa_wbytes in nasmlib/saa.c.", | ||
Priority: "medium", | ||
Bugs: []string{ | ||
"LINCD-2974", | ||
"LIN1019-5289", | ||
"LIN1018-6614", | ||
"LIN10-7689", | ||
}, |
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.
gofmt
is also needed here
gc := git.Config{} | ||
dir := filepath.Join(utils.CacheDir(), cveTrackerDir) | ||
for _, url := range repoURLs { | ||
_, err = gc.CloneOrPull(url, dir, "master", false) |
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 think we can remove this folder after adding CVEs.
wdyt?
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.
absolutely!
88d9f77
to
365b5e6
Compare
@DmitriyLewen addressed all your comments above. Please take a look when you can! |
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.
Looks good.
1 small comment
wrlinux/wrlinux.go
Outdated
log.Printf("failed to clone or pull: %s: %v", url, err) | ||
log.Printf("removing %s directory", cveTrackerDir) | ||
if err := os.RemoveAll(dir); err != nil { | ||
return xerrors.Errorf("failed to remove %s directory: %w", cveTrackerDir, err) | ||
} |
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 is extra code
vuln-list-update/wrlinux/wrlinux.go
Line 86 in 365b5e6
defer os.RemoveAll(dir) |
this is enough
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.
correct and addressed.
365b5e6
to
3a009fd
Compare
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.
good job! @ssajal-wrl
Thanks for your work.
Can you sign CLA(#178 (comment))?
@knqyf263 i approved this PR. Can you take a look and merge this PR, if you don't see any notes.
@ssajal-wrl message have small text:)
did you try it? |
I had to sign CLA with the account that authored the commit, sorry for the delay. |
3a009fd
to
d314775
Compare
Looks like this PR is good to be merged, anything else that I need to address? |
We're sorry for the late response. We're not sure if we can keep maintaining this feature. Could you suspend your work until further notice? We want to see how many people need this one. |
) Signed-off-by: Sakib Sajal <[email protected]>
Hi, @knqyf263, what are the concerns with maintaining this feature? Would you please provide more details about your concerns? |
@FuzzyGophers More features bring more bugs. |
Thank you for the follow up, @knqyf263. The addition of Wind River Linux is a "standard" approach. The only concern I can see is whether Wind River Linux continues to host the git repo with the required vulnerability data. I will be happy to maintain this if it can be merged. Would this address your concerns? |
It's hard for outside contributors to keep maintaining OSS for the long term. It is likely that we, the maintainers, will eventually maintain it because this is our job. Unfortunately, our resources are not plentiful. |
Signed-off-by: Sakib Sajal [email protected]