Skip to content

Commit f44eeb5

Browse files
committed
engine: Add --strict and --secure flags
The -t, --strict flag is especially useful for tests, since it combines flags commonly used for reproducible executions.
1 parent 1a4ab65 commit f44eeb5

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

engine/src/main.cpp

+19-1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ int main(int argc, char** argv) {
114114
app.add_flag("--interpolate-undefined", stack_options.interpolate_undefined,
115115
"Interpolate undefined variables with empty strings");
116116

117+
// The --strict flag here is useful for all our smoketests, since this is the
118+
// combination of flags we use for maximum reproducibility / isolation.
119+
// Note: This option also affects / overwrites options for the run subcommand!
120+
app.add_flag("-t,--strict", stack_options.strict_mode,
121+
"Forces flags: --no-system-plugins --no-system-confs --require-success");
122+
app.add_flag("-s,--secure", stack_options.secure_mode,
123+
"Forces flags: --strict --no-hooks --no-interpolate");
124+
117125
// ----------------------------------------------------------------------- //
118126

119127
CLI11_PARSE(app, argc, argv);
@@ -131,7 +139,17 @@ int main(int argc, char** argv) {
131139
cloe::logger::set_level(level);
132140
}
133141

134-
// Setup stack and provide launch command.
142+
// Setup stack, applying strict/secure mode if necessary, and provide launch command.
143+
if (stack_options.secure_mode) {
144+
stack_options.strict_mode = true;
145+
stack_options.no_hooks = true;
146+
stack_options.interpolate_vars = false;
147+
}
148+
if (stack_options.strict_mode) {
149+
stack_options.no_system_plugins = true;
150+
stack_options.no_system_confs = true;
151+
run_options.require_success = true;
152+
}
135153
stack_options.environment->prefer_external(false);
136154
stack_options.environment->allow_undefined(stack_options.interpolate_undefined);
137155
stack_options.environment->insert(CLOE_SIMULATION_UUID_VAR, "${" CLOE_SIMULATION_UUID_VAR "}");

engine/src/main_stack.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
namespace cloe {
3636

37+
// See main.cpp for descriptions of flags.
3738
struct StackOptions {
3839
boost::optional<std::ostream&> error = std::cerr;
3940
std::shared_ptr<fable::Environment> environment;
@@ -47,6 +48,8 @@ struct StackOptions {
4748
bool no_hooks = false;
4849
bool interpolate_vars = true;
4950
bool interpolate_undefined = false;
51+
bool strict_mode = false;
52+
bool secure_mode = false;
5053
};
5154

5255
Stack new_stack(const StackOptions& opt);

0 commit comments

Comments
 (0)