From a66dbc29e4e075abe11a73ca4b3dba72c78cf8fd Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Sun, 22 Sep 2024 01:36:07 -0400 Subject: [PATCH] feat: use CopyInDir instead of CopyInCwd --- README.md | 2 +- examples/clangtidy/sillycode | 2 +- examples/compile/error | 2 +- examples/compile/success | 2 +- examples/cppcheck/sillycode | 2 +- examples/cpplint/sillycode | 2 +- examples/diff/basic | 2 +- examples/diff/complex | 2 +- examples/healthcheck/asciifile | 2 +- examples/healthcheck/asciimsg | 2 +- examples/healthcheck/forbiddenfile | 2 +- examples/healthcheck/meta | 2 +- examples/healthcheck/release | 2 +- examples/healthcheck/reposize | 2 +- examples/healthcheck/repoverify | 2 +- examples/keyword/clangtidy/sillycode | 2 +- examples/keyword/cpplint/sillycode | 2 +- examples/sample/error | 2 +- examples/sample/success | 2 +- internal/executors/sandbox/convert.go | 10 ++++++---- internal/stage/model.go | 2 +- 21 files changed, 26 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 2b0e2f6..6200597 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ Check `Cmd` at . Some difference: -- `CopyInCwd bool`: set to `true` to add everything in the current working directory to `CopyIn`. +- `CopyInDir string`: set to non-empty string to add everything in that directory to `CopyIn`. - `CopyInCached map[string]string`: key: file name in the sandbox, value: file name used in `CopyOutCached`. - `LocalFile`: now supports the relative path diff --git a/examples/clangtidy/sillycode b/examples/clangtidy/sillycode index 235d198..30b1798 160000 --- a/examples/clangtidy/sillycode +++ b/examples/clangtidy/sillycode @@ -1 +1 @@ -Subproject commit 235d1980bb55c8ec231ab03933cf8e8335344b81 +Subproject commit 30b179812335b427a431c303ed3453779f898796 diff --git a/examples/compile/error b/examples/compile/error index fc02680..b16b4a9 160000 --- a/examples/compile/error +++ b/examples/compile/error @@ -1 +1 @@ -Subproject commit fc02680432a9003d623970187acce73276ce03b5 +Subproject commit b16b4a9679bb97d8703a3c70d3b75dd06e9fd4df diff --git a/examples/compile/success b/examples/compile/success index 3a0760f..ca21e3e 160000 --- a/examples/compile/success +++ b/examples/compile/success @@ -1 +1 @@ -Subproject commit 3a0760f2442723eb77eafacbf89b0d25d62eb607 +Subproject commit ca21e3ef7980339e433c6531d8e2aae9678eff2d diff --git a/examples/cppcheck/sillycode b/examples/cppcheck/sillycode index 578be03..866e732 160000 --- a/examples/cppcheck/sillycode +++ b/examples/cppcheck/sillycode @@ -1 +1 @@ -Subproject commit 578be035a0aedc0d9b5ffe5f40d4162e6483b6d0 +Subproject commit 866e73258c2d8f87b0000754a16f9b9c7de0c0fa diff --git a/examples/cpplint/sillycode b/examples/cpplint/sillycode index 80ec230..af355d9 160000 --- a/examples/cpplint/sillycode +++ b/examples/cpplint/sillycode @@ -1 +1 @@ -Subproject commit 80ec230f63267a10777ae58ebb632709fc562e85 +Subproject commit af355d91abf1ed62f19e0703dad55d18eb1252f8 diff --git a/examples/diff/basic b/examples/diff/basic index 13a3d05..cc5d991 160000 --- a/examples/diff/basic +++ b/examples/diff/basic @@ -1 +1 @@ -Subproject commit 13a3d05163213ce44c1ec638d4a409ed9db90530 +Subproject commit cc5d991cb401b0c8cfd8e03a76fb9994158d2819 diff --git a/examples/diff/complex b/examples/diff/complex index 7f6f6e8..f29fbda 160000 --- a/examples/diff/complex +++ b/examples/diff/complex @@ -1 +1 @@ -Subproject commit 7f6f6e881d39e870e51afb3fd36fdbef20b9cb35 +Subproject commit f29fbdac51f851e782f0db13f8640c6ba0aec49d diff --git a/examples/healthcheck/asciifile b/examples/healthcheck/asciifile index 1492b43..146b2f8 160000 --- a/examples/healthcheck/asciifile +++ b/examples/healthcheck/asciifile @@ -1 +1 @@ -Subproject commit 1492b43605a17850071d4e6674151719ae55e761 +Subproject commit 146b2f829a91594c89f1d1379d312b91c5f97a55 diff --git a/examples/healthcheck/asciimsg b/examples/healthcheck/asciimsg index f2848d6..ffd9ab1 160000 --- a/examples/healthcheck/asciimsg +++ b/examples/healthcheck/asciimsg @@ -1 +1 @@ -Subproject commit f2848d61097578d2439d3995820ea02a96ccad67 +Subproject commit ffd9ab13c7e403d0afc7f1dfc86ec131f9992498 diff --git a/examples/healthcheck/forbiddenfile b/examples/healthcheck/forbiddenfile index 02de953..b93a025 160000 --- a/examples/healthcheck/forbiddenfile +++ b/examples/healthcheck/forbiddenfile @@ -1 +1 @@ -Subproject commit 02de953cbc841afb3f53d0d4096b423f91d78593 +Subproject commit b93a0254c2842e4d9c3a4b8f832cd6b17bf284f9 diff --git a/examples/healthcheck/meta b/examples/healthcheck/meta index 3161962..b469371 160000 --- a/examples/healthcheck/meta +++ b/examples/healthcheck/meta @@ -1 +1 @@ -Subproject commit 3161962adba8d6f2663963eb5c39578cb7874ab8 +Subproject commit b4693716ee97bd5d9814c512b036aabeb12c7fd6 diff --git a/examples/healthcheck/release b/examples/healthcheck/release index 01b362e..50ec9cc 160000 --- a/examples/healthcheck/release +++ b/examples/healthcheck/release @@ -1 +1 @@ -Subproject commit 01b362e3bd5156211f8152237b101301560433b8 +Subproject commit 50ec9ccbb6d7fe9b5352a018b6ac6445ac5c354f diff --git a/examples/healthcheck/reposize b/examples/healthcheck/reposize index 0648e32..9c010a0 160000 --- a/examples/healthcheck/reposize +++ b/examples/healthcheck/reposize @@ -1 +1 @@ -Subproject commit 0648e32a8932e561e102f336766ca18165866ab8 +Subproject commit 9c010a0f8d501223f94d677a4aed70f0162092e2 diff --git a/examples/healthcheck/repoverify b/examples/healthcheck/repoverify index 5e25b93..99d95c2 160000 --- a/examples/healthcheck/repoverify +++ b/examples/healthcheck/repoverify @@ -1 +1 @@ -Subproject commit 5e25b932fc3950f382c8533e018520b04542af4a +Subproject commit 99d95c2841517f36a2063c641ea2e1b9b6190c76 diff --git a/examples/keyword/clangtidy/sillycode b/examples/keyword/clangtidy/sillycode index 1f53f4d..1f962c7 160000 --- a/examples/keyword/clangtidy/sillycode +++ b/examples/keyword/clangtidy/sillycode @@ -1 +1 @@ -Subproject commit 1f53f4df209662a30f7005a925fff0f0e3d94b13 +Subproject commit 1f962c75faccc9e703a8cd46e0a939551306bd4c diff --git a/examples/keyword/cpplint/sillycode b/examples/keyword/cpplint/sillycode index 244a63f..507ae70 160000 --- a/examples/keyword/cpplint/sillycode +++ b/examples/keyword/cpplint/sillycode @@ -1 +1 @@ -Subproject commit 244a63f54397196f9f9a08114f4eef279093f2a6 +Subproject commit 507ae70e81c08a6becdc8219a2c62b5aa8c3db69 diff --git a/examples/sample/error b/examples/sample/error index 980baf1..31b3191 160000 --- a/examples/sample/error +++ b/examples/sample/error @@ -1 +1 @@ -Subproject commit 980baf11df313e659fb4b1dea1a126add15ac547 +Subproject commit 31b319157fb221636fcdf8d6a752a4a5e46d6a6d diff --git a/examples/sample/success b/examples/sample/success index 1d886f8..7a98095 160000 --- a/examples/sample/success +++ b/examples/sample/success @@ -1 +1 @@ -Subproject commit 1d886f8754d0a22471405580d231b2691b929bfd +Subproject commit 7a98095a322419939bffa8636207090493108a3c diff --git a/internal/executors/sandbox/convert.go b/internal/executors/sandbox/convert.go index 827dd15..c739f79 100644 --- a/internal/executors/sandbox/convert.go +++ b/internal/executors/sandbox/convert.go @@ -28,7 +28,7 @@ func convertPBCmd(cmd []stage.Cmd) []*pb.Request_CmdType { CpuSetLimit: c.CPUSetLimit, DataSegmentLimit: c.DataSegmentLimit, AddressSpaceLimit: c.AddressSpaceLimit, - CopyIn: convertPBCopyIn(c.CopyIn, c.CopyInCwd), + CopyIn: convertPBCopyIn(c.CopyIn, c.CopyInDir), CopyOut: convertPBCopyOut(c.CopyOut), CopyOutCached: convertPBCopyOut(c.CopyOutCached), CopyOutMax: c.CopyOutMax, @@ -39,9 +39,11 @@ func convertPBCmd(cmd []stage.Cmd) []*pb.Request_CmdType { return ret } -func convertPBCopyIn(copyIn map[string]stage.CmdFile, copyInCwd bool) map[string]*pb.Request_File { - if copyInCwd { - _ = filepath.Walk(".", +func convertPBCopyIn( + copyIn map[string]stage.CmdFile, copyInDir string, +) map[string]*pb.Request_File { + if copyInDir != "" { + _ = filepath.Walk(copyInDir, func(path string, info os.FileInfo, err error) error { if err != nil { return nil diff --git a/internal/stage/model.go b/internal/stage/model.go index dba945a..224b687 100644 --- a/internal/stage/model.go +++ b/internal/stage/model.go @@ -46,7 +46,7 @@ type Cmd struct { CopyIn map[string]CmdFile `json:"copyIn"` CopyInCached map[string]string `json:"copyInCached"` - CopyInCwd bool `json:"copyInCwd"` + CopyInDir string `json:"copyInDir"` CopyOut []string `json:"copyOut"` CopyOutCached []string `json:"copyOutCached"`