Skip to content

Commit 355f73d

Browse files
committed
Extract legal review notices from specfiles
1 parent e81cf46 commit 355f73d

30 files changed

+446
-353
lines changed

assets/vue/ReportMetadata.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,12 @@
288288
<li v-for="warning in warnings" :key="warning">{{ warning }}</li>
289289
</ul>
290290
</div>
291+
<div v-if="legalReviewNotices.length > 0" id="spec-legal-review-notices" class="alert alert-success">
292+
<p>Legal review notices from packagers:</p>
293+
<ul>
294+
<li v-for="notice in legalReviewNotices" :key="notice">{{ notice }}</li>
295+
</ul>
296+
</div>
291297
<div v-if="notice !== null" class="row">
292298
<div class="col mb-3">
293299
<div class="alert alert-info">
@@ -369,6 +375,7 @@ export default {
369375
fasttrackUrl: `/reviews/fasttrack_package/${this.pkgId}`,
370376
hasSpdxReport: false,
371377
history: [],
378+
legalReviewNotices: [],
372379
notice: null,
373380
pkgAiAssisted: false,
374381
pkgChecksum: null,
@@ -413,6 +420,7 @@ export default {
413420
this.errors = data.errors;
414421
this.externalLink = externalLink({external_link: data.external_link});
415422
this.hasSpdxReport = data.has_spdx_report;
423+
this.legalReviewNotices = data.legal_review_notices;
416424
417425
this.actions = data.actions;
418426
for (const action of this.actions) {

lib/Cavil/Checkout.pm

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,18 @@ sub _kiwifile ($file) {
433433
}
434434

435435
sub _specfile ($file) {
436-
my $info = {file => $file->basename, type => 'spec', licenses => [], sources => [], '%doc' => [], '%license' => []};
436+
my $info = {
437+
file => $file->basename,
438+
type => 'spec',
439+
licenses => [],
440+
sources => [],
441+
'%doc' => [],
442+
'%license' => [],
443+
legal_review_notices => []
444+
};
437445
for my $line (split "\n", $file->slurp) {
446+
447+
# Standard metadata fields
438448
if ($line =~ /^License:\s*(.+)\s*$/) { push @{$info->{licenses}}, $1 }
439449
elsif ($line =~ /^Source(?:\d+)?:\s*(.+)\s*$/) { push @{$info->{sources}}, $1 }
440450
elsif ($line =~ /^\%doc\s*(.+)\s*$/) { push @{$info->{'%doc'}}, $1 }
@@ -443,6 +453,9 @@ sub _specfile ($file) {
443453
elsif ($line =~ /^Summary:\s*(.+)\s*$/) { $info->{summary} ||= $1 }
444454
elsif ($line =~ /^Group:\s*(.+)\s*$/) { $info->{group} ||= $1 }
445455
elsif ($line =~ /^Url:\s*(.+)\s*$/i) { $info->{url} ||= $1 }
456+
457+
# Legal review notices, non-standard but used in SUSE packages
458+
elsif ($line =~ /^\s*#+\s*Legal-Review-Notice:\s*(.+)\s*$/i) { push @{$info->{legal_review_notices}}, $1 }
446459
}
447460

448461
return $info;

lib/Cavil/Plugin/Helpers.pm

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ sub _package_summary ($c, $id) {
146146
push @$actions, $entry;
147147
}
148148

149-
my (%docs, %lics, @package_files);
149+
my (%docs, %lics, @package_files, @legal_review_notices);
150150
for my $sub (@{$spec->{sub} // []}) {
151151
my $entry = {
152152
file => $sub->{file},
@@ -164,40 +164,42 @@ sub _package_summary ($c, $id) {
164164
for my $line (@{$sub->{'%license'}}) {
165165
$lics{$_} = 1 for split(/ /, $line);
166166
}
167+
push @legal_review_notices, @{$sub->{'legal_review_notices'} // []};
167168
}
168169

169170
return {
170-
actions => $actions,
171-
copied_files => {'%doc' => [sort keys %docs], '%license' => [sort keys %lics]},
172-
created => $pkg->{created_epoch},
173-
embargoed => \!!$pkg->{embargoed},
174-
ai_assisted => \!!$pkg->{ai_assisted},
175-
errors => $spec->{errors} // [],
176-
external_link => $pkg->{external_link},
177-
has_spdx_report => \!!$has_spdx_report,
178-
history => $history,
179-
id => $pkg->{id},
180-
notice => $pkg->{notice},
181-
package_checksum => $pkg->{checkout_dir},
182-
package_files => \@package_files,
183-
package_group => $group,
184-
package_license => {name => $package_license, spdx => \!!$normalized_license},
185-
package_name => $pkg->{name},
186-
package_priority => $pkg->{priority},
187-
package_shortname => $shortname,
188-
package_summary => $summary,
189-
package_type => $type,
190-
package_url => $url,
191-
package_version => $version,
192-
products => $products,
193-
requests => $requests,
194-
result => $pkg->{result},
195-
reviewed => $pkg->{reviewed_epoch},
196-
reviewing_user => $pkg->{login},
197-
state => $pkg->{state},
198-
unpacked_files => $pkg->{unpacked_files},
199-
unpacked_size => humanize_bytes($pkg->{unpacked_size} // 0),
200-
warnings => $spec->{warnings} // []
171+
actions => $actions,
172+
copied_files => {'%doc' => [sort keys %docs], '%license' => [sort keys %lics]},
173+
created => $pkg->{created_epoch},
174+
embargoed => \!!$pkg->{embargoed},
175+
ai_assisted => \!!$pkg->{ai_assisted},
176+
errors => $spec->{errors} // [],
177+
external_link => $pkg->{external_link},
178+
has_spdx_report => \!!$has_spdx_report,
179+
history => $history,
180+
id => $pkg->{id},
181+
legal_review_notices => \@legal_review_notices,
182+
notice => $pkg->{notice},
183+
package_checksum => $pkg->{checkout_dir},
184+
package_files => \@package_files,
185+
package_group => $group,
186+
package_license => {name => $package_license, spdx => \!!$normalized_license},
187+
package_name => $pkg->{name},
188+
package_priority => $pkg->{priority},
189+
package_shortname => $shortname,
190+
package_summary => $summary,
191+
package_type => $type,
192+
package_url => $url,
193+
package_version => $version,
194+
products => $products,
195+
requests => $requests,
196+
result => $pkg->{result},
197+
reviewed => $pkg->{reviewed_epoch},
198+
reviewing_user => $pkg->{login},
199+
state => $pkg->{state},
200+
unpacked_files => $pkg->{unpacked_files},
201+
unpacked_size => humanize_bytes($pkg->{unpacked_size} // 0),
202+
warnings => $spec->{warnings} // []
201203
};
202204
}
203205

t/api.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ $routes->get('/source/:project/perl-Mojolicious' => [project => ['devel:language
7171
size="675142" mtime="1496988144" />
7272
<entry name="perl-Mojolicious.changes" md5="46c99c12bdce7adad475de28916975ef"
7373
size="81924" mtime="1496988145" />
74-
<entry name="perl-Mojolicious.spec" md5="4d480d6329a7ea52f7bb3a479d72b8fe"
74+
<entry name="perl-Mojolicious.spec" md5="efab031c960c314a31f39a4a5e68ca50"
7575
size="2420" mtime="1496988145" />
7676
</directory>
7777
EOF

t/embargo.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ get '/source/:project/perl-Mojolicious.SUSE_SLE-15-SP2_Update' => [project => ['
6464
size="675142" mtime="1496988144" />
6565
<entry name="perl-Mojolicious.changes" md5="46c99c12bdce7adad475de28916975ef"
6666
size="81924" mtime="1496988145" />
67-
<entry name="perl-Mojolicious.spec" md5="4d480d6329a7ea52f7bb3a479d72b8fe"
67+
<entry name="perl-Mojolicious.spec" md5="efab031c960c314a31f39a4a5e68ca50"
6868
size="2420" mtime="1496988145" />
6969
</directory>
7070
EOF
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
###
2+
### Legal-Review-Notice: testing 123
3+
###
14
Summary: Just a test
25
License: MIT
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
License: MIT AND BSD-3-Clause
2+
# legal-review-notice: hello
3+
# legal-review-notice: cavil!
24
Summary: Just a test
5+
# Legal-Review-Notice: Proprietary video codecs are disabled

t/legal-bot/perl-Mojolicious/c7cfdab0e71b0bebfdf8b2dc3badfecd/perl-Mojolicious.spec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,7 @@ find . -type f ! -name \*.pl -print0 | xargs -0 chmod 644
7171
%license LICENSE
7272

7373
%changelog
74+
75+
#
76+
# Legal-Review-Notice: Upstream project maintained by SUSE employee
77+
#

t/manual_review.t

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,12 @@ subtest 'Details after indexing' => sub {
107107
->status_is(200)
108108
->json_like('/package_license/name', qr!Artistic-2.0!)
109109
->json_is('/package_license/spdx', 1)
110-
->json_like('/package_version', qr!7\.25!)
111-
->json_like('/package_summary', qr!Real-time web framework!)
112-
->json_like('/package_group', qr!Development/Libraries/Perl!)
113-
->json_like('/package_url', qr!http://search\.cpan\.org/dist/Mojolicious/!)
114-
->json_like('/state', qr!new!)
110+
->json_like('/package_version', qr!7\.25!)
111+
->json_like('/package_summary', qr!Real-time web framework!)
112+
->json_like('/package_group', qr!Development/Libraries/Perl!)
113+
->json_like('/package_url', qr!http://search\.cpan\.org/dist/Mojolicious/!)
114+
->json_like('/state', qr!new!)
115+
->json_like('/legal_review_notices/0', qr!Upstream project maintained by SUSE employee!)
115116
->json_is('/unpacked_files', 339)
116117
->json_is('/unpacked_size', '2.5MiB');
117118

t/mcp_api.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ subtest 'MCP' => sub {
172172
like $text, qr/Priority:.+5/, 'priority';
173173
like $text, qr/Created:.+/, 'created';
174174
like $text, qr/Manual review is required because no previous reports are available/, 'system notice';
175+
like $text, qr/Upstream project maintained by SUSE employee/, 'legal review notice';
175176
like $text, qr/Elevated risk, package might contain incompatible licenses/, 'risk notice';
176177
like $text, qr/\* GPL-2.0-only: 1 file/, 'license summary';
177178
like $text, qr/- `gpl2_file.txt`/, 'matched file';

0 commit comments

Comments
 (0)