- 
                Notifications
    
You must be signed in to change notification settings  - Fork 2.9k
 
adding support for execution in docker #6549
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
base: dev
Are you sure you want to change the base?
Conversation
          
WalkthroughDocker sandbox support is introduced for code execution with new Sandbox configuration type. Integration tests for virtual environments are added with Linux-only gates. Dependencies are updated, including OpenTelemetry to v1.38.0 and golang.org/x/time to v0.14.0. Changes
 Sequence Diagram(s)sequenceDiagram
    participant Client
    participant Request
    participant useSandbox
    participant Eval
    participant EvalWithVirtualEnv
    
    Client->>Request: Execute Code
    Request->>useSandbox: Check if sandbox configured
    
    alt Sandbox Enabled
        useSandbox-->>Request: true
        Request->>EvalWithVirtualEnv: Execute with Docker<br/>(WorkingDir, Image)
        EvalWithVirtualEnv-->>Request: Result
    else Sandbox Disabled
        useSandbox-->>Request: false
        Request->>Eval: Execute normally
        Eval-->>Request: Result
    end
    
    Request-->>Client: Return Result
    Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 
 Poem
 Pre-merge checks and finishing touches✅ Passed checks (2 passed)
 ✨ Finishing touches
 🧪 Generate unit tests (beta)
 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment   | 
    
| 
           @coderabbitai create an issue for this PR: it depends on projectdiscovery/gozero#25 and introduces execution of nuclei code templates into a virtualized docker enviroment  | 
    
| 
          
 Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 54 @Mzack9999: I've created issue #6582 for this PR. The issue includes: 
 You can view the issue here: #6582  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
pkg/protocols/code/code.go (1)
49-52: LGTM! Consider adding field validation.The Sandbox struct is well-defined with appropriate YAML/JSON tags. However, consider adding validation in the future to ensure WorkingDir (if provided) is an absolute path and Image is a valid Docker image reference.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
go.sumis excluded by!**/*.sumintegration_tests/protocols/code/py-virtual.yamlis excluded by!**/*.yamlintegration_tests/protocols/code/sh-virtual.yamlis excluded by!**/*.yaml
📒 Files selected for processing (3)
cmd/integration-test/code.go(1 hunks)go.mod(4 hunks)pkg/protocols/code/code.go(5 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.go: Format Go code using go fmt
Run static analysis with go vet
Files:
cmd/integration-test/code.gopkg/protocols/code/code.go
pkg/protocols/**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
Each protocol implementation must provide a Request interface with methods Compile(), ExecuteWithResults(), Match(), and Extract()
Files:
pkg/protocols/code/code.go
🧬 Code graph analysis (2)
cmd/integration-test/code.go (1)
pkg/testutils/integration.go (1)
TestCase(247-250)
pkg/protocols/code/code.go (1)
pkg/protocols/protocols.go (1)
Request(308-333)
🔇 Additional comments (4)
pkg/protocols/code/code.go (2)
479-481: LGTM! Sandbox detection logic is clear.The
useSandbox()helper correctly checks both that Sandbox is not nil and that Image is non-empty, which is the minimum requirement for Docker execution.
255-265: Sandbox configuration lacks pre-flight validation before passing to gozero.The
useSandbox()method (line 480) validates only thatSandboxis non-nil andImageis non-empty. TheWorkingDirfield andImageformat are never validated before construction ofDockerConfigurationat lines 260–263. While error handling exists downstream (line 271), the absence of local validation means invalid paths or malformed Docker image references will only surface as runtime errors from gozero.Add validation for:
Image: Verify it matches valid Docker image reference formatWorkingDir: Validate path constraints (absolute path, accessible, etc.)Alternatively, document that gozero performs these validations and handles invalid configurations gracefully.
cmd/integration-test/code.go (1)
27-28: LGTM! Linux-gated virtual environment tests added.The new test cases for sandbox-based code execution are appropriately gated to Linux-only environments, which is correct for Docker-based virtualization. The test cases reuse the existing
codeSnippetimplementation, maintaining consistency with the test suite structure.go.mod (1)
101-101: No security advisories found for the updated dependencies.The verification check against GitHub's security advisory database confirms that none of the updated dependencies (gozero, OpenTelemetry suite, golang.org/x/time, and backoff/v5) have known security vulnerabilities in their current versions.
Proposed changes
Checklist
Summary by CodeRabbit