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

feat(wrlinux): Add Wind River Linux vulnerability data (#177) #178

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ssajal-wrl
Copy link

Signed-off-by: Sakib Sajal [email protected]

@CLAassistant
Copy link

CLAassistant commented Nov 9, 2022

CLA assistant check
All committers have signed the CLA.

@ssajal-wrl
Copy link
Author

Hi, do I need to do anything else for this PR?

Copy link
Contributor

@DmitriyLewen DmitriyLewen left a 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.

{
name: "perfect data",
args: args{
filePath: "./testdata/golden",
Copy link
Contributor

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

"Status": "ignored",
"Note": ""
},
10.19.45.1": {
Copy link
Contributor

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++ {
Copy link
Contributor

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:

s := bufio.NewScanner(f)
for s.Scan() {
line := s.Text()

Copy link
Author

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".

Copy link
Contributor

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.

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
Copy link
Contributor

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?

if isPatch(status) && !strings.HasPrefix(s[0], "Patches_") {
pkgRel := strings.SplitN(s[0], "_", 2)
release := Release(pkgRel[0])
pkgName := Package(strings.Trim(pkgRel[1], ":"))
Copy link
Contributor

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:

s := strings.SplitN(line, ":", 2)

Copy link
Author

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 {
Copy link
Contributor

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:") {
Copy link
Contributor

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:") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

@ssajal-wrl
Copy link
Author

@DmitriyLewen I have addressed all your comments/concerns and pushed the changes.
Please review it when you have time :)

@ssajal-wrl
Copy link
Author

Hi, any updates?

Copy link
Contributor

@DmitriyLewen DmitriyLewen left a 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.

Comment on lines 12 to 23
"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"
Copy link
Contributor

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.

vuln = &Vulnerability{}
vuln.Patches = map[Package]Statuses{}

lines := []string{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
lines := []string{}
var lines []string

}
lines := strings.Split(string(all), "\n")

for i := 0; i < len(lines); i++ {
Copy link
Contributor

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.

Comment on lines 21 to 23
type args struct {
filePath string
}
Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

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

correct

Comment on lines 36 to 45
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",
},
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Author

Choose a reason for hiding this comment

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

absolutely!

@ssajal-wrl
Copy link
Author

@DmitriyLewen addressed all your comments above. Please take a look when you can!

Copy link
Contributor

@DmitriyLewen DmitriyLewen left a 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

Comment on lines 77 to 81
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)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this is extra code

defer os.RemoveAll(dir)

this is enough

Copy link
Author

Choose a reason for hiding this comment

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

correct and addressed.

Copy link
Contributor

@DmitriyLewen DmitriyLewen left a 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
Copy link
Author

Hi, I have signed the CLA for vuln-list-update but it still shows as pending, I am not sure how to resolve this. Any suggestions?
CLA

@DmitriyLewen
Copy link
Contributor

@ssajal-wrl message have small text:)

You have signed the CLA already but the status is still pending? Let us recheck it.

did you try it?

@sajal-wr
Copy link

I had to sign CLA with the account that authored the commit, sorry for the delay.

@ssajal-wrl
Copy link
Author

Looks like this PR is good to be merged, anything else that I need to address?

@knqyf263
Copy link
Collaborator

knqyf263 commented Apr 4, 2023

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.

@FuzzyGophers
Copy link

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.

Hi, @knqyf263, what are the concerns with maintaining this feature? Would you please provide more details about your concerns?

@knqyf263
Copy link
Collaborator

@FuzzyGophers More features bring more bugs.

@FuzzyGophers
Copy link

FuzzyGophers commented Jan 16, 2024

@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?

@knqyf263
Copy link
Collaborator

I will be happy to maintain this if it can be merged.

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.

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.

6 participants