Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion dag/extdeps/shell/shell.dag
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ service shell.Exec {
stderr: String from "stderr"
}

transport shell { argv: ["sh", "-c", "{script}"] }
transport shell {
argv: ["sh", "-s"]
stdin: script
}
exit {
0 => Unit
nonzero => String "Script failed"
Expand Down
34 changes: 34 additions & 0 deletions dag/test/claim/shell_exec_run_argv_embed_witness_test.dag
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module test.claim.shell_exec_run_argv_embed_witness

import std.types { Bool, String }
import std.measure { ByteSize, byte_size, byte_size_count }
import gunbc.live_deploy.emit { live_deploy_apply_script_for }
import gunbc.live_deploy.spec { deployment_spec_srv1 }
import extdeps.filesystem.filesystem_io
import v2.std.live_tree { LiveTreeDisposition, ReadsLiveTree }

data live_tree_disposition: LiveTreeDisposition = ReadsLiveTree

data shell_dag_path: String = "dag/extdeps/shell/shell.dag"

data local_argv_embed_budget: ByteSize = byte_size(65536)

fn src_has(path: String, needle: String) -> Bool {
let r = filesystem_read(path: path)
string_contains(s: r.content, pattern: needle)
}

fn witness_apply_script_exceeds_local_argv_embed_budget() -> Bool {
let script_len = length(live_deploy_apply_script_for(spec: deployment_spec_srv1()))
let budget = byte_size_count(b: local_argv_embed_budget)
script_len > budget
}

fn witness_shell_exec_run_uses_stdin_transport() -> Bool {
src_has(path: shell_dag_path, needle: "stdin: script")
}

test fn shell_exec_run_argv_embed_witnesses() -> Bool {
witness_apply_script_exceeds_local_argv_embed_budget()
&& witness_shell_exec_run_uses_stdin_transport()
}
Loading