-
Notifications
You must be signed in to change notification settings - Fork 41
Add implementation of PicoD #65
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
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
028c53b
Add implementation of PicoD
acsoto 7da4b77
Add Dockerfile for PicoD
acsoto 057e330
Refactor bootstrap key handling to use byte slices instead of strings
acsoto 85780c1
Add multi-architecture support to Dockerfile
acsoto ea374e3
Refactor handlers to use method receivers and update authentication m…
acsoto 28cb092
Refactor command execution to use context with timeout and improve er…
acsoto c7c8c32
Refactor command execution to accept a slice of strings for commands …
acsoto 3455748
Sanitize working directory input in execute
acsoto b308528
Refactor AuthManager to improve public key handling and ensure thread…
acsoto a5afa76
Ensures the file is created with the correct permissions atomically, …
acsoto 5f5f0b1
Improve error handling in LoadBootstrapKey and enhance test utility f…
acsoto b3e8e90
Enhance security
acsoto 11ee51d
Fix lint
acsoto bfa1142
Ensuring stderr is formatted correctly in execute.go
acsoto 68e9eb6
Refactor authentication middleware
acsoto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "flag" | ||
| "log" | ||
| "os" | ||
|
|
||
| "github.com/volcano-sh/agentcube/pkg/picod" | ||
| ) | ||
|
|
||
| func main() { | ||
| port := flag.Int("port", 8080, "Port for the PicoD server to listen on") | ||
| bootstrapKeyFile := flag.String("bootstrap-key", "/etc/picod/public-key.pem", "Path to the bootstrap public key file") | ||
| workspace := flag.String("workspace", "", "Root directory for file operations (default: current working directory)") | ||
| flag.Parse() | ||
|
|
||
| // Read bootstrap key from file | ||
| var bootstrapKey []byte | ||
| if data, err := os.ReadFile(*bootstrapKeyFile); err == nil { | ||
| bootstrapKey = data | ||
| } else { | ||
| log.Fatalf("Failed to read bootstrap key from %s: %v", *bootstrapKeyFile, err) | ||
| } | ||
|
|
||
| config := picod.Config{ | ||
| Port: *port, | ||
| BootstrapKey: bootstrapKey, | ||
| Workspace: *workspace, | ||
| } | ||
|
|
||
| // Create and start server | ||
| server := picod.NewServer(config) | ||
|
|
||
| if err := server.Run(); err != nil { | ||
| log.Fatalf("Failed to start server: %v", err) | ||
| } | ||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Build stage | ||
| FROM golang:1.24.4 AS builder | ||
|
|
||
| # Build arguments for multi-architecture support | ||
| ARG TARGETOS=linux | ||
| ARG TARGETARCH | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY go.mod go.sum ./ | ||
| RUN go mod download | ||
|
|
||
| COPY . . | ||
|
|
||
| RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -installsuffix cgo -o picod ./cmd/picod | ||
|
|
||
| # Run stage | ||
| FROM ubuntu:24.04 | ||
|
|
||
| # Install Python3 to support code execution tasks (Code Interpreter) | ||
| RUN apt-get update && apt-get install -y python3 | ||
|
|
||
| # Use /root/ as the working directory | ||
| # We run as root to allow 'chattr +i' on the public key file (see pkg/picod/auth.go) | ||
| # and to ensure sufficient permissions for arbitrary code execution within the sandbox. | ||
| WORKDIR /root/ | ||
acsoto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| COPY --from=builder /app/picod . | ||
|
|
||
acsoto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ENTRYPOINT ["./picod"] | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.