github-windows-bazel Kokoro fail

PiperOrigin-RevId: 356564212
Change-Id: If5e9d570a2dd7f42c3661aee51683bb3f542f50d
This commit is contained in:
Laura Pak 2021-02-09 12:26:37 -08:00 committed by TensorFlower Gardener
parent d4c8c579e1
commit 77c61d9c13
2 changed files with 62 additions and 0 deletions

View File

@ -48,6 +48,15 @@ tf_fuzz_target(
],
)
tf_fuzz_target(
name = "ParseAttrValue_fuzz",
srcs = ["ParseAttrValue_fuzz.cc"],
deps = [
"//tensorflow/core/framework:attr_value_proto_cc",
"//tensorflow/core/framework:attr_value_util",
],
)
tf_fuzz_target(
name = "joinpath_fuzz",
srcs = ["joinpath_fuzz.cc"],

View File

@ -0,0 +1,53 @@
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include <fuzzer/FuzzedDataProvider.h>
#include <cstdint>
#include <cstdlib>
#include <string>
#include "tensorflow/core/framework/attr_value.pb.h"
#include "tensorflow/core/framework/attr_value_util.h"
// This is a fuzzer for tensorflow::ParseAttrValue.
namespace {
using tensorflow::StringPiece;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// ParseAttrValue converts text protos into the types of attr_value.proto,
// which are string, int, float, bool, DataType, TensorShapeProto,
// TensorProto, NameAttrList, and list of any previously mentioned data type.
// This fuzzer tests the ParseAttrValue's ability to not crash.
FuzzedDataProvider fuzzed_data(data, size);
tensorflow::AttrValue out;
std::string type = fuzzed_data.PickValueInArray(
{"string", "int", "float", "bool", "type", "shape", "tensor",
"list(string)", "list(int)", "list(float)", "list(bool)", "list(type)",
"list(shape)", "list(tensor)", "list(list(string))", "list(list(int))",
"list(list(float))", "list(list(bool))", "list(list(type))",
"list(list(shape))", "list(list(tensor))",
// Invalid values
"invalid", "123"});
std::string text_string = fuzzed_data.ConsumeRemainingBytesAsString();
tensorflow::ParseAttrValue(type, text_string, &out);
return 0;
}
} // namespace