Merge pull request #8586 from ctiller/securityfuzzit

Add credentials creation to api_fuzzer
pull/8532/head^2
Craig Tiller 8 years ago committed by GitHub
commit 43ec556ea7
  1. 151
      test/core/end2end/fuzzers/api_fuzzer.c
  2. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/00c7c2cc7f90842e766645310e4a439e7b188473
  3. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/0768af66da5e344f21337df8eb0a1c8c955f4244
  4. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/099d967555bfc237238c93f9d884c004c773b33b
  5. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/0b08fc5a8eb4a23766be7b3082308959955d4b13
  6. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/0c088a8261de0bf3b996cc1e7889399acb03fd5a
  7. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/0e0ecc8214b5083b75216857b967621c0648afc9
  8. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/0e5aa755fff40b487617e01f6812d85ad310b727
  9. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/13b2e7a9d9f07a9e06ed96957c56e968f3b6070d
  10. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/13c269dc54b84acbf75b78db730c25311a61c4ab
  11. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/16b69b968a140abb00dd5c79ea7d0c1b23510fe7
  12. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/16f798191df0c173217cdcb4ec8edd3e4f7fb99b
  13. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/17c7024889cc97a8afd3133b55a147ba75d17188
  14. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/194027acca76bf2e874aa672b4491f0b7fe32187
  15. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/1a6119919790570e3c15bb371648fc7929c72ea2
  16. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/1abcbb03796c6512f5b8a977532fbcf6368b45b0
  17. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/1d505e827d0036b3d8eab87439d31da5f901aed1
  18. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/217785067a28a2dcdf7c5cea9ef8c10817889aa7
  19. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/21af47d84b1aa84e8b4021765203c8951239fe41
  20. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2339fcca7f93814c587aba47fff2210875a41f49
  21. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/239b03041efe9bf24982b0ecbb66d5abea4a28d0
  22. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/24d630240f673498d784cecb66d73e9b1d981493
  23. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2533c4ed207eed715756142667128f6eb01309e0
  24. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2b6a001c2274e347cbfc6fe2e3bf4f7d7e79f5fe
  25. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2c5b259108eb1a9735d7a89609d96bc043914cdb
  26. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/2f8262de35a8314655d55f10ca46db441577ba36
  27. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/321e6127d6f5619c88e31037f7fdec581acf75e8
  28. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/34052cc2fa2be6543184db85d0b9ad33ae17029c
  29. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/351c6aabe840d69a16ca0f630c6c5a11d42cb85c
  30. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/35623259c0d5d73d23ea52efc3e4bd808c119440
  31. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/35b84f9f429e72230f0e9f6400ae5052c961fb27
  32. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3606c0748089f53e252b577ff7ab2df203d098ff
  33. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3a07fd9ba009b9a57e298343e815abab13a16f5c
  34. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3a74f1be7106c7dea533a34bd8a88974f69a5d71
  35. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3adaa0aea970123baa8ddb2560842c43bd19eb3f
  36. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/3f4ee68f1f22eabcd01c2a7c1c6c8ccc299aa97d
  37. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/40b500d38927c62c6966039b8557f810b3c19dc1
  38. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/427392659bf3a945097c6c754a17d8c15e23816f
  39. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/42b3c2bc6a11cea9d3ac86fbb8411360da676268
  40. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/42bcf462c3b918f07c52e87bcea6fd69a1f291b1
  41. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/42e6fb19dac07a0cbe747dfc8f1c90bae1d58cec
  42. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/43d52b36766d71176a2fc9f2a4be385bd2638570
  43. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/44ec5dcc4133f1786084202bf41d877702ce9277
  44. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/463a882b12f48bf803b650e95f3968a28732fc02
  45. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/467971d589278cc348786054add9f1efda2fef9e
  46. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/49ff30e0f070fe37b642dd0d361c5cbca139f223
  47. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/4aac2683fc841a2b5da166889c54c01aa2ab9c6c
  48. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/4b538eda0a7ad5d38b9d95867b7c181cbe84589b
  49. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/4e4e5902e6d79c5d57bbf631863ab51b8b07943a
  50. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/4eb0173ccf074ec6d8c1943f3ab2464184262426
  51. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/507b8ecbb9fd3eea9084087bce22a94cca8a7c41
  52. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/509fa48e02986acab87796b1976e78a6ec243b79
  53. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/5347599c4246a004f9cbecfa78d39168237b6394
  54. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/5356dcd6b1d0487f9723663f8a3dc955b7e09273
  55. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/53d637a3f0b9fc07dee0de089080e5c105381eb1
  56. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/55c1b1bd6e532928ad47cadd8e5c5363849d7df5
  57. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/568af7c1199c646c500e287b50abada8ac0ff2da
  58. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/56fb970061e8b61059130c0ac642bd0ceb0ea26d
  59. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/587d211412b8405e82245f511007083dd60b7477
  60. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/58f2f1f487dcd6cc6f2126835ec647c73f0d371a
  61. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/58f87cac2d3f564f1afe4ca85637e47b758796a5
  62. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/5a3dbe637791a9a7c5005b985c1cc3e7066f8f50
  63. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/5bcde4a99b8ad54a5b8ba9b5131842c6c7c0ef19
  64. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/5fe822a742cf2f5328cec86c0972b0c7b4bd4460
  65. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/6016f65e62600b73d18ca8548591034fcddf440c
  66. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/61614f406af22aa805e6a2cfb24519ffd058d575
  67. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/622a3505d10767b795fc2c2922c0d5305d9b84e6
  68. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/63626e71d4e8e15905f13933f5b88d89073b3411
  69. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/65afd7305e481da5ffc44a6a66eb3117744ae77d
  70. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/65d8075993dbb2ed83dea46cd76e974352916eac
  71. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/663e7fc276b902cd6efb5bc944c4c7af90ca916d
  72. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/6ae9bab625e9ac8210953a7363167d6deaf194ec
  73. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/6b6a9a2ecc635bd8d76b00b64aeb6297e04683b6
  74. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/6c3c3119fabe838b2600e24651931f3012338e3b
  75. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/6cb9930369caf7584015d3a17c37e144d23b79ce
  76. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/713f66791d0f23b7b7b0ec9c40b6d51f7b214c9a
  77. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/71ef778b5cb623be033026d5a6968e49a9581dc2
  78. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/72b0bead5c0425173f696ff8efd7c726dcc4ecf8
  79. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/73b467524ba4f55fd030be6b0602389b9af4fa1a
  80. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/75aa409bfe540a3ad31f8bc504131eb41128404d
  81. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/764deb515100de2b3d375d2689fd2c9e55eb8cd6
  82. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/7697d76245fff3d4a58fb04745c2a6197c9eeb54
  83. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/798e448161e03d40712655f913464a276b6d6129
  84. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/79da19253d7fea59733d2a5276bb393918f014d1
  85. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/7a17b28c4e274868a9f9a8430ddd12d07221396e
  86. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/7a5a769942efac79863bb154cf1e7574e6d98e22
  87. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/7b1ad173c2ce60dd9f82143be5db1cbd317f8a6e
  88. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/7b747e0fabbfae7ecb4e9e8261121aaa42a21cc2
  89. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/7c9b85db0b4648d13fd8a0de2de9bebdba555fa8
  90. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/801f08f6085a2986fb868d326c71bdcb16df1481
  91. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/8102033256a24f00a59a0f23640d379eaeaba37d
  92. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/815f39659d787ccae06bc7d1e0564525c27b9b79
  93. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/816a1c7d02100fb495ab698923f8f4e550583e91
  94. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/820b97903732cf20dae26cdba0717220fa042a49
  95. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/83371e1fa4720aae8035d7dc955d376678e102ef
  96. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/83b2491b16c26c0dbb6aef5a9df10a3fa83beea2
  97. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/83df07a7e069d0932a221e28a2d47e449ca37c3f
  98. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/840959b26ce65b833d488ebb7b1d8431839fe701
  99. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/84316630fa8962f4753dda6e6c75625c47d19675
  100. BIN
      test/core/end2end/fuzzers/api_fuzzer_corpus/858a8d611419ced08aa85e89b75ff7baa1d9a791
  101. Some files were not shown because too many files have changed in this diff Show More

