-
Notifications
You must be signed in to change notification settings - Fork 185
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
AppStreams reposync module #8421
AppStreams reposync module #8421
Conversation
3960103
to
72ebc8b
Compare
b1ba7a2
to
953e113
Compare
95f5c1b
to
c2a2862
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.
I only looked at the Python code. I think there is a risk of an SQL injection, please check that again. I also left a few other comments. Many are nitpicks, feel free to ignore them.
sql = "INSERT INTO suseAppstreamApi (rpm, module_id) VALUES " | ||
sql += ",".join([f"('{api}', {module_id})" for api in apis]) | ||
sql += " ON CONFLICT DO NOTHING" |
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.
Is this safe against SQL injections? I think we're handling untrusted input here.
# Remove the trailing ':' if epoch is present | ||
epoch = match.group("epoch")[:-1] if match.group("epoch") else None |
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.
[nitpick] If you don't want to have to comment the code you can use rstrip
instead. Either way is fine.
# Remove the trailing ':' if epoch is present | |
epoch = match.group("epoch")[:-1] if match.group("epoch") else None | |
epoch = match.group("epoch").rstrip(":") if match.group("epoch") else None |
modulemd_importer = ModuleMdImporter( | ||
self.channel["id"], modulemd_path | ||
) | ||
modulemd_importer.validate() |
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 can raise an exception, can you add code that handles it? The general exception handler logs with "Unexpected error", maybe we can use a concrete logging statement instead.
return self.copy_metadata_file( | ||
plug, modulesfile, "modules", relative_modules_dir | ||
) |
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.
Why was this changed?
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.
Black insists on it (and all the others) 😞
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.
Are you running black from the container? reposync.py
was already reformatted with black, I wonder why yours has a different line length
to_disassociate[(db_pack["checksum_type"], db_pack["checksum"])] = ( | ||
True | ||
) |
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 here, why the reformatting?
|
||
assert exc.value.domain == "modulemd-yaml-error-quark" | ||
|
||
# pylint: disable=protected-access |
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.
[nitpick] This looks like something has the wrong visibility
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 case tests the protected _get_modules
method. Black doesn't let this without the disable
directive.
# pylint: enable=wrong-import-position | ||
|
||
|
||
class TestModuleMdImporter: |
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.
[nitpick] There is no need for a class here.
33c4456
to
6762863
Compare
97519ae
to
f4d314c
Compare
f4d314c
to
70c64c0
Compare
A Python module that imports AppStream module metadata from the downloaded
.yaml
file during repo-sync.Documentation
Test coverage
Links
Fixes https://github.com/SUSE/spacewalk/issues/23770
Changelogs
Make sure the changelogs entries you are adding are compliant with https://github.com/uyuni-project/uyuni/wiki/Contributing#changelogs and https://github.com/uyuni-project/uyuni/wiki/Contributing#uyuni-projectuyuni-repository
If you don't need a changelog check, please mark this checkbox:
If you uncheck the checkbox after the PR is created, you will need to re-run
changelog_test
(see below)Re-run a test
If you need to re-run a test, please mark the related checkbox, it will be unchecked automatically once it has re-run:
Before you merge
Check How to branch and merge properly!