-
Notifications
You must be signed in to change notification settings - Fork 117
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
[opensuse] Add FileDigestCheck #594
[opensuse] Add FileDigestCheck #594
Conversation
I've got few notes about File Digest check:
|
588754e
to
c31ff66
Compare
I looked at the code and tested the new check. The logic should be okay now. I still have a couple of detailed comments though that I will add individually soon. |
d6a6a08
to
b0261fc
Compare
I find it a bit confusing with many things going on in parallel in the review/discussion. Maybe we should first agree on the suitable configuration structure before continuing with the other details. I still don't find the current suggestion very intuitive. I dived a bit deeper into what TOML provides and have come up with this approach:
This approach still repeats the package names in the sub-tables, but this is due to a limitation of TOML not allowing newlines in inline-tables, see toml-lang/toml#516. The resulting python data structure looks like this:
What do you think? |
I like the suggested format with one small nit: replacing I've just pushed a patch that supports your format. |
@mgerstner Do you feel the current shape of |
Okay the configuration syntax looks good now. The check still behaves erroneous, though. In the I also get a KeyError in line 111, because the check tries to access a file in the package that isn't even existing. Is there a possibility to show the full exception backtrace when running rpmlint and a check fails internally? Because this error here was not very helpful:
For contextual files like /usr/sbin/sarg-reports the reported "group" is None, because the prefix of this path is not in a cron directory. It could make sense to assign each FileDigestGroup a type. Now that I think about it, something like this will most certainly become necessary, because we need to be able to keep parallel whitelists for cron, systemd-tmpfiles etc. Say we want to keep separate xml files for them:
These two entries should be treated seperately. So we need to encode the type |
Ok, the function
Which one is not good, or please show me an example.
Sure, will fix that.
Sure, just apply the following patch: diff --git a/rpmlint/lint.py b/rpmlint/lint.py
index 1d75625..419a629 100644
--- a/rpmlint/lint.py
+++ b/rpmlint/lint.py
@@ -255,6 +255,7 @@ class Lint(object):
self.run_checks(pkg)
except Exception as e:
print_warning(f'(none): E: fatal error while reading {pname}: {e}')
+ raise e
sys.exit(3)
def run_checks(self, pkg):
Oh yes, that's really a limitation.
What about:
where when checking the |
Maybe I didn't express the problem good enough. The problem is that even if a package doesn't
Yes it sounds good. |
You are right, that were bogus errors. I've just pushed a version with simplified logic that respects the newly added |
Okay we're getting close, however there is still a problem with the
Then I receive an error:
So we would need to change the data structure to allow for this. |
That's really problem. It will need something like: rpmlint/test/configs/test.config Line 60 in f6f7671
However, I'm considering flattening of the |
Hmm, I don't see big advantages or disadvantages. The hierarchical approach before made it clearer that the different digest groups are related IMO but I can also live with this new approach. It looks like there is a regression now, though: The package field is not evaluated, so the digests are considered for all packages. Can you maybe add this to your tests that the config only is evaluated for matching package names? Also I noticed the check doesn't work when there are not |
It will help as the implementation can be simplified a bit.
Fixed that and it's now newly tests.
I added |
The package is now correctly take in to account. I'm sorry to say it still doesn't work as expected though. Having two separate check types doesn't work out, the problem must be somewhere in line 131
This results in the following error:
So the apache config file is treated as being part of the cron type check and the apache type whitelisting isn't used. |
I'm sorry that it still does not work as expected :/ It's being caused by fact that we require that all package files (in a secured file digest location) must be covered by exactly one |
Groups of different type should not have any influence on each other. For each restriction type exactly one group of the same type should fully match. |
I see that makes sense. I fixed that and tested it on the package. We'll definitely need a better test coverage I guess. |
Yes a more complex test case that checks all the corner cases would surely be helpful. Okay the current state seems to finally work for the FileDigestCheck. Now there remains the question about the "error details". In rpmlint-1 we have How can we achieve this in rpmlint-2? |
This can be easily achieved by adding a description to Similarly one can see:
|
Okay so the mechanism is clear. However we would like to add the openSUSE wiki URL to the explanation and we also would like to avoid redundancy. Currently we do this by using some generic text snippets that are Since this is now a TOML file where the descriptions reside, doing it during runtime is not so easy. We could generate the description file from the repository via a script or something but that would complicate the installation somewhat. Any ideas? |
I think it's a good idea to have snippets (variables). Should be addressed with 2c78ab1 that can be upstreamed later. Hope it will work for your use case? |
Okay snippets in error descriptions look good this should allow us to do what we want. Testing this I found yet another regression, however: When there are no digest groups present for a package then no error is raised at all ( |
Good. Will you please prepare a commit that will add the descriptions?
Fixed that. I'm suggesting to move the unreviewed |
For this to be complete I would need to add configuration for all whitelisting restrictions we currently have in place, also add the actual whitelists as we already have them in rpmlint1 and then the error descriptions for each type of error we have. Would that be okay?
We really need some actual test coverage before we can bring that into production. We should implement various test cases:
Probably I missed a couple of situations there.
Yes that is a good idea, because this took quite a lot of time and we should "save" the progress we have made. Before we do that we should cover the points above, however, and I also want to involve Johannes to test the final variant of the checker, because I'm starting to get blind myself about this and we need a final fresh view on things before we move it into production. |
8612e6b
to
42134da
Compare
Yes. We can likely make it a separate pull request to |
Sure, please submit such packages to https://build.opensuse.org/project/show/devel:openSUSE:Factory:rpmlint:tests and then add the created |
Good, I've just done that in #600. |
Maybe we should at the moment just add some example configuration (commented out) so that users can quickly understand how the configuration os the checker is supposed to work. This can be part of the standard rpmlint, while the actual production configuration we need are then added to the opensuse branch. |
Can you explain to us how the connection between these test packages and the tests within the |
In order to create a rpm test-case, one needs something like OBS. So that's why we track .spec files in the |
To be honest, based on the experience with #439, I don't think upstream is going to accept the pass. |
Okay I have informed @jsegitz about the current state of the check and asked him to look at it from his point of view if usability, feature set and robustness are all right. I am waiting for this statement before I continue. Which process should be follow to complete the integration? I can create commits to add the error descriptions and port the actual production whitelisting entries from rpmlint1. Should I do this as a separate PR# once this PR# is merged? |
Currently, we do face problems with extensive dependencies of the patch: I hope @kstreitova can make a progress with taht.
I guess so. May I please ask @kstreitova for a review of this pull request? |
@jsegitz also pointed out that rpmlint is behaving badly when there are syntax errors in TOML configuration files like
So its not clear in which file exactly the error occured. And even worse, the rpmlint processing continues, bit without the security related checks. In such a case we need rpmlint to abort with an error such that package with potential dangerous content don't build successfully in protected projects on OBS. Another things we noted is that at least in the packaging that you have in |
Very good point, I've just made #603 for it:
This is replaced with:
... and rpmlint prints a fatal error and ends.
Fixed here: |
Btw. I've just extended rpmlint/test/test_file_digest.py Lines 49 to 59 in a7f460d
|
No description provided.