analyze: allow a custom policy to skip a check with weight=0

In some cases an offline analysis should ignore some fields, for example
a portable service in an image will never list RootImage/RootDirectory, as
they are added at runtime, and thus can be skipped.
This commit is contained in:
Luca Boccassi
2021-11-05 22:37:34 +00:00
parent 03e93377dc
commit 82100ef486
3 changed files with 8 additions and 2 deletions
+5
View File
@@ -1764,6 +1764,11 @@ static int assess(const SecurityInfo *info,
d = strdup("Service runs in special boot phase, option is not appropriate");
if (!d)
return log_oom();
} else if (weight == 0) {
badness = UINT64_MAX;
d = strdup("Option excluded by policy, skipping");
if (!d)
return log_oom();
} else {
r = a->assess(a, info, data, &badness, &d);
if (r < 0)