Merge branch 'workflow_permissions' into codeql_workflow

This commit is contained in:
Max Goedjen 2025-09-03 23:43:55 -07:00
commit ce98f7b0f8
No known key found for this signature in database
8 changed files with 56 additions and 24 deletions

View File

@ -7,7 +7,6 @@ on:
jobs: jobs:
build: build:
# runs-on: macOS-latest
runs-on: macos-15 runs-on: macos-15
permissions: permissions:
id-token: write id-token: write

View File

@ -6,7 +6,8 @@ on:
- '*' - '*'
jobs: jobs:
test: test:
# runs-on: macOS-latest permissions:
contents: read
runs-on: macos-15 runs-on: macos-15
timeout-minutes: 10 timeout-minutes: 10
steps: steps:
@ -25,12 +26,11 @@ jobs:
- name: Test - name: Test
run: swift test --build-system swiftbuild --package-path Sources/Packages run: swift test --build-system swiftbuild --package-path Sources/Packages
build: build:
# runs-on: macOS-latest
runs-on: macos-15
permissions: permissions:
id-token: write id-token: write
contents: write contents: write
attestations: write attestations: write
runs-on: macos-15
timeout-minutes: 10 timeout-minutes: 10
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v5

View File

@ -3,7 +3,8 @@ name: Test
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
test: test:
# runs-on: macOS-latest permissions:
contents: read
runs-on: macos-15 runs-on: macos-15
timeout-minutes: 10 timeout-minutes: 10
steps: steps:

View File

@ -133,20 +133,22 @@ private extension SocketPort {
convenience init(path: String) { convenience init(path: String) {
var addr = sockaddr_un() var addr = sockaddr_un()
addr.sun_family = sa_family_t(AF_UNIX)
var len: Int = 0 let length = withUnsafeMutablePointer(to: &addr.sun_path.0) { pointer in
withUnsafeMutablePointer(to: &addr.sun_path.0) { pointer in
path.withCString { cstring in path.withCString { cstring in
len = strlen(cstring) let len = strlen(cstring)
strncpy(pointer, cstring, len) strncpy(pointer, cstring, len)
return len
} }
} }
addr.sun_len = UInt8(len+2) // This doesn't seem to be _strictly_ neccessary with SocketPort.
// but just for good form.
addr.sun_family = sa_family_t(AF_UNIX)
// This mirrors the SUN_LEN macro format.
addr.sun_len = UInt8(MemoryLayout<sockaddr_un>.size - MemoryLayout.size(ofValue: addr.sun_path) + length)
var data: Data! let data = withUnsafePointer(to: &addr) { pointer in
withUnsafePointer(to: &addr) { pointer in Data(bytes: pointer, count: MemoryLayout<sockaddr_un>.size)
data = Data(bytes: pointer, count: MemoryLayout<sockaddr_un>.size)
} }
self.init(protocolFamily: AF_UNIX, socketType: SOCK_STREAM, protocol: 0, address: data)! self.init(protocolFamily: AF_UNIX, socketType: SOCK_STREAM, protocol: 0, address: data)!

View File

@ -9,4 +9,17 @@ extension URL {
static var socketPath: String { static var socketPath: String {
URL.agentHomeURL.appendingPathComponent("socket.ssh").path() URL.agentHomeURL.appendingPathComponent("socket.ssh").path()
} }
}
extension String {
var normalizedPathAndFolder: (String, String) {
// All foundation-based normalization methods replace this with the container directly.
let processedPath = replacingOccurrences(of: "~", with: "/Users/\(NSUserName())")
let url = URL(filePath: processedPath)
let folder = url.deletingLastPathComponent().path()
return (processedPath, folder)
}
} }

View File

@ -40,10 +40,7 @@ struct ConfigurationItemView<Content: View>: View {
.buttonStyle(.borderless) .buttonStyle(.borderless)
case .revealInFinder(let rawPath): case .revealInFinder(let rawPath):
Button(.revealInFinderButton, systemImage: "folder") { Button(.revealInFinderButton, systemImage: "folder") {
// All foundation-based normalization methods replace this with the container directly. let (processedPath, folder) = rawPath.normalizedPathAndFolder
let processedPath = rawPath.replacingOccurrences(of: "~", with: "/Users/\(NSUserName())")
let url = URL(filePath: processedPath)
let folder = url.deletingLastPathComponent().path()
NSWorkspace.shared.selectFile(processedPath, inFileViewerRootedAtPath: folder) NSWorkspace.shared.selectFile(processedPath, inFileViewerRootedAtPath: folder)
} }
.labelStyle(.iconOnly) .labelStyle(.iconOnly)

View File

@ -21,7 +21,7 @@ struct SecretDetailView<SecretType: Secret>: View {
CopyableView(title: .secretDetailPublicKeyLabel, image: Image(systemName: "key"), text: keyString) CopyableView(title: .secretDetailPublicKeyLabel, image: Image(systemName: "key"), text: keyString)
Spacer() Spacer()
.frame(height: 20) .frame(height: 20)
CopyableView(title: .secretDetailPublicKeyPathLabel, image: Image(systemName: "lock.doc"), text: publicKeyFileStoreController.publicKeyPath(for: secret)) CopyableView(title: .secretDetailPublicKeyPathLabel, image: Image(systemName: "lock.doc"), text: publicKeyFileStoreController.publicKeyPath(for: secret), showRevealInFinder: true)
Spacer() Spacer()
} }
} }

