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: add rpm package verification #632

Merged

Conversation

MiahaCybersec
Copy link
Contributor

Closes #601

Signed-off-by: Miaha <miahacybersec@gmail.com>
Copy link

codecov bot commented May 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 34.20%. Comparing base (2602d59) to head (c9b0c2c).
Report is 69 commits behind head on main.

Current head c9b0c2c differs from pull request most recent head 5bf917f

Please upload reports for the commit 5bf917f to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #632      +/-   ##
==========================================
+ Coverage   32.51%   34.20%   +1.69%     
==========================================
  Files          17       18       +1     
  Lines        1621     1523      -98     
==========================================
- Hits          527      521       -6     
+ Misses       1062      969      -93     
- Partials       32       33       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Miaha <miahacybersec@gmail.com>
return err == nil
}

func isValidPackage(ver 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.

could we add a unit test to rpm_test file for this function?

Miaha Cybersec added 3 commits May 21, 2024 12:05
Signed-off-by: Miaha <miahacybersec@gmail.com>
Signed-off-by: Miaha <miahacybersec@gmail.com>
Signed-off-by: Miaha <miahacybersec@gmail.com>
// TODO: Verify if there are format correctness check that need to be added given lack of support in rpmVer lib
return true
err := isValidPackage(v)
return err == nil
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of isValidPackage maybe we could leave it in this function since we are just checking version?

for _, s := range ver {
if !unicode.IsDigit(s) && !unicode.IsLetter(s) && !strings.ContainsRune(allowedSymbols, s) {
return errors.New("upstream_version includes invalid character")
}
Copy link
Contributor

@ashnamehrotra ashnamehrotra May 21, 2024

Choose a reason for hiding this comment

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

maybe we can log the upstream_version in the error message. Otherwise the checks look good to me based on the docs!

Signed-off-by: Miaha <miahacybersec@gmail.com>
Copy link
Contributor

@ashnamehrotra ashnamehrotra left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@ashnamehrotra ashnamehrotra merged commit c9a5fb7 into project-copacetic:main May 22, 2024
20 checks passed
@MiahaCybersec MiahaCybersec deleted the rpm-verify-package branch May 23, 2024 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
2 participants