Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sign.sh incorrectly uses relative path of nuget package instead of absolute path for signing operations #1478

Merged
merged 3 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/__tests__/signing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('with standard pipeline', () => {
{
Name: 'SCRIPT_S3_KEY',
Type: 'PLAINTEXT',
Value: '57b2661c55d0400ef7c5db10e1d13ea42db5520c0338de4ca7cf407f8cc325e2.zip',
Value: 'a04bdf56b18c26031d8d67e4d1f9acbd9f2f0126d20ae0bb88be1491f63b18bf.zip',
},
{
Name: 'SIGNING_BUCKET_NAME',
Expand Down Expand Up @@ -267,7 +267,7 @@ describe('with standard pipeline', () => {
{
Name: 'SCRIPT_S3_KEY',
Type: 'PLAINTEXT',
Value: '57b2661c55d0400ef7c5db10e1d13ea42db5520c0338de4ca7cf407f8cc325e2.zip',
Value: 'a04bdf56b18c26031d8d67e4d1f9acbd9f2f0126d20ae0bb88be1491f63b18bf.zip',
},
{
Name: 'SIGNING_BUCKET_NAME',
Expand Down
9 changes: 5 additions & 4 deletions lib/signing/nuget/sign.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ fi
found=false
for nuget_package_path in $(find dotnet -name *.nupkg -not -iname *.symbols.nupkg); do
found=true
echo "🔑 Applying authenticode signatures to assemblies in ${nuget_package_path}"
for file in $(unzip -Z1 ${nuget_package_path} '*.dll'); do
nuget_package=$(cd $(dirname ${nuget_package_path}) && echo $PWD)/$(basename ${nuget_package_path})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like what you're trying to do is make this path absolute.

Most Linuxes will have the tool realpath to do this (won't exist on Mac by default though), and according to StackOverflow you can use readlink -f <file> as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted - thanks for explaining that and showing me an alternative!

echo "🔑 Applying authenticode signatures to assemblies in ${nuget_package}"
for file in $(unzip -Z1 ${nuget_package} '*.dll'); do
echo "📄 Assembly: ${file}"
tmp=$(mktemp -d)
# extract the dll from the zip file
unzip -q ${nuget_package_path} -d ${tmp} ${file}
unzip -q ${nuget_package} -d ${tmp} ${file}
# need to set appropriate permissions, otherwise the file has none
chmod u+rw ${tmp}/${file}
# upload dll to signer bucket
Expand All @@ -50,7 +51,7 @@ for nuget_package_path in $(find dotnet -name *.nupkg -not -iname *.symbols.nupk
# replace the dll in the nuget package
(
cd ${tmp}
zip -qfr ${nuget_package_path} ${file}
zip -qfr ${nuget_package} ${file}
)
# clean up temporary directory
rm -rf ${tmp}
Expand Down