-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Track sourceLink and resources in deterministic key #81629
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: jcouv <12466233+jcouv@users.noreply.github.com>
Co-authored-by: jcouv <12466233+jcouv@users.noreply.github.com>
Co-authored-by: jcouv <12466233+jcouv@users.noreply.github.com>
|
@copilot CI produced |
Co-authored-by: jcouv <12466233+jcouv@users.noreply.github.com>
Fixed in 08c5f38. Removed the unused Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot |
Co-authored-by: jcouv <12466233+jcouv@users.noreply.github.com>
Fixed in e4530d3. Removed the redundant Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot We should care about the ruleset contents, not just the path to the ruleset file |
Co-authored-by: jcouv <12466233+jcouv@users.noreply.github.com>
Fixed in 2fac371. Changed from tracking ruleset file path to tracking ruleset content with checksum (similar to source link). The ruleset file is now opened and read as SourceText, with its checksum written to Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot Remove IsEmbedded. It is redundant with FileName and we need FileName for non-embedded scenarios |
Co-authored-by: jcouv <12466233+jcouv@users.noreply.github.com>
|
@copilot We don't need to include ruleSet in the key after all since it can only affect the compilation output via GeneralDiagnosticOption and SpecificDiagnosticOptions. Both of those are already included in the key. |
Co-authored-by: jcouv <12466233+jcouv@users.noreply.github.com>
Fixed in 0e564a1. Removed ruleSet tracking from the deterministic key. As you noted, rulesets only affect compilation output via Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot Let's update the added test for resources to include a non-public resource and a non-embedded resource. |
Co-authored-by: jcouv <12466233+jcouv@users.noreply.github.com>
Fixed in 59233c9. Enhanced the Resources test to include:
Added RuleSetChangesDoNotAffectKey test demonstrating that the deterministic key is based on the diagnostic options (GeneralDiagnosticOption and SpecificDiagnosticOptions) rather than ruleset file content, since those options are already tracked in the key. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
| static Span<byte> computeChecksum(ResourceDescription resource) | ||
| { | ||
| using var stream = resource.DataProvider(); | ||
| using var hashAlgorithm = System.Security.Cryptography.SHA256.Create(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 sourceText.GetChecksum (in WriteSourceText) uses either SHA1 or SHA256. I figured it's okay to align with that for now, but we should consider moving to XXHASH at some point #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key file should use the same checksum for all entries. This is effectively a merkle tree and the checksums should be uniform throughout it. This guarantees that the file has the same efficacy irrespective of what compiler options are used.
we should consider moving to XXHASH at some point
Disagree. The intent of these checksums is to provide uniqueness and that is one of the valid uses of crypto. The code here should just use the default crypto algorithm for all entries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If xxhash128 does not sufficiently ensure uniqueness for our purposes, then, I would recommend just using SHA512 here now to minimize our future compliance burden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key file should use the same checksum for all entries.
This is already not the case. Each syntax tree can use its own checksum algorithm. Added a test to illustrate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't hard code any crypto hash algorithm, that is how we get into compliance problems. Eventually all hash algorithms are broken and it turns into a security problem. Use SourceHashAlgorithms.Default instead where we centrally control the hash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each syntax tree can use its own checksum algorithm.
Believe that was done for expediency. Overall, we should be using the same hash. Other wise some enries are stronger than others.
| using var stream = resource.DataProvider(); | ||
| var sourceText = SourceText.From(stream, encoding: null, checksumAlgorithm: SourceHashAlgorithms.Default); | ||
| WriteSourceText(writer, sourceText); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you converting to a SourceText here? These resources are generally treated as binary blobs in the codebase. My intuition would be that we just grab the raw Stream or byte[] and hash that. Not sure if we'd hit weird edge cases trying to view a binary as a source text.
This PR adds tracking for source link files and resources to the compiler's deterministic key file to ensure all compilation inputs that affect reproducible builds are properly tracked. The implementation includes calculating checksums for source link content and manifest resources (tracking name, fileName, isPublic, and content checksum), while ruleset tracking was deemed unnecessary since rulesets only affect compilation through diagnostic options that are already being tracked.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.