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

Fix CodeQL warnings #740

Merged
merged 2 commits into from
Mar 2, 2023
Merged

Fix CodeQL warnings #740

merged 2 commits into from
Mar 2, 2023

Conversation

r0x0d
Copy link
Member

@r0x0d r0x0d commented Feb 17, 2023

This commit introduces a bunch of fixes for the warnings/notices that CodeQL was showing for Convert2RHEL under the the Security tab.

Jira Issue: RHELC-

Checklist

  • PR meets acceptance criteria specified in the Jira issue
  • PR has been tested manually in a VM (either author or reviewer)
  • Jira issue has been made public if possible
  • [RHELC-] is part of the PR title
  • Code and tests are documented properly
  • The commits are squashed to as few commits as possible (without losing data)
  • When merged: Jira issue has been updated to Release Pending

@r0x0d r0x0d self-assigned this Feb 17, 2023
@r0x0d
Copy link
Member Author

r0x0d commented Feb 17, 2023

No rush for reviewing here.

@codecov
Copy link

codecov bot commented Feb 17, 2023

Codecov Report

Patch coverage: 55.55% and project coverage change: +0.08 🎉

Comparison is base (46ae57f) 92.85% compared to head (9c81328) 92.93%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #740      +/-   ##
==========================================
+ Coverage   92.85%   92.93%   +0.08%     
==========================================
  Files          24       24              
  Lines        3329     3326       -3     
  Branches      583      579       -4     
==========================================
  Hits         3091     3091              
  Misses        171      171              
+ Partials       67       64       -3     
Flag Coverage Δ
centos-linux-7 88.27% <22.22%> (+0.07%) ⬆️
centos-linux-8 89.26% <55.55%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
convert2rhel/redhatrelease.py 78.00% <0.00%> (ø)
convert2rhel/pkghandler.py 93.11% <100.00%> (+0.42%) ⬆️
convert2rhel/pkgmanager/__init__.py 100.00% <100.00%> (+3.44%) ⬆️
convert2rhel/pkgmanager/handlers/base.py 66.66% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

convert2rhel/unit_tests/conftest.py Show resolved Hide resolved
Copy link
Member

@bocekm bocekm left a comment

Choose a reason for hiding this comment

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

TODO: Remove a failed check identified at #723 (comment).

return DnfTransactionHandler()
from convert2rhel.pkgmanager.handlers.dnf import DnfTransactionHandler

return DnfTransactionHandler()
Copy link
Member

Choose a reason for hiding this comment

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

Just a note, since you were asking about how to rewrite code that requires either dnf or yum in one of our 1::1s. This can be done at the toplevel with something like:

try:
    from yum import *
    # [...]
    from convert2rhel.pkgmanager.handlers.yum import YumTransactionHandler as TransactionHandler
except ImportError:
    from convert2rhel.pkgmanager.handlers.dnf import DnfTransactionHandler as TransactionHandler

The naming (`TransactionHandler vs DnTransactionHandler) could be done inside of the specific handlers instead of in this file as well.

(This should not be done in this PR. Just seeing this reminded me of our discussion.)

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that it would cause a recursive import, as the {Yum,Dnf}TransactionHandler import from pkgmanager to do a lot of operations.

But once we have figured up a good way of transitioning to the refactor of yum/dnf, we can take care of that.

stream.write("".join(manpage))
stream.close()
with open(self.output, mode="w") as stream:
stream.write("".join(manpage))
Copy link
Member

Choose a reason for hiding this comment

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

This build script is just copied into our repository from https://github.com/andialbrecht/build_manpage In my pylint cleanup patch, I excluded this file instead of fixing it in our copy so that we didn't get out of sync. OTOH, the upstream looks dead so maybe changing it is the right thing to do...

(No changes needed, just something to think about).

Copy link
Member

@bocekm bocekm Feb 21, 2023

Choose a reason for hiding this comment

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

I'd not be worried about diverging since as you mentioned the upstream is not maintained anymore.

@r0x0d
Copy link
Member Author

r0x0d commented Feb 23, 2023

TODO: Remove a failed check identified at #723 (comment).

Done.

@Venefilyn Venefilyn added the kind/feature New feature or request label Feb 28, 2023
This commit introduces a bunch of fixes for the warnings/notices that CodeQL
was showing for Convert2RHEL under the the `Security` tab.

Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
@r0x0d
Copy link
Member Author

r0x0d commented Mar 1, 2023

Rebased to trigger the tests once more. Probably if they fail for some reason will not be related to the PR itself, but just in case, triggering this again.

@r0x0d
Copy link
Member Author

r0x0d commented Mar 1, 2023

Failures do not seem to be related to the changes made here.

@r0x0d
Copy link
Member Author

r0x0d commented Mar 2, 2023

Merging this as it seems that the failures are not related to the PR, but rather some infrastructure problems.

@r0x0d r0x0d merged commit 7250bdd into oamg:main Mar 2, 2023
@r0x0d r0x0d deleted the fix-codeql-messages branch March 2, 2023 12:31
@Venefilyn Venefilyn added kind/security Anything which improves security or fixes vulnerabilities and removed kind/feature New feature or request labels May 22, 2023
Venefilyn pushed a commit that referenced this pull request Jun 19, 2023
* Fix CodeQL warnings

This commit introduces a bunch of fixes for the warnings/notices that CodeQL
was showing for Convert2RHEL under the the `Security` tab.

Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>

* Fix leftover warning from #723

Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>

---------

Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/security Anything which improves security or fixes vulnerabilities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants