Skip to content

Commit

Permalink
remove extraneous information (including filenames) from the image ta…
Browse files Browse the repository at this point in the history
…g calculations

- most of the extraneous information is harmless, but the filenames
  can actually vary from one installation to another if the pathing is
  not the same (installed somewhere besides /opt/crucible, CI
  environment, etc.)

- since the paths are not important, but the file contents are, they
  are being removed from the hash calculation to avoid simple path
  differences from resulting in different image tags
  • Loading branch information
k-rister committed Jun 21, 2024
1 parent 84502b9 commit 1bbdeda
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions rickshaw-run
Original file line number Diff line number Diff line change
Expand Up @@ -505,17 +505,14 @@ sub calc_image_md5 {
my $item;

# First is the Initial hash calc on workshop reqs
$item = $item_header . "Workshop Config Output:\n" . join("", @config_analysis_output) . "\n";
$md5->add($item);
print $tag_fh $item;
print $tag_fh $item_header . "Workshop Config Output:\n" . join("", @config_analysis_output) . "\n";
$md5->add(join("", @config_analysis_output));

# Second is the hashing contents of files
for my $file (sort @files) {
debug_log(sprintf "calc_image_md5(): adding '%s' to hash\n", $file);

$item = $item_header . "File: " . $file . "\nFile Contents:\n";
$md5->add($item);
print $tag_fh $item;
print $tag_fh $item_header . "File: " . $file . "\nFile Contents:\n";

open(my $fh, $file);
while(<$fh>) {
Expand All @@ -526,14 +523,13 @@ sub calc_image_md5 {

binmode($fh);
$md5->addfile($fh);
$md5->add("\n");

close($fh);
}
my $base_hash = $md5->hexdigest;
print $tag_fh $item_header . "Hash: " . $base_hash . "\n";
close($tag_fh);
my $full_hash = $base_hash . "_" . $arch_suffix;
print $tag_fh $item_header . "Hash: " . $full_hash . "\n";
close($tag_fh);
debug_log(sprintf "calc_image_md5(): returning '%s'\n", $full_hash);

return $full_hash;
Expand Down

0 comments on commit 1bbdeda

Please sign in to comment.