This source file includes following definitions.
- main
#include <string>
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "chrome/browser/safe_browsing/binary_feature_extractor.h"
#include "chrome/common/safe_browsing/csd.pb.h"
static const char kExecutable[] = "executable";
static const char kOutputFile[] = "output";
int main(int argc, char* argv[]) {
CommandLine::Init(argc, argv);
CommandLine* cmd_line = CommandLine::ForCurrentProcess();
if (!cmd_line->HasSwitch(kExecutable)) {
LOG(ERROR) << "Must specify executable to open with --executable";
return 1;
}
if (!cmd_line->HasSwitch(kOutputFile)) {
LOG(ERROR) << "Must specify output file with --output";
return 1;
}
scoped_refptr<safe_browsing::BinaryFeatureExtractor> extractor(
new safe_browsing::BinaryFeatureExtractor());
safe_browsing::ClientDownloadRequest_SignatureInfo signature_info;
extractor->CheckSignature(cmd_line->GetSwitchValuePath(kExecutable),
&signature_info);
std::string serialized_info = signature_info.SerializeAsString();
int bytes_written = base::WriteFile(
cmd_line->GetSwitchValuePath(kOutputFile),
serialized_info.data(),
serialized_info.size());
if (bytes_written != static_cast<int>(serialized_info.size())) {
LOG(ERROR) << "Error writing output file";
return 1;
}
return 0;
}