View File

@ -6,6 +6,7 @@ struct CopyableView: View {
var title: LocalizedStringResource var title: LocalizedStringResource
var image: Image var image: Image
var text: String var text: String
var showRevealInFinder = false
@State private var interactionState: InteractionState = .normal @State private var interactionState: InteractionState = .normal
@ -21,9 +22,12 @@ struct CopyableView: View {
.foregroundColor(primaryTextColor) .foregroundColor(primaryTextColor)
Spacer() Spacer()
if interactionState != .normal { if interactionState != .normal {
hoverIcon HStack {
.bold() if showRevealInFinder {
.textCase(.uppercase) revealInFinderButton
}
copyButton
}
.foregroundColor(secondaryTextColor) .foregroundColor(secondaryTextColor)
.transition(.opacity) .transition(.opacity)
} }
@ -72,11 +76,18 @@ struct CopyableView: View {
} }
@ViewBuilder @ViewBuilder
var hoverIcon: some View { var copyButton: some View {
switch interactionState { switch interactionState {
case .hovering: case .hovering:
Image(systemName: "document.on.document") Button(.copyableClickToCopyButton, systemImage: "document.on.document") {
.accessibilityLabel(String(localized: .copyableClickToCopyButton)) withAnimation {
// Button will eat the click, so we set interaction state manually.
interactionState = .clicking
}
copy()
}
.labelStyle(.iconOnly)
.buttonStyle(.borderless)
case .clicking: case .clicking:
Image(systemName: "checkmark.circle.fill") Image(systemName: "checkmark.circle.fill")
.accessibilityLabel(String(localized: .copyableCopied)) .accessibilityLabel(String(localized: .copyableCopied))
@ -85,6 +96,15 @@ struct CopyableView: View {
} }
} }
var revealInFinderButton: some View {
Button(.revealInFinderButton, systemImage: "folder") {
let (processedPath, folder) = text.normalizedPathAndFolder
NSWorkspace.shared.selectFile(processedPath, inFileViewerRootedAtPath: folder)
}
.labelStyle(.iconOnly)
.buttonStyle(.borderless)
}
var primaryTextColor: Color { var primaryTextColor: Color {
switch interactionState { switch interactionState {
case .normal, .hovering, .dragging: case .normal, .hovering, .dragging: