Skip to content

Disable fingerprint checking when storage is not available #3928

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

Merged
merged 1 commit into from
Dec 10, 2021

Conversation

yim-lee
Copy link
Contributor

@yim-lee yim-lee commented Dec 10, 2021

Motivation:

Source compat test failure: https://ci.swift.org/job/swift-PR-source-compat-suite/5701/artifact/swift-source-compat-suite/

error: Failed to get source control fingerprint for swift-log remoteSourceControl https://github.com/apple/swift-log.git version 1.4.2 from storage: Error Domain=NSCocoaErrorDomain Code=513 "You don't have permission to save the file "fingerprints" in the folder "security"." UserInfo={NSFilePath=/Users/buildnode/.swiftpm/security/fingerprints, NSUnderlyingError=0x7feaae439370 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
error: Error Domain=NSCocoaErrorDomain Code=513 "You don't have permission to save the file "fingerprints" in the folder "security"." UserInfo={NSFilePath=/Users/buildnode/.swiftpm/security/fingerprints, NSUnderlyingError=0x7feaae439370 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}

Modifications:

  • Make PackageFingerprintStorage optional in RegistryClient and SourceControlPackageContainer, which would turn off fingerprint read/write and essentially disable the TOFU feature.
  • SwiftTool will try to create the shared security directory (under which fingerprints are stored), and if it fails (e.g., permission errors) set PackageFingerprintStorage to none.
  • Don't perform integrity check on fingerprint write. The validation failure will happen on read.

@yim-lee
Copy link
Contributor Author

yim-lee commented Dec 10, 2021

@swift-ci please smoke test

Motivation:

Source compat test failure: https://ci.swift.org/job/swift-PR-source-compat-suite/5701/artifact/swift-source-compat-suite/

```
error: Failed to get source control fingerprint for swift-log remoteSourceControl https://github.com/apple/swift-log.git version 1.4.2 from storage: Error Domain=NSCocoaErrorDomain Code=513 "You don't have permission to save the file "fingerprints" in the folder "security"." UserInfo={NSFilePath=/Users/buildnode/.swiftpm/security/fingerprints, NSUnderlyingError=0x7feaae439370 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
error: Error Domain=NSCocoaErrorDomain Code=513 "You don't have permission to save the file "fingerprints" in the folder "security"." UserInfo={NSFilePath=/Users/buildnode/.swiftpm/security/fingerprints, NSUnderlyingError=0x7feaae439370 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
```

Modifications:
- Make `PackageFingerprintStorage` optional in `RegistryClient` and `SourceControlPackageContainer`, which would turn off fingerprint read/write and essentially disable the TOFU feature.
- `SwiftTool` will try to create the shared security directory (under which fingerprints are stored), and if it fails (e.g., permission errors) set `PackageFingerprintStorage` to none.
- Don't perform integrity check on fingerprint write. The validation failure will happen on read.
@yim-lee yim-lee force-pushed the fingerprint-storage-err branch from 877640a to 63d0de2 Compare December 10, 2021 20:15
@yim-lee
Copy link
Contributor Author

yim-lee commented Dec 10, 2021

@swift-ci please smoke test

@yim-lee yim-lee changed the title Fingerprint storage error handling Disable fingerprint checking when storage is not available Dec 10, 2021
@yim-lee yim-lee requested a review from neonichu December 10, 2021 20:16
completion(.success(checksum))
case .none:
case .failure(let error):
// Don't throw write errors
Copy link
Contributor

Choose a reason for hiding this comment

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

out of curiosity, why do we no longer throw in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We were doing two types of throw before:

  1. checksum has changed
  2. actual write failures (e.g., file system, serialization, etc.)

1 is sort of integrity check, and I think it's a bit strange to do it on a write operation when we are already doing it on read.

I suppose we can continue throwing 2 if that's the preference.

Copy link
Member

Choose a reason for hiding this comment

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

I'm seeing a failure in Swift CI due to the removed none case at https://ci.swift.org/job/swift-PR-Linux-smoke-test/31790/consoleFull#6525590103122a513-f36a-4c87-8ed7-cbc36a1ec144:

/home/buildnode/jenkins/workspace/swift-PR-Linux-smoke-test/branch-main/swiftpm/Tests/WorkspaceTests/RegistryPackageContainerTests.swift:421:39: error: type 'FingerprintCheckingMode' has no member 'none'
01:01:48             fingerprintCheckingMode: .none,
01:01:48                                      ~^~~~
01:01:48 error: fatalError

@yim-lee yim-lee merged commit e0b1bd2 into swiftlang:main Dec 10, 2021
@yim-lee yim-lee deleted the fingerprint-storage-err branch December 10, 2021 23:28
@tomerd
Copy link
Contributor

tomerd commented Dec 10, 2021

I suppose we can continue throwing 2 if that's the preference.

I think it would be good to throw in that case, follow up PR is fine, this is not urgent to fix

yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Dec 11, 2021
Per review feedback, reverting part of the changes introduced in swiftlang#3928.
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Dec 11, 2021
Per review feedback, reverting part of the changes introduced in swiftlang#3928.
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Dec 11, 2021
Motivation:
Source compat test continues to fail even with swiftlang#3928:

```
"You don’t have permission to save the file “fingerprints” in the folder “security”
```

https://ci.swift.org/job/swift-PR-source-compat-suite/5709/artifact/

Not sure how/why, but it seems like `security` directory is created just fine but not the `fingerprints` sub directory (`fingerprints` is a directory not a file, and the code add a file to the `fingerprints` dir for each downloaded package).

Modifications:
Test creating `fingerprints` directory instead of `security`, and if that fails, disable TOFU feature.
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Dec 12, 2021
Motivation:
Source compat test continues to fail even with swiftlang#3928:

```
"You don’t have permission to save the file “fingerprints” in the folder “security”
```

https://ci.swift.org/job/swift-PR-source-compat-suite/5709/artifact/

Not sure how/why, but it seems like `security` directory is created just fine but not the `fingerprints` sub directory (`fingerprints` is a directory not a file, and the code add a file to the `fingerprints` dir for each downloaded package).

Modifications:
Test creating `fingerprints` directory instead of `security`, and if that fails, disable TOFU feature.
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Dec 13, 2021
Motivation:
Source compat test continues to fail even with swiftlang#3928:

```
"You don’t have permission to save the file “fingerprints” in the folder “security”
```

https://ci.swift.org/job/swift-PR-source-compat-suite/5709/artifact/

The tests we did with swiftlang#3938 shows that we can create directories but not write files.

Modifications:
Test creating `security` directory and writing file in it, and disable TOFU feature if the test fails.
yim-lee added a commit that referenced this pull request Dec 14, 2021
Motivation:
Source compat test continues to fail even with #3928:

```
"You don’t have permission to save the file “fingerprints” in the folder “security”
```

https://ci.swift.org/job/swift-PR-source-compat-suite/5709/artifact/

The tests we did with #3938 shows that we can create directories but not write files.

Modifications:
Test creating `security` directory and writing file in it, and disable TOFU feature if the test fails.
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Dec 14, 2021
Per review feedback, reverting part of the changes introduced in swiftlang#3928.
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Dec 14, 2021
…ang#3941)

Motivation:
Source compat test continues to fail even with swiftlang#3928:

```
"You don’t have permission to save the file “fingerprints” in the folder “security”
```

https://ci.swift.org/job/swift-PR-source-compat-suite/5709/artifact/

The tests we did with swiftlang#3938 shows that we can create directories but not write files.

Modifications:
Test creating `security` directory and writing file in it, and disable TOFU feature if the test fails.
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Dec 14, 2021
Per review feedback, reverting part of the changes introduced in swiftlang#3928.
yim-lee added a commit that referenced this pull request Dec 14, 2021
Per review feedback, reverting part of the changes introduced in #3928.
yim-lee added a commit that referenced this pull request Dec 15, 2021
* Disable fingerprint checking when storage is not available

Motivation:

Source compat test failure: https://ci.swift.org/job/swift-PR-source-compat-suite/5701/artifact/swift-source-compat-suite/

```
error: Failed to get source control fingerprint for swift-log remoteSourceControl https://github.com/apple/swift-log.git version 1.4.2 from storage: Error Domain=NSCocoaErrorDomain Code=513 "You don't have permission to save the file "fingerprints" in the folder "security"." UserInfo={NSFilePath=/Users/buildnode/.swiftpm/security/fingerprints, NSUnderlyingError=0x7feaae439370 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
error: Error Domain=NSCocoaErrorDomain Code=513 "You don't have permission to save the file "fingerprints" in the folder "security"." UserInfo={NSFilePath=/Users/buildnode/.swiftpm/security/fingerprints, NSUnderlyingError=0x7feaae439370 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
```

Modifications:
- Make `PackageFingerprintStorage` optional in `RegistryClient` and `SourceControlPackageContainer`, which would turn off fingerprint read/write and essentially disable the TOFU feature.
- `SwiftTool` will try to create the shared security directory (under which fingerprints are stored), and if it fails (e.g., permission errors) set `PackageFingerprintStorage` to none.
- Don't perform integrity check on fingerprint write. The validation failure will happen on read.

* Throw fingerprint write errors

Per review feedback, reverting part of the changes introduced in #3928.

* Create 'security' directory test should try writing files too (#3941)

Motivation:
Source compat test continues to fail even with #3928:

```
"You don’t have permission to save the file “fingerprints” in the folder “security”
```

https://ci.swift.org/job/swift-PR-source-compat-suite/5709/artifact/

The tests we did with #3938 shows that we can create directories but not write files.

Modifications:
Test creating `security` directory and writing file in it, and disable TOFU feature if the test fails.

* Fix test that fails to compile (#3936)

Co-authored-by: Doug Gregor <[email protected]>
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.

4 participants