@ -34,6 +34,7 @@
#include <string.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
@ -45,6 +46,7 @@
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/surface/server.h"
#include "src/core/lib/transport/metadata.h"
#include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/util/passthru_endpoint.h"
////////////////////////////////////////////////////////////////////////////////
@ -195,6 +197,136 @@ static grpc_channel_args *read_args(input_stream *inp) {
return a;
}
typedef struct cred_artifact_ctx {
int num_release;
char *release[3];
} cred_artifact_ctx;
#define CRED_ARTIFACT_CTX_INIT \
{ \
0, { 0 } \
}
static void cred_artifact_ctx_finish(cred_artifact_ctx *ctx) {
for (int i = 0; i < ctx->num_release; i++) {
gpr_free(ctx->release[i]);
}
}
static const char *read_cred_artifact(cred_artifact_ctx *ctx, input_stream *inp,
const char **builtins,
size_t num_builtins) {
uint8_t b = next_byte(inp);
if (b == 0) return NULL;
if (b == 1) return ctx->release[ctx->num_release++] = read_string(inp);
if (b >= num_builtins + 1) {
end(inp);
return NULL;
}
return builtins[b - 1];
}
static grpc_channel_credentials *read_ssl_channel_creds(input_stream *inp) {
cred_artifact_ctx ctx = CRED_ARTIFACT_CTX_INIT;
static const char *builtin_root_certs[] = {test_root_cert};
static const char *builtin_private_keys[] = {
test_server1_key, test_self_signed_client_key, test_signed_client_key};
static const char *builtin_cert_chains[] = {
test_server1_cert, test_self_signed_client_cert, test_signed_client_cert};
const char *root_certs = read_cred_artifact(
&ctx, inp, builtin_root_certs, GPR_ARRAY_SIZE(builtin_root_certs));
const char *private_key = read_cred_artifact(
&ctx, inp, builtin_private_keys, GPR_ARRAY_SIZE(builtin_private_keys));
const char *certs = read_cred_artifact(&ctx, inp, builtin_cert_chains,
GPR_ARRAY_SIZE(builtin_cert_chains));
grpc_ssl_pem_key_cert_pair key_cert_pair = {private_key, certs};
grpc_channel_credentials *creds = grpc_ssl_credentials_create(
root_certs, private_key != NULL && certs != NULL ? &key_cert_pair : NULL,
NULL);
cred_artifact_ctx_finish(&ctx);
return creds;
}
static grpc_call_credentials *read_call_creds(input_stream *inp) {
switch (next_byte(inp)) {
default:
end(inp);
return NULL;
case 0:
return NULL;
case 1: {
grpc_call_credentials *c1 = read_call_creds(inp);
grpc_call_credentials *c2 = read_call_creds(inp);
if (c1 != NULL && c2 != NULL) {
grpc_call_credentials *out =
grpc_composite_call_credentials_create(c1, c2, NULL);
grpc_call_credentials_release(c1);
grpc_call_credentials_release(c2);
return out;
} else if (c1 != NULL) {
return c1;
} else if (c2 != NULL) {
return c2;
} else {
return NULL;
}
GPR_UNREACHABLE_CODE(return NULL);
}
case 2: {
cred_artifact_ctx ctx = CRED_ARTIFACT_CTX_INIT;
const char *access_token = read_cred_artifact(&ctx, inp, NULL, 0);
grpc_call_credentials *out =
access_token == NULL ? NULL : grpc_access_token_credentials_create(
access_token, NULL);
cred_artifact_ctx_finish(&ctx);
return out;
}
case 3: {
cred_artifact_ctx ctx = CRED_ARTIFACT_CTX_INIT;
const char *auth_token = read_cred_artifact(&ctx, inp, NULL, 0);
const char *auth_selector = read_cred_artifact(&ctx, inp, NULL, 0);
grpc_call_credentials *out = auth_token == NULL || auth_selector == NULL
? NULL
: grpc_google_iam_credentials_create(
auth_token, auth_selector, NULL);
cred_artifact_ctx_finish(&ctx);
return out;
}
/* TODO(ctiller): more cred types here */
}
}
static grpc_channel_credentials *read_channel_creds(input_stream *inp) {
switch (next_byte(inp)) {
case 0:
return read_ssl_channel_creds(inp);
break;
case 1: {
grpc_channel_credentials *c1 = read_channel_creds(inp);
grpc_call_credentials *c2 = read_call_creds(inp);
if (c1 != NULL && c2 != NULL) {
grpc_channel_credentials *out =
grpc_composite_channel_credentials_create(c1, c2, NULL);
grpc_channel_credentials_release(c1);
grpc_call_credentials_release(c2);
return out;
} else if (c1) {
return c1;
} else if (c2) {
grpc_call_credentials_release(c2);
return NULL;
} else {
return NULL;
}
GPR_UNREACHABLE_CODE(return NULL);
}
case 2:
return NULL;
default:
end(inp);
return NULL;
}
}
static bool is_eof(input_stream *inp) { return inp->cur == inp->end; }
////////////////////////////////////////////////////////////////////////////////
@ -962,6 +1094,25 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_resource_quota_resize(g_resource_quota, read_uint22(&inp));
break;
}
// create a secure channel
case 22: {
if (g_channel == NULL) {
char *target = read_string(&inp);
char *target_uri;
gpr_asprintf(&target_uri, "dns:%s", target);
grpc_channel_args *args = read_args(&inp);
grpc_channel_credentials *creds = read_channel_creds(&inp);
g_channel = grpc_secure_channel_create(creds, target_uri, args, NULL);
GPR_ASSERT(g_channel != NULL);
grpc_channel_args_destroy(args);
gpr_free(target_uri);
gpr_free(target);
grpc_channel_credentials_release(creds);
} else {
end(&inp);
}
break;
}
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save