Browse code

Add clamscan flag --bytecode-mode.

This allows access to the newly introduced testmode.

Török Edvin authored on 2010/07/29 19:46:16
Showing 2 changed files
... ...
@@ -404,6 +404,18 @@ int scanmanager(const struct optstruct *opts)
404 404
 	cl_engine_set_num(engine, CL_ENGINE_BYTECODE_SECURITY, CL_BYTECODE_TRUST_ALL);
405 405
     if((opt = optget(opts,"bytecode-timeout"))->enabled)
406 406
 	cl_engine_set_num(engine, CL_ENGINE_BYTECODE_TIMEOUT, opt->numarg);
407
+    if((opt = optget(opts,"bytecode-mode"))->enabled) {
408
+	enum bytecode_mode mode;
409
+	if (!strcmp(opt->strarg, "ForceJIT"))
410
+	    mode = CL_BYTECODE_MODE_JIT;
411
+	else if(!strcmp(opt->strarg, "ForceInterpreter"))
412
+	    mode = CL_BYTECODE_MODE_INTERPRETER;
413
+	else if(!strcmp(opt->strarg, "Test"))
414
+	    mode = CL_BYTECODE_MODE_TEST;
415
+	else
416
+	    mode = CL_BYTECODE_MODE_AUTO;
417
+	cl_engine_set_num(engine, CL_ENGINE_BYTECODE_MODE, mode);
418
+    }
407 419
 
408 420
     if((opt = optget(opts, "tempdir"))->enabled) {
409 421
 	if((ret = cl_engine_set_str(engine, CL_ENGINE_TMPDIR, opt->strarg))) {
... ...
@@ -254,6 +254,8 @@ const struct clam_option __clam_options[] = {
254 254
 	"Set bytecode security level.\nPossible values:\n\tNone - no security at all, meant for debugging. DO NOT USE THIS ON PRODUCTION SYSTEMS\n\tTrustSigned - trust bytecode loaded from signed .c[lv]d files,\n\t\t insert runtime safety checks for bytecode loaded from other sources\n\tParanoid - don't trust any bytecode, insert runtime checks for all\nRecommended: TrustSigned, because bytecode in .cvd files already has these checks\n","TrustSigned"},
255 255
     { "BytecodeTimeout", "bytecode-timeout", 0, TYPE_NUMBER, MATCH_NUMBER, 60000, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, 
256 256
 	"Set bytecode timeout in miliseconds.\n","60000"},
257
+    { "BytecodeMode", "bytecode-mode", 0, TYPE_STRING, "^(Auto|ForceJIT|ForceInterpreter|Test)$", -1, "Auto", 0, OPT_CLAMD | OPT_CLAMSCAN,
258
+	"Set bytecode execution mode.\nPossible values:\n\tAuto - automatically choose JIT if possible, fallback to interpreter\nForceJIT - always choose JIT, fail if not possible\nForceIntepreter - always choose interpreter\nTest - run with both JIT and interpreter and compare results. Make all failures fatal\n","Auto"},
257 259
     { "DetectPUA", "detect-pua", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "Detect Potentially Unwanted Applications.", "yes" },
258 260
 
259 261
     { "ExcludePUA", "exclude-pua", 0, TYPE_STRING, NULL, -1, NULL, FLAG_MULTIPLE, OPT_CLAMD | OPT_CLAMSCAN, "Exclude a specific PUA category. This directive can be used multiple times.\nSee http://www.clamav.net/support/pua for the complete list of PUA\ncategories.", "NetTool\nPWTool" },