MCPcopy Create free account
hub / github.com/NotRequiem/VMAware / write_cli

Function write_cli

auxiliary/add_technique.py:435–477  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

433
434
435def write_cli(options):
436 with open('../src/cli.cpp', 'r') as file:
437 lines = file.readlines()
438
439 new_code = []
440
441 for line in lines:
442 # if the line is empty, skip
443 if not line:
444 new_code.append(line)
445 continue
446
447 # modify the checklist with the newly appended technique here
448 if "// ADD NEW TECHNIQUE CHECKER HERE" in line:
449 new_code.append(
450 tab +
451 "checker(VM::" +
452 options.enum_name +
453 ", \"" +
454 options.short_description +
455 "\");\n"
456 )
457
458 if "// ADD LINUX FLAG" in line:
459 if options.is_linux:
460 new_code.append(tab + tab + tab + "case VM::" + options.enum_name + ":\n")
461
462 if "// ADD WINDOWS FLAG" in line:
463 if options.is_win:
464 new_code.append(tab + tab + tab + "case VM::" + options.enum_name + ":\n")
465
466 if "// ADD MACOS FLAG" in line:
467 if options.is_mac:
468 new_code.append(tab + tab + tab + "case VM::" + options.enum_name + ":\n")
469
470 # add the line in the buffer array
471 new_code.append(line)
472
473
474 # commit the new changes from the buffer array
475 with open("../src/cli.cpp", "w") as file:
476 for line in new_code:
477 file.write(line)
478
479
480

Callers 1

add_technique.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected