Commit 0d619893 authored by Jerry Lin's avatar Jerry Lin Committed by Commit Bot

Add fuzzer for PasswordGenerator.

This fuzzer passes fuzzed message |PasswordRequirementsSpec| to function |GeneratePassword|.
The random choices inside the function are still random and not replaced by the fuzzed input.

R=vabr@chromium.org

Bug: 847200
Change-Id: I221fe286328d5818bd50282046799e8930079298
Reviewed-on: https://chromium-review.googlesource.com/1120088Reviewed-by: default avatarJonathan Metzman <metzman@chromium.org>
Reviewed-by: default avatarVaclav Brozek <vabr@chromium.org>
Commit-Queue: Vaclav Brozek <vabr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584059}
parent 1c8f41eb
......@@ -116,8 +116,6 @@ jumbo_static_library("browser") {
"local_card_migration_manager.h",
"name_field.cc",
"name_field.h",
"password_generator.cc",
"password_generator.h",
"password_requirements_spec_fetcher.h",
"password_requirements_spec_fetcher_impl.cc",
"password_requirements_spec_fetcher_impl.h",
......@@ -255,6 +253,7 @@ jumbo_static_library("browser") {
"//third_party/libaddressinput",
]
deps = [
":password_generator",
":password_generator_fips181",
"//base",
"//base:i18n",
......@@ -373,6 +372,19 @@ jumbo_static_library("test_support") {
]
}
static_library("password_generator") {
sources = [
"password_generator.cc",
"password_generator.h",
]
public_deps = [
"//components/autofill/core/browser/proto",
]
deps = [
"//base",
]
}
static_library("password_generator_fips181") {
sources = [
"password_generator_fips181.cc",
......@@ -494,6 +506,7 @@ source_set("unit_tests") {
deps = [
":browser",
":password_generator",
":password_generator_fips181",
":test_support",
":unit_tests_bundle_data",
......@@ -572,4 +585,15 @@ if (use_libfuzzer) {
"//third_party/libprotobuf-mutator",
]
}
fuzzer_test("password_generator_proto_fuzzer") {
sources = [
"password_generator_proto_fuzzer.cc",
]
deps = [
":password_generator",
"//components/autofill/core/browser/proto",
"//third_party/libprotobuf-mutator",
]
}
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/autofill/core/browser/password_generator.h"
#include "components/autofill/core/browser/proto/password_requirements.pb.h"
#include "testing/libfuzzer/proto/lpm_interface.h"
namespace autofill {
DEFINE_PROTO_FUZZER(const PasswordRequirementsSpec& spec) {
GeneratePassword(spec);
}
} // namespace autofill
......@@ -188,6 +188,7 @@ jumbo_static_library("browser") {
":proto",
"//base:i18n",
"//components/autofill/core/browser",
"//components/autofill/core/browser:password_generator",
"//components/autofill/core/browser/proto",
"//components/autofill/core/common",
"//components/favicon/core",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment