chromium/components/media_router/common/providers/cast/channel/proto/fuzzer_inputs.proto

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Inputs for various fuzz tests

// NOTE(crbug.com/796717): As for this writing, the tests are
// incomplete, and its not entirely clear what additional tests need
// to be written.  The general priority for tests is:
//
// 1. Messages that contain any data passed through the SDK/renderer
//    process.
// 2. Messages from Cast devices.
// 3. Messages generated entirely by the native Cast MRP, since they
//    are already from privileged code (at least for now).
//
// See also
// https://chromium-coverage.appspot.com/reports/763373_fuzzers_only/linux/chromium/src/components/media_router/common/providers/cast/channel/report.html
// for fuzz test coverage.

syntax = "proto2";

import "cast_channel.proto";
import "revocation.proto";

option optimize_for = LITE_RUNTIME;

package cast_channel.fuzz;

enum TimeBoundCase {
  VALID = 0;
  INVALID = 1;
  OOB = 2;
  MISSING = 3;
}

// Inputs for functions in cast_auth_utils.cc
message CastAuthUtilInputs {
  message AuthenticateChallengeReplyInput {
    // The actual input to the function, parts of which may be
    // overridden based on the additional fields below.
    required openscreen.cast.proto.CastMessage cast_message = 1;
    required string nonce = 2;

    // Values used to set the start and end times.
    required TimeBoundCase start_case = 3;
    required TimeBoundCase expiry_case = 4;

    // Value used to replace the payload of |cast_message| with data
    // that is more likely to be valid (and thus exercise more code
    // paths).
    optional openscreen.cast.proto.DeviceAuthMessage auth_message = 5;

    // Values used to replace the |crl| field of
    // |auth_message.response|.
    repeated openscreen.cast.proto.TbsCrl tbs_crls = 7;

    // Flags that force certain fields to have correct values.
    required bool nonce_ok = 8;
    required bool response_certs_ok = 9;
    required bool crl_certs_ok = 10;
    required bool crl_signatures_ok = 11;
  }

  oneof input {
    AuthenticateChallengeReplyInput authenticate_challenge_reply_input = 1;
  }
}

// Inputs for functions in cast_message_utils.cc
message CastMessageUtilInputs {
  message CreateLaunchRequestInput {
    required string source_id = 1;
    required int32 request_id = 2;
    required string app_id = 3;
    required string locale = 4;
    repeated string supported_app_types = 5;
    optional JunkValue app_params = 6;
  }

  message CreateStopRequestInput {
    required string source_id = 1;
    required int32 request_id = 2;
    required string session_id = 3;
  }

  message CreateCastMessageInput {
    required string message_namespace = 1;
    required string source_id = 2;
    required string destination_id = 3;
    required JunkValue body = 4;
  }

  message CreateMediaRequestInput {
    required int32 request_id = 1;
    required string source_id = 2;
    required string destination_id = 3;
    required int32 type = 4;
    required JunkValue body = 5;
  }

  message CreateSetVolumeRequestInput {
    required int32 request_id = 1;
    required string source_id = 2;
    required JunkValue body = 3;
  }

  message CreateVirtualConnectionRequestInput {
    required string source_id = 1;
    required string destination_id = 2;
    required int32 connection_type = 3;
    required string user_agent = 4;
    required string browser_version = 5;
  }

  message CreateGetAppAvailabilityRequestInput {
    required string source_id = 1;
    required int32 request_id = 2;
    required string app_id = 3;
  }

  message GetRequestIdFromResponseInput {
    optional int32 request_id = 1;
    required JunkValue payload = 2;
  }

  message GetAppAvailabilityResultFromResponseInput {
    required JunkValue payload = 1;
    required string app_id = 2;
  }

  message GetLaunchSessionResponseInput {
    required JunkValue payload = 1;
  }

  message IsCastReservedNamespaceInput {
    required string message_namespace = 1;
  }

  message ParseMessageTypeFromPayloadInput {
    optional string type = 1;
    required JunkValue payload = 2;
  }

  message CreateReceiverStatusRequestInput {
    required string source_id = 1;
    required int32 request_id = 2;
  }

  oneof input {
    CreateLaunchRequestInput create_launch_request_input = 2;
    CreateStopRequestInput create_stop_request_input = 3;
    CreateCastMessageInput create_cast_message_input = 4;
    CreateMediaRequestInput create_media_request_input = 5;
    CreateSetVolumeRequestInput create_set_volume_request_input = 6;
    int32 int_input = 7;
    string string_input = 8;
    openscreen.cast.proto.CastMessage cast_message = 9;
    CreateVirtualConnectionRequestInput
        create_virtual_connection_request_input = 10;
    CreateGetAppAvailabilityRequestInput
        create_get_app_availability_request_input = 11;
    GetRequestIdFromResponseInput get_request_id_from_response_input = 12;
    GetLaunchSessionResponseInput get_launch_session_response_input = 13;
    ParseMessageTypeFromPayloadInput parse_message_type_from_payload_input = 14;
    CreateReceiverStatusRequestInput create_receiver_status_request_input = 15;
  }
}

// Message used to generate a plausible but meaningless instance of
// base::Value.
message JunkValue {
  message Field {
    required string name = 1;
    oneof value {
      int32 int_value = 2;
      string string_value = 3;
      float float_value = 4;
      bool bool_value = 5;
    }
  }

  repeated Field field = 1;
}