Example #1
0
    if args.config is None and not os.path.exists(args.tables):
        print("Cannot find --tables: %s" % (args.tables))
        exit(1)

    queries = {}
    if args.config is not None:
        if not os.path.exists(args.config):
            print("Cannot find --config: %s" % (args.config))
            exit(1)
        queries = utils.queries_from_config(args.config)
    elif args.query is not None:
        queries["manual"] = args.query
    elif args.force:
        queries["force"] = True
    else:
        queries = utils.queries_from_tables(args.tables, args.restrict)

    if args.leaks:
        results = profile_leaks(
            args.shell, queries, count=args.count,
            rounds=args.rounds, supp_file=args.suppressions
        )
    else:
        # Start the profiling!
        results = profile(
            args.shell, queries,
            timeout=args.timeout, count=args.count, rounds=args.rounds
        )

        # Only apply checking/regressions to performance, not leaks.
        if args.check:
Example #2
0
        default="./build/%s/osquery/osqueryi" % (utils.platform()),
        help="Path to osqueryi shell (./build/<sys>/osquery/osqueryi).")

    args = parser.parse_args()
    if not os.path.exists(args.shell):
        print("Cannot find --shell: %s" % (args.shell))
        exit(1)
    if not os.path.exists(args.specs):
        print("Cannot find --specs: %s" % (args.specs))
        exit(1)

    if args.s < 0:
        args.s = random.randint(0, 65535)

    exit_code = 0
    tables = utils.queries_from_tables(args.specs, args.table)
    for table in tables:
        table = table.split(".")
        if table[0] == "specs":
            table.pop(0)
        table[-1] += ".table"

        filename = os.path.join(args.specs, *table)
        with open(filename, 'rU') as fh:
            # Open and parse/execute the specification.
            tree = ast.parse(fh.read())
            TableState = _TableState()
            exec(compile(tree, "<string>", "exec"))

            # We may later introduce other (simple) types of fuzzing.
            if len(TableState.fuzz_paths) > 0: