Skip to content

Commit 3b4e8cc

Browse files
dglzakame
authored andcommitted
generate: Add checksum validation for SSL modules
cpanm defaults to downloading via http, so currently while there is a checksum for App::cpanminus there isn't a checksum or validation for the SSL modules installed. Rather than just switching to HTTPS, explicitly download the modules and verify the checksums, so the Docker image is built with known versions and checksums.
1 parent 310b7bc commit 3b4e8cc

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

generate.pl

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,25 @@ sub die_with_sample {
8585

8686
my %builds;
8787

88-
# sha256 taken from http://www.cpan.org/authors/id/M/MI/MIYAGAWA/CHECKSUMS
89-
my %cpanm = (
90-
name => "App-cpanminus-1.7047",
91-
url => "https://www.cpan.org/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7047.tar.gz",
92-
sha256 => "963e63c6e1a8725ff2f624e9086396ae150db51dd0a337c3781d09a994af05a5",
88+
my %install_modules = (
89+
cpanm => {
90+
name => "App-cpanminus-1.7047",
91+
url => "https://www.cpan.org/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7047.tar.gz",
92+
# sha256 taken from http://www.cpan.org/authors/id/M/MI/MIYAGAWA/CHECKSUMS
93+
sha256 => "963e63c6e1a8725ff2f624e9086396ae150db51dd0a337c3781d09a994af05a5",
94+
},
95+
iosocketssl => {
96+
name => "IO-Socket-SSL-2.085",
97+
url => "https://www.cpan.org/authors/id/S/SU/SULLR/IO-Socket-SSL-2.085.tar.gz",
98+
# sha256 taken from http://www.cpan.org/authors/id/S/SU/SULLR/CHECKSUMS
99+
sha256 => "95b2f7c0628a7e246a159665fbf0620d0d7835e3a940f22d3fdd47c3aa799c2e",
100+
},
101+
netssleay => {
102+
name => "Net-SSLeay-1.94",
103+
url => "https://www.cpan.org/authors/id/C/CH/CHRISN/Net-SSLeay-1.94.tar.gz",
104+
# sha256 taken from http://www.cpan.org/authors/id/C/CH/CHRISN/CHECKSUMS
105+
sha256 => "9d7be8a56d1bedda05c425306cc504ba134307e0c09bda4a788c98744ebcd95d",
106+
},
93107
);
94108

95109
# sha256 checksum is from docker-perl team, cf https://github.com/docker-library/official-images/pull/12612#issuecomment-1158288299
@@ -148,8 +162,12 @@ sub die_with_sample {
148162
}
149163

150164
for my $build (keys %builds) {
151-
$release->{url} = $url;
152-
$release->{"cpanm_dist_$_"} = $cpanm{$_} for keys %cpanm;
165+
$release->{url} = $url;
166+
167+
for my $name (keys %install_modules) {
168+
my $module = $install_modules{$name};
169+
$release->{"${name}_dist_$_"} = $module->{$_} for keys %$module;
170+
}
153171
$release->{"cpm_dist_$_"} = $cpm{$_} for keys %cpm;
154172

155173
$release->{extra_flags} ||= '';
@@ -159,8 +177,7 @@ sub die_with_sample {
159177
for my $debian_release (@{$release->{debian_release}}) {
160178

161179
my $output = $template;
162-
$output =~ s/\{\{$_\}\}/$release->{$_}/mg
163-
for (qw(version pause extra_flags sha256 type url image cpanm_dist_name cpanm_dist_url cpanm_dist_sha256 cpm_dist_url cpm_dist_sha256));
180+
$output =~ s/\{\{$_\}\}/$release->{$_}/mg for keys %$release;
164181
$output =~ s/\{\{args\}\}/$builds{$build}/mg;
165182

166183
if ($build =~ /slim/) {
@@ -309,7 +326,12 @@ =head1 DESCRIPTION
309326
&& curl -fLO {{cpanm_dist_url}} \
310327
&& echo '{{cpanm_dist_sha256}} *{{cpanm_dist_name}}.tar.gz' | sha256sum --strict --check - \
311328
&& tar -xzf {{cpanm_dist_name}}.tar.gz && cd {{cpanm_dist_name}} && perl bin/cpanm . && cd /root \
312-
&& cpanm IO::Socket::SSL \
329+
&& curl -fLO '{{netssleay_dist_url}}' \
330+
&& echo '{{netssleay_dist_sha256}} *{{netssleay_dist_name}}.tar.gz' | sha256sum --strict --check - \
331+
&& cpanm --from $PWD {{netssleay_dist_name}}.tar.gz \
332+
&& curl -fLO '{{iosocketssl_dist_url}}' \
333+
&& echo '{{iosocketssl_dist_sha256}} *{{iosocketssl_dist_name}}.tar.gz' | sha256sum --strict --check - \
334+
&& SSL_CERT_DIR=/etc/ssl/certs cpanm --from $PWD {{iosocketssl_dist_name}}.tar.gz \
313335
&& curl -fL {{cpm_dist_url}} -o /usr/local/bin/cpm \
314336
# sha256 checksum is from docker-perl team, cf https://github.com/docker-library/official-images/pull/12612#issuecomment-1158288299
315337
&& echo '{{cpm_dist_sha256}} */usr/local/bin/cpm' | sha256sum --strict --check - \

0 commit comments

Comments
 (0)