Home | History | Annotate | Download | only in quipper
      1 // Copyright 2015 The Chromium OS Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROMIUMOS_WIDE_PROFILING_PERF_OPTION_PARSER_H_
      6 #define CHROMIUMOS_WIDE_PROFILING_PERF_OPTION_PARSER_H_
      7 
      8 #include <vector>
      9 
     10 #include "compat/string.h"
     11 
     12 namespace quipper {
     13 
     14 // Check that "args" is safe to pass to perf. That is, that it only contains
     15 // safe options from a whitelist of those that modify event collection.
     16 // e.g., "perf record -e cycles -- rm -rf /" is unsafe.
     17 // This check should be made on the arguments coming from an untrusted caller of
     18 // quipper before quipper adds its own arguments, like "-- sleep 2" to set the
     19 // profile duration, or "-o /tmp/perf.data" to set the output path.
     20 // This also requires that args[0] is "perf". Quipper can later substitute
     21 // this with the One True perf binary.
     22 // Returns |true| iff the command line is safe.
     23 bool ValidatePerfCommandLine(const std::vector<string> &args);
     24 
     25 }  // namespace quipper
     26 
     27 #endif  // CHROMIUMOS_WIDE_PROFILING_PERF_OPTION_PARSER_H_
     28