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

Added SSH Key comment field and fixed build for other users #190

Closed
wants to merge 11 commits into from

Conversation

lavalleeale
Copy link
Contributor

No description provided.

@@ -9,6 +9,7 @@ protocol AgentStatusCheckerProtocol: ObservableObject {
class AgentStatusChecker: ObservableObject, AgentStatusCheckerProtocol {

@Published var running: Bool = false
let bundleID = Bundle.main.bundleIdentifier!.replacingOccurrences(of: "Host", with: "SecretAgent")
Copy link
Owner

Choose a reason for hiding this comment

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

Overall big 👍 these changes.
This doesn't really need to be a property on the class though I don't think, you can just move this into the secretAgentProcesses block.

Copy link
Owner

Choose a reason for hiding this comment

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

Bundle.main.bundleIdentifier!.replacingOccurrences(of: "Host", with: "SecretAgent") this bit is repeated a couple times – might make sense to have a Bundle extension in SecretKit with like hostBundleID and agentBundleID properties.

@@ -4,7 +4,8 @@ import AppKit
import OSLog

struct LaunchAgentController {


let bundleID = Bundle.main.bundleIdentifier!.replacingOccurrences(of: "Host", with: "SecretAgent")
Copy link
Owner

Choose a reason for hiding this comment

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

Same here.

Copy link
Owner

@maxgoedjen maxgoedjen left a comment

Choose a reason for hiding this comment

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

Hey @lavalleeale – thanks for the PR, sorry it took me so long to review.

Overall got some good changes – I think there might be a better storage strategy possible that we should experiment with though.

@State private var name = ""
@State private var requiresAuthentication = true
let defaults = UserDefaults.standard
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not crazy about having this info stored in UserDefaults/View tbh, particularly for the SEP keys.

My inclination would be to add a kSecAttrComment at the key creation

and read that out into a new property on Secret

Copy link
Owner

Choose a reason for hiding this comment

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

(disclaimer: I haven't personally tested this yet so it might run into some issues, the SEP can be a bit weird that way sometimes)

We'll probably also need to figure out an approach for SmartCards.

@@ -9,6 +9,7 @@ protocol AgentStatusCheckerProtocol: ObservableObject {
class AgentStatusChecker: ObservableObject, AgentStatusCheckerProtocol {

@Published var running: Bool = false
let bundleID = Bundle.main.bundleIdentifier!.replacingOccurrences(of: "Host", with: "SecretAgent")
Copy link
Owner

Choose a reason for hiding this comment

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

Bundle.main.bundleIdentifier!.replacingOccurrences(of: "Host", with: "SecretAgent") this bit is repeated a couple times – might make sense to have a Bundle extension in SecretKit with like hostBundleID and agentBundleID properties.


func save() {
try! store.create(name: name, requiresAuthentication: requiresAuthentication)
if comment != "" {
defaults.set(comment, forKey: name)
Copy link
Owner

Choose a reason for hiding this comment

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

Having the comment be the default is nice 👍
(when we switch to the comment being on the keychain entry, I think it probably makes sense to just to do this at view time, and not bake it in to the stored secret. This will make it nicer if the user changes their username, or has secrets created before this).

@vladimyr
Copy link
Contributor

@maxgoedjen I believe you tagged the wrong guy 😉

@maxgoedjen
Copy link
Owner

@vladimyr betrayed by autocomplete!
image

@lavalleeale
Copy link
Contributor Author

Hey, maybe I just read wrong, but I was under the impression that kSecAttrComment could not be changed after it was set. Obviously this PR doesn't let you change the comment later, but that might be a good idea down the road.

Copy link
Contributor Author

@lavalleeale lavalleeale left a comment

Choose a reason for hiding this comment

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

Hey, I changed it to being an extension

@maxgoedjen
Copy link
Owner

Hey, maybe I just read wrong, but I was under the impression that kSecAttrComment could not be changed after it was set. Obviously this PR doesn't let you change the comment later, but that might be a good idea down the road.

I'm not sure about that tbh, you could be right there. I'm not terribly concerned with that if it is the case tho, since keys are basically immutable as is.

@maxgoedjen
Copy link
Owner

@lavalleeale looks like unit tests failed to build

1366
Test session results, code coverage, and logs:
1367
	Value of type 'Bundle' has no member 'agentBundleID'
1368
	/Users/runner/Library/Developer/Xcode/DerivedData/Secretive-acdauzrjufafyfgbbuwlkimwgdpy/Logs/Test/Test-Secretive-2020.12.28_02-41-23-+0000.xcresult
1369
	Value of type 'Bundle' has no member 'agentBundleID'
1370

1371
	Value of type 'Bundle' has no member 'agentBundleID'
1372
	Testing cancelled because the build failed.
1373

Comment on lines 1 to 8
//
// bundleIDs.swift
// SecretKit
//
// Created by Alex lavallee on 12/27/20.
// Copyright © 2020 Max Goedjen. All rights reserved.
//

Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
//
// bundleIDs.swift
// SecretKit
//
// Created by Alex lavallee on 12/27/20.
// Copyright © 2020 Max Goedjen. All rights reserved.
//

@lavalleeale
Copy link
Contributor Author

Sorry about that, TIL that Xcode stores a reference of all the files in the project in the same file where it stores signing data

@maxgoedjen
Copy link
Owner

All good, I miss it about half the time myself ;)

@lavalleeale
Copy link
Contributor Author

So is there anything else in the PR that you want me to fix?

@maxgoedjen
Copy link
Owner

Hey @lavalleeale – sorry to be a bummer about this but I'm still pretty uncomfortable about storing metadata like this outside of the SEP. If we can find a way to remedy that I'd be receptive to a PR along those lines. (I'd also still gratefully merge the changes you made to the project to simplify signing/bundle IDs, if you'd be willing to split that out into a separate PR).

@maxgoedjen
Copy link
Owner

I sketched out a few ideas we might be able to use to address this in #201 – it's probably a nontrivial amount of work so don't feel obligated to take it on yourself, I'll take a look at implementing for probably ~2.2.0 or so.

@lavalleeale
Copy link
Contributor Author

I'll take a look at the metadata idea, but comments are a part of the public key, which should be fine if it is public, right?

@maxgoedjen
Copy link
Owner

comments are a part of the public key, which should be fine if it is public, right?

To an extent. Like if you were looking at my keys on https://github.com/maxgoedjen.keys it's fine that you see the comments there. Having the comments be in a non-locked-down area like user defaults can potentially leak what services you're using (ie, another process could see that I use GitHub, that I have another Mac named XYZ, etc) which IMO somewhat violates the security expectations people have of the app.

@lavalleeale
Copy link
Contributor Author

I'm just saying that the last field in the public key is the comment, maybe specify it is part of the public key?

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