Harden security posture with Keychain secrets, image vuln scanning, runtime security visibility, and action audit trail - #14
Merged
Conversation
…sibility Co-authored-by: djpfs <43576725+djpfs@users.noreply.github.com>
Co-authored-by: djpfs <43576725+djpfs@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add secrets management and vulnerability scanning
Harden security posture with Keychain secrets, image vuln scanning, runtime security visibility, and action audit trail
Aug 14, 2026
djpfs
marked this pull request as ready for review
August 14, 2026 03:14
djpfs
approved these changes
Aug 14, 2026
Co-authored-by: djpfs <43576725+djpfs@users.noreply.github.com>
djpfs
approved these changes
Aug 14, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds end-to-end security features across the CLI shim, compose orchestrator, runtime backend, and UI: Keychain-backed secrets, Trivy-based image scanning, surfaced container privilege/security metadata, and persistent JSONL audit logging.
Changes:
- Introduces Keychain-backed secret CRUD (
docker secret ...) andkeychain://NAMEenvironment resolution fordocker runand compose. - Adds image vulnerability scanning (
docker scan) backed by a Trivy JSON parser and anImageService.scan(...)API. - Adds runtime security/audit visibility via new container security fields and a persistent
AuditLoggerrecording key operations.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/DockerShimTests/DockerShimTests.swift | Adds parser tests for docker secret create and docker scan --severity. |
| Tests/ContainerBackendTests/ContainerBackendTests.swift | Adds tests for keychain env resolution, missing-secret error, Trivy JSON parsing, and config defaults. |
| Tests/ComposeEngineTests/ComposeEngineTests.swift | Adds compose parsing coverage for privileged/capabilities/security options. |
| Sources/ContainerBackend/VulnerabilityScanner.swift | Implements Trivy-backed scan execution and JSON parsing into structured findings. |
| Sources/ContainerBackend/Models/ContainerConfiguration.swift | Extends container config model with privileged and securityOptions with decoding defaults. |
| Sources/ContainerBackend/KeychainSecretStore.swift | Adds Keychain-backed secret CRUD plus fallback storage and env reference resolver. |
| Sources/ContainerBackend/ImageService.swift | Wires vulnerability scanning and adds audit events to image operations. |
| Sources/ContainerBackend/ContainerService.swift | Adds shared audit logging to container/network/volume operations and exposes secret store. |
| Sources/ContainerBackend/AuditLogger.swift | Adds persistent JSONL audit logger actor (~/.macker/audit.jsonl). |
| Sources/ComposeEngine/Models/ComposeModels.swift | Adds compose security_opt model support. |
| Sources/ComposeEngine/ComposeOrchestrator.swift | Resolves keychain:// envs and propagates privileged/security options into runtime config. |
| Sources/AppleDockerCLI/DockerShim/DockerTranslator.swift | Adds docker scan and docker secret execution paths and wires security flags into run config. |
| Sources/AppleDockerCLI/DockerShim/DockerCommand.swift | Registers scan/secret flags and help routing in the parser. |
| Sources/AppleDockerApp/Views/ContainerDetailView.swift | Surfaces privileged/read-only/capabilities/security options in the UI “Security” section. |
| README.md | Documents Keychain-backed secret usage. |
| docs/SECURITY.md | Documents secret handling, scanning, and audit log location/behavior. |
| docs/COMMANDS.md | Adds scan and secret commands to the command reference table. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+172
to
+176
| private var fallbackURL: URL { | ||
| FileManager.default.homeDirectoryForCurrentUser | ||
| .appendingPathComponent(".macker", isDirectory: true) | ||
| .appendingPathComponent("secrets-\(serviceName).json") | ||
| } |
Comment on lines
360
to
364
| let containers = try await listContainers(filters: .all) | ||
| if let builder = containers.first(where: { $0.id == "buildkit" }) { | ||
| try await deleteContainer(id: builder.id, force: true) | ||
| await auditLogger.record(action: "cleanup.deleteBuildkitBuilder", target: "buildkit", succeeded: true) | ||
| } |
| default: | ||
| throw DockerShimError.unsupportedCommand("secret \(command.subSubcommand ?? "")") | ||
| } | ||
| await auditLogger.record(action: action, target: command.arguments.first, succeeded: true) |
Comment on lines
+583
to
+591
| let names = command.arguments | ||
| guard !names.isEmpty else { throw DockerShimError.missingArgument("SECRET_NAME") } | ||
| let existing = Set(try service.secrets.listSecretNames()) | ||
| for name in names where !existing.contains(name) { | ||
| throw BackendError.notFound("secret '\(name)'") | ||
| } | ||
| let payload = names.map { ["Name": $0] } | ||
| let data = try JSONSerialization.data(withJSONObject: payload, options: [.prettyPrinted, .sortedKeys]) | ||
| print(String(decoding: data, as: UTF8.self)) |
Comment on lines
89
to
+92
| "image pull failed: \(result.stderr.trimmingCharacters(in: .whitespacesAndNewlines))" | ||
| ) | ||
| } | ||
| await auditLogger.record(action: "image.pull", target: reference, succeeded: true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change addresses four security gaps in the runtime/CLI surface: secret handling, image vulnerability visibility, container privilege/capability visibility, and operation auditing. It adds first-class security primitives without changing the core orchestration model.
Keychain-backed secret management
KeychainSecretStorefor secret CRUD.docker secret ls|create|inspect|rmin the shim.keychain://<name>env reference resolution in bothdocker runand compose service config assembly.Image vulnerability scanning
VulnerabilityScanner(Trivy JSON parser) andImageService.scan(...).docker scan <image>with severity filtering and optional JSON output.Runtime security metadata surfaced end-to-end
ContainerConfigurationwithprivilegedandsecurityOptions.--privileged,--cap-add,--cap-drop,--security-opt,--read-only,--shm-size,--stop-signalfrom CLI into runtime config.security_optsupport and propagated privilege/security fields into container config.ContainerDetailView(Security section).Action audit trail
AuditLoggerwriting JSONL to~/.macker/audit.jsonl.Documentation updates
docker scananddocker secretcommands.