Skip to content

Commit 54720b2

Browse files
committed
Verify artifact attestations for sass-embedded prebuilt gems
1 parent 8e19eaa commit 54720b2

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

ext/sass/Rakefile

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,13 @@ rescue NotImplementedError
4545
end
4646

4747
file 'dart-sass/sass' do
48-
gem_install 'sass-embedded', SassConfig.gem_version, SassConfig.gem_platform do |dir|
49-
mv File.absolute_path('ext/sass/dart-sass', dir), 'dart-sass'
48+
gem_install 'sass-embedded', SassConfig.gem_version, SassConfig.gem_platform do |installer|
49+
gh_attestation_verify(installer.gem, 'sass-contrib/sass-embedded-host-ruby')
50+
mv File.absolute_path('ext/sass/dart-sass', installer.gem_dir), 'dart-sass'
5051
end
5152
rescue StandardError
5253
archive = fetch(SassConfig.dart_sass)
53-
if SassConfig.development? && system('gh', 'auth', 'status', '--hostname', 'github.com', %i[out err] => File::NULL)
54-
sh 'gh', 'attestation', 'verify', archive, '--hostname', 'github.com', '--repo', 'sass/dart-sass'
55-
end
54+
gh_attestation_verify(archive, 'sass/dart-sass')
5655
unarchive archive
5756
rm archive
5857
end
@@ -424,10 +423,16 @@ module FileUtils
424423
installer.install
425424
end
426425

427-
yield installer.dir
426+
yield installer
428427
ensure
429428
rm_rf install_dir unless Rake::FileUtilsExt.nowrite_flag
430429
end
430+
431+
def gh_attestation_verify(path, repo)
432+
if SassConfig.development? && system('gh', 'auth', 'status', '--hostname', 'github.com', %i[out err] => File::NULL)
433+
sh 'gh', 'attestation', 'verify', path, '--hostname', 'github.com', '--repo', repo
434+
end
435+
end
431436
end
432437

433438
# The {Platform} module.

0 commit comments

Comments
 (0)