Skip to content

Commit

Permalink
[backend] also put anonymous containers in the digest file
Browse files Browse the repository at this point in the history
We want to generate signatures for them as well in the future.
  • Loading branch information
mlschroe committed Jan 18, 2022
1 parent 66cafe1 commit 4624669
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/backend/bs_notar
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ if ($digestfile) {
while(<DIG>) {
chomp;
next if /^#/ || /^\s*$/;
next if /^([a-z0-9]+):([a-f0-9]+) (\d+)\s*$/; # ignore anonymous images
die("bad line in digest file\n") unless /^([a-z0-9]+):([a-f0-9]+) (\d+) (.+?)\s*$/;
$manifests->{$4} = {
'hashes' => { $1 => MIME::Base64::encode_base64(pack('H*', $2), '') },
Expand Down
11 changes: 8 additions & 3 deletions src/backend/bs_regpush
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ sub manifest_upload {
sub manifest_append {
my ($manifest, $tag) = @_;
my $maniid = 'sha256:'.Digest::SHA::sha256_hex($manifest);
my $str = "$maniid ".length($manifest)." $tag\n";
my $str = "$maniid ".length($manifest).(defined($tag) ? " $tag" : '')."\n";
if ($digestfile ne '-') {
BSUtil::appendstr($digestfile, $str);
} else {
Expand All @@ -230,7 +230,11 @@ sub manifest_append {

sub manifest_upload_tags {
my ($manifest, $tags, $content_type) = @_;
return manifest_upload($manifest, undef, $content_type) unless @{$tags || []};
if (!@{$tags || []}) {
manifest_upload($manifest, undef, $content_type);
manifest_append($manifest, undef) if defined $digestfile;
return;
}
for my $tag (BSUtil::unify(@$tags)) {
manifest_upload($manifest, $tag, $content_type);
manifest_append($manifest, $tag) if defined $digestfile;
Expand Down Expand Up @@ -358,6 +362,7 @@ sub tags_from_digestfile {
while (<DIG>) {
chomp;
next if /^#/ || /^\s*$/;
next if /^([a-z0-9]+):([a-f0-9]+) (\d+)\s*$/; # ignore anonymous images
die("bad line in digest file\n") unless /^([a-z0-9]+):([a-f0-9]+) (\d+) (.+?)\s*$/;
push @ret, $4;
}
Expand Down Expand Up @@ -646,7 +651,7 @@ for my $tarfile (@tarfiles) {
my $mani_json = BSContar::create_dist_manifest($mani);

if ($multiarch) {
manifest_upload($mani_json, undef, $mediaType); # upload anonymous image
manifest_upload_tags($mani_json, undef, $mediaType); # upload anonymous image
my $multimani = {
'mediaType' => $mediaType,
'size' => length($mani_json),
Expand Down

0 comments on commit 4624669

Please sign in to comment.