|
29 | 29 | /* Globals */
|
30 | 30 | static const char *srpm = NULL;
|
31 | 31 | static int nspdx = 0;
|
| 32 | +static int nlegacy = 0; |
| 33 | +static int ndual = 0; |
32 | 34 | string_list_t *booleans = NULL;
|
33 | 35 |
|
34 | 36 | /* Local helper functions */
|
@@ -168,13 +170,20 @@ static bool lic_cb(const char *license_name, void *cb_data)
|
168 | 170 | if (!approved) {
|
169 | 171 | /* invalid - do nothing */
|
170 | 172 | goto done;
|
| 173 | + } |
| 174 | + |
| 175 | + if (spdx_abbrev && !strcasecmp(lic, spdx_abbrev) && list_contains(fedora_abbrev, lic)) { |
| 176 | + /* license token is valid under the legacy system and SPDX */ |
| 177 | + data->valid = true; |
| 178 | + ndual++; |
171 | 179 | } else if (spdx_abbrev && !strcasecmp(lic, spdx_abbrev)) {
|
172 | 180 | /* SPDX identifier matched */
|
173 | 181 | data->valid = true;
|
174 | 182 | nspdx++;
|
175 | 183 | } else if (list_contains(fedora_abbrev, lic) || (list_len(fedora_abbrev) == 0 && spdx_abbrev == NULL && list_contains(fedora_name, lic))) {
|
176 | 184 | /* Old Fedora abbreviation matches -or- there are no Fedora abbreviations but a Fedora name matches */
|
177 | 185 | data->valid = true;
|
| 186 | + nlegacy++; |
178 | 187 | }
|
179 | 188 |
|
180 | 189 | done:
|
@@ -544,21 +553,36 @@ static bool is_valid_license(struct rpminspect *ri, struct result_params *params
|
544 | 553 | free(wlicense);
|
545 | 554 |
|
546 | 555 | /* for SPDX tags found, ensure booleans are all uppercase */
|
547 |
| - if (nspdx > 0 && (booleans && !TAILQ_EMPTY(booleans))) { |
| 556 | + if (nlegacy == 0 && ndual == 0 && nspdx > 0 && (booleans && !TAILQ_EMPTY(booleans))) { |
548 | 557 | TAILQ_FOREACH(entry, booleans, items) {
|
549 | 558 | if ((!strcasecmp(entry->data, "AND") && strcmp(entry->data, "AND"))
|
550 | 559 | || (!strcasecmp(entry->data, "OR") && strcmp(entry->data, "OR"))) {
|
551 | 560 | r = false;
|
552 | 561 |
|
553 | 562 | params->severity = RESULT_BAD;
|
554 | 563 | params->remedy = get_remedy(REMEDY_INVALID_BOOLEAN);
|
555 |
| - xasprintf(¶ms->msg, _("SPDX license expressions in use, but an invalid boolean was found: %s; when using SPDX expression the booleans must be in all caps."), entry->data); |
| 564 | + xasprintf(¶ms->msg, _("SPDX license expressions in use in %s, but an invalid boolean was found: %s; when using SPDX expression the booleans must be in all caps."), nevra, entry->data); |
| 565 | + xasprintf(¶ms->details, _("License: %s"), license); |
556 | 566 | add_result(ri, params);
|
557 | 567 | free(params->msg);
|
| 568 | + free(params->details); |
| 569 | + params->details = NULL; |
558 | 570 | }
|
559 | 571 | }
|
560 | 572 | }
|
561 | 573 |
|
| 574 | + /* mixed SPDX and legacy tags are forbidden */ |
| 575 | + if (nlegacy > 0 && nspdx > 0 && ndual == 0) { |
| 576 | + params->severity = RESULT_BAD; |
| 577 | + params->remedy = get_remedy(REMEDY_MIXED_LICENSE_TAGS); |
| 578 | + xasprintf(¶ms->msg, _("Mixed SPDX and legacy license identifiers found in %s."), nevra); |
| 579 | + xasprintf(¶ms->details, _("License: %s"), license); |
| 580 | + add_result(ri, params); |
| 581 | + free(params->msg); |
| 582 | + free(params->details); |
| 583 | + params->details = NULL; |
| 584 | + } |
| 585 | + |
562 | 586 | return r;
|
563 | 587 | }
|
564 | 588 |
|
|
0 commit comments