malicious_test.go 530 B

1234567891011121314151617181920212223242526
  1. package integrationtests_test
  2. import (
  3. "strings"
  4. "testing"
  5. "github.com/langgenius/dify-sandbox/internal/core/runner/types"
  6. "github.com/langgenius/dify-sandbox/internal/service"
  7. )
  8. func TestSysFork(t *testing.T) {
  9. // Test case for sys_fork
  10. resp := service.RunPython3Code(`
  11. import os
  12. os.fork()
  13. `, "", &types.RunnerOptions{})
  14. if resp.Code != 0 {
  15. t.Error(resp)
  16. }
  17. if !strings.Contains(resp.Data.(*service.RunCodeResponse).Stderr, "operation not permitted") {
  18. t.Error(resp.Data.(*service.RunCodeResponse).Stderr)
  19. }
  20. }