-
-
Notifications
You must be signed in to change notification settings - Fork 57
Crash when using Secure Input in Docker container for custom Vapor Command #184
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When using the secure input within ConsoleKit, app crashes with Trace/breakpoint trap error.
To Reproduce
Simplified version of my code that produces error within Docker but NOT on macOS.
struct CreateUserCommand: Command {
struct Signature: CommandSignature {
@Argument(name: "username")
var username: String
}
var help: String {
NSLocalizedString("Create a new user with the provided email address.", comment: "")
}
func run(using context: ConsoleKit.CommandContext, signature: Signature) throws {
context.console.print("We're about to setup a new user using the username `\(signature.username)`.")
let firstName: String = context.console.ask("User's First Name: ")
let lastName: String = context.console.ask("User's Last Name: ")
let emailAddress: String = context.console.ask("E-Mail Address: ")
// Crashes right after this displays.
let password: String = context.console.ask("Password: ", isSecure: true)
let passwordConfirmation: String = context.console.ask("Confirm Password: ", isSecure: true)
}
}Steps to reproduce the behavior:
- Default Vapor app with latest versions as of 8/27/2023
- Run command
swift run App createUser userNameand follow prompts - Crashes once reaches the secure input.
Expected behavior
To not crash and accept secure input.
Environment
FROM swift:5.8-jammy as build
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
&& apt-get -q update \
&& apt-get -q dist-upgrade -y \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
COPY ./Package.* ./
RUN swift package resolve
COPY . .
RUN swift build -c release --static-swift-stdlib
WORKDIR /staging
RUN cp "$(swift build --package-path /build -c release --show-bin-path)/App" ./
RUN find -L "$(swift build --package-path /build -c release --show-bin-path)/" -regex '.*\.resources$' -exec cp -Ra {} ./ \;
RUN [ -d /build/Public ] && { mv /build/Public ./Public && chmod -R a-w ./Public; } || true
RUN [ -d /build/Resources ] && { mv /build/Resources ./Resources && chmod -R a-w ./Resources; } || true
FROM ubuntu:jammy
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
&& apt-get -q update \
&& apt-get -q dist-upgrade -y \
&& apt-get -q install -y \
ca-certificates \
tzdata \
&& rm -r /var/lib/apt/lists/*
RUN useradd --user-group --create-home --system --skel /dev/null --home-dir /app vapor
WORKDIR /app
COPY --from=build --chown=vapor:vapor /staging /app
USER vapor:vapor
EXPOSE 8080
ENTRYPOINT ["./App"]
CMD ["serve", "--env", "production", "--hostname", "0.0.0.0", "--port", "8080"]Package.swift
// swift-tools-version:5.8
import PackageDescription
let package = Package(
name: "FASAAPI",
platforms: [
.macOS(.v13)
],
dependencies: [
.package(url: "https://github.com/vapor/vapor.git", from: "4.0.0"),
.package(url: "https://github.com/vapor/fluent.git", from: "4.0.0"),
.package(url: "https://github.com/vapor/fluent-postgres-driver.git", from: "2.0.0"),
.package(url: "https://github.com/vapor/leaf.git", from: "4.0.0"),
.package(url: "https://github.com/swift-server-community/SwiftPrometheus.git", from: "1.0.0"),
.package(url: "https://github.com/vapor-community/sendgrid.git", from: "5.0.0"),
.package(url: "https://github.com/DiscordBM/DiscordBM", from: "1.0.0"),
.package(url: "https://github.com/DiscordBM/DiscordLogger", from: "1.0.0-beta.1"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.9.0"),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.1.0")
],
targets: [
.executableTarget(
name: "App",
dependencies: [
.product(name: "Fluent", package: "fluent"),
.product(name: "FluentPostgresDriver", package: "fluent-postgres-driver"),
.product(name: "Leaf", package: "leaf"),
.product(name: "Vapor", package: "vapor"),
.product(name: "SwiftPrometheus", package: "SwiftPrometheus"),
.product(name: "SendGrid", package: "sendgrid"),
.product(name: "DiscordBM", package: "DiscordBM"),
.product(name: "DiscordLogger", package: "DiscordLogger"),
.product(name: "Logging", package: "swift-log"),
.product(name: "AsyncHTTPClient", package: "async-http-client")
],
swiftSettings: [
.enableUpcomingFeature("StrictConcurrency"),
.enableUpcomingFeature("ConciseMagicFile"),
.enableUpcomingFeature("BareSlashRegexLiterals"),
.enableUpcomingFeature("ForwardTrailingClosures"),
.enableUpcomingFeature("ExistentialAny"),
.unsafeFlags(["-cross-module-optimization"], .when(configuration: .release))
]
),
.testTarget(name: "AppTests", dependencies: [
.target(name: "App"),
.product(name: "XCTVapor", package: "vapor")
])
]
)Additional context
Oddly all tests pass within CI/CD system but this command fails when ran from a Docker terminal.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working