-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Port contents of Documentation/PackageSecurity.md
to DocC
#8726
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
@swift-ci please test |
@swift-ci please test |
@swift-ci please test windows |
@swift-ci please test windows platform self hosted |
@@ -0,0 +1,50 @@ | |||
# Package Security | |||
|
|||
Learn about the security features that SwiftPM implements. |
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.
Learn about the security features that SwiftPM implements. | |
Learn about the security features that the package manager implements. |
(I've been taking to removing SwiftPM
and replacing it with "package manager")
|
||
## Trust on First Use | ||
|
||
SwiftPM records **fingerprints** of downloaded package versions so that |
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.
SwiftPM records **fingerprints** of downloaded package versions so that | |
Package manager records **fingerprints** of downloaded package versions so that |
SwiftPM records **fingerprints** of downloaded package versions so that | ||
it can perform [trust-on-first-use](https://en.wikipedia.org/wiki/Trust_on_first_use) | ||
(TOFU). | ||
That is, when a package version is downloaded for the first time, SwiftPM trusts that |
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.
That is, when a package version is downloaded for the first time, SwiftPM trusts that | |
That is, when a package version is downloaded for the first time, the package manager trusts that |
it has downloaded the correct contents and requires subsequent downloads of the same | ||
package version to have the same fingerprint. | ||
If the fingerprint changes, it might be an indicator that the package has been | ||
compromised and SwiftPM will either warn or return an error. |
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.
compromised and SwiftPM will either warn or return an error. | |
compromised and the package manager either warns or returns an error. | |
Control the choice of warning or error using the build option `--resolver-fingerprint-checking`, which defaults to `strict`. | |
Set the value to `warn` to not error on a mismatched fingerprint. |
| Git repository | Git hash of the revision | | ||
| Package registry | Checksum of the source archive | | ||
|
||
All version fingerprints of a package are kept in a single file |
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.
All version fingerprints of a package are kept in a single file | |
The package manager keeps version fingerprints for each package in a file |
|
||
All version fingerprints of a package are kept in a single file | ||
under the `~/.swiftpm/security/fingerprints` directory. | ||
- For a Git repository package, the fingerprint filename takes the form of `{PACKAGE_NAME}-{REPOSITORY_URL_HASH}.json` (e.g., `LinkedList-5ddbcf15.json`). |
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.
- For a Git repository package, the fingerprint filename takes the form of `{PACKAGE_NAME}-{REPOSITORY_URL_HASH}.json` (e.g., `LinkedList-5ddbcf15.json`). | |
- For a Git repository package, the fingerprint filename takes the form of `{PACKAGE_NAME}-{REPOSITORY_URL_HASH}.json` (such as `LinkedList-5ddbcf15.json`). |
All version fingerprints of a package are kept in a single file | ||
under the `~/.swiftpm/security/fingerprints` directory. | ||
- For a Git repository package, the fingerprint filename takes the form of `{PACKAGE_NAME}-{REPOSITORY_URL_HASH}.json` (e.g., `LinkedList-5ddbcf15.json`). | ||
- For a registry package, the fingerprint filename takes the form of `{PACKAGE_ID}.json` (e.g., `mona.LinkedList.json`). |
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.
- For a registry package, the fingerprint filename takes the form of `{PACKAGE_ID}.json` (e.g., `mona.LinkedList.json`). | |
- For a registry package, the fingerprint filename takes the form of `{PACKAGE_ID}.json` (such as `mona.LinkedList.json`). |
under the `~/.swiftpm/security/fingerprints` directory. | ||
- For a Git repository package, the fingerprint filename takes the form of `{PACKAGE_NAME}-{REPOSITORY_URL_HASH}.json` (e.g., `LinkedList-5ddbcf15.json`). | ||
- For a registry package, the fingerprint filename takes the form of `{PACKAGE_ID}.json` (e.g., `mona.LinkedList.json`). | ||
|
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.
For packages retrieved from a registry, the package manager expects all registries to provide consistent fingerprints for packages they host. | |
If registries have conflicting fingerprints, package manager reports that as an error. |
- For a registry package, the fingerprint filename takes the form of `{PACKAGE_ID}.json` (e.g., `mona.LinkedList.json`). | ||
|
||
|
||
### Using fingerprints for TOFU |
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.
Everything from line 30 (heading included) is replicated content from above - I made some suggestions to cherry pick a few details in the content above, and I think everything below can be deleted. Give it a read through and verify though.
Fixes #8591
Ports the contents of
Documentation/PackageSecurity.md
to our DocC catalog inSources/PackageManagerDocs/PackageSecurity.md
.