Skip to content

Include the filename in the zip data map key - #6317

Merged
mmitche merged 5 commits into
dotnet:masterfrom
mmitche:include-filename-in-zip-map-key
Oct 7, 2020
Merged

mmitche merged 5 commits into
dotnet:masterfrom
mmitche:include-filename-in-zip-map-key

Conversation

@mmitche

@mmitche mmitche commented Oct 2, 2020

Copy link
Copy Markdown
Member

.NET has a bunch of cases where symbol packages and non-symbol packages are identical.
This occurs when there are either no symbols in a symbol package (e.g. a sources package), and
cases where an original package also contains symbols. SignTool does not like this.

The primary issue is that the zip data map (for each container) only uses the content
hash as the key. This means that zip files with different file names will have the same content
hash and map to the same zip data. This is problematic because signing information can
be different based on filename. For example, we may choose to sign .nupkgs but not
the corresponding .symbol.nupkg. If the content hash is the key for the zip data map,
then the .symbol.nupkg and .nupkg are de-duplicated and the file signing information we choose to use
is arbitrary.

To fix this, use the file name in the zip map key, like we do file the map of files to their signed data.

.NET has a bunch of cases where symbol packages and non-symbol packages are identical.
This occurs when there are either no symbols in a symbol package (e.g. a sources package), and
cases where an original package also contains symbols. SignTool does not like this.

The primary issue is that the zip data map (for each container) only uses the content
hash as the key. This means that zip files with different file names will have the same content
hash and map to the same zip data. This is problematic because signing information can
be **different** based on filename. For example, we may choose to sign .nupkgs but not
the corresponding .symbol.nupkg. If the content hash is the key for the zip data map,
then the .symbol.nupkg and .nupkg are de-duplicated and the file signing information we choose to use
is arbitrary.

To fix this, use the file name in the zip map key, like we do file the map of files to their signed data.
if (fileSignInfo.IsContainer())
{
if (_zipDataMap.ContainsKey(contentHash))
/*if (_zipDataMap.ContainsKey(contentHash))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did you intend to delete this block post-validation?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah....I wanted to remind myself of this bit until I'm sure it can go. I'm about 90% sure of this fix though.

@mmitche
mmitche merged commit fa16854 into dotnet:master Oct 7, 2020
@mmitche
mmitche deleted the include-filename-in-zip-map-key branch October 7, 2020 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants