-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge from master to firebase #143
Changes from all commits
78b931b
8b3a442
c3abd2a
add363a
ee3cdee
efc32a2
92541b7
cea8827
6d7f0ee
4cd5c9f
bcdb75d
2c9c1af
2796209
8218f92
1d2d6a8
53fd026
33f54ed
eb8bfcc
89f0fbf
7635536
a6a33fd
d29a195
fdac61b
6e372fc
28105ca
21f1cb3
673b902
366f5ae
a39d555
88cfb24
d5a878a
25adae9
1cdc2ac
2f69cc9
8488133
0804a07
7444da1
d093254
ef1aecf
20e19d2
7fe10df
fdfb73f
3d402e6
d71d5f3
f5281ad
0c7c549
fc9497a
83e1d58
a118aea
eac5f4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# This is from Bazel's former travis setup, to avoid blowing up the RAM usage. | ||
startup --host_jvm_args=-Xmx8192m | ||
startup --host_jvm_args=-Xms8192m | ||
startup --batch | ||
|
||
# This is so we understand failures better | ||
build --verbose_failures | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
/bazel-* | ||
.idea/* | ||
*.iml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
sudo: required | ||
dist: xenial | ||
|
||
branches: | ||
except: | ||
- stable | ||
|
||
lang: go | ||
|
||
go: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!groovy | ||
|
||
@Library('testutils') | ||
|
||
import org.istio.testutils.Utilities | ||
import org.istio.testutils.GitUtilities | ||
import org.istio.testutils.Bazel | ||
|
||
// Utilities shared amongst modules | ||
def gitUtils = new GitUtilities() | ||
def utils = new Utilities() | ||
def bazel = new Bazel() | ||
|
||
mainFlow(utils) { | ||
pullRequest(utils) { | ||
node { | ||
gitUtils.initialize() | ||
// Proxy does build work correctly with Hazelcast. | ||
// Must use .bazelrc.jenkins | ||
bazel.setVars('', '') | ||
} | ||
|
||
if (utils.runStage('PRESUBMIT')) { | ||
presubmit(gitUtils, bazel) | ||
} | ||
if (utils.runStage('POSTSUBMIT')) { | ||
postsubmit(gitUtils, bazel, utils) | ||
} | ||
} | ||
} | ||
|
||
def presubmit(gitUtils, bazel) { | ||
buildNode(gitUtils) { | ||
stage('Code Check') { | ||
sh('script/check-style') | ||
} | ||
bazel.updateBazelRc() | ||
stage('Bazel Fetch') { | ||
bazel.fetch('-k //...') | ||
} | ||
stage('Bazel Build') { | ||
bazel.build('//...') | ||
} | ||
stage('Bazel Tests') { | ||
bazel.test('//...') | ||
} | ||
stage('Push Test Binary') { | ||
sh 'script/release-binary' | ||
} | ||
} | ||
} | ||
|
||
def postsubmit(gitUtils, bazel, utils) { | ||
buildNode(gitUtils) { | ||
bazel.updateBazelRc() | ||
stage('Push Binary') { | ||
sh 'script/release-binary' | ||
} | ||
stage('Docker Push') { | ||
def images = 'proxy,proxy_debug' | ||
def tags = "${gitUtils.GIT_SHORT_SHA},\$(date +%Y-%m-%d-%H.%M.%S),latest" | ||
utils.publishDockerImages(images, tags, 'release') | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the trailing icon? |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,6 +150,8 @@ class JwtValidatorImpl : public JwtValidator { | |
RSA *rsa_; | ||
EVP_PKEY *pkey_; | ||
EVP_MD_CTX *md_ctx_; | ||
|
||
grpc_exec_ctx exec_ctx_; | ||
}; | ||
|
||
// Gets EVP_MD mapped from an alg (algorithm string). | ||
|
@@ -159,12 +161,12 @@ const EVP_MD *EvpMdFromAlg(const char *alg); | |
size_t HashSizeFromAlg(const char *alg); | ||
|
||
// Parses str into grpc_json object. Does not own buffer. | ||
grpc_json *DecodeBase64AndParseJson(const char *str, size_t len, | ||
gpr_slice *buffer); | ||
grpc_json *DecodeBase64AndParseJson(grpc_exec_ctx *exec_ctx, const char *str, | ||
size_t len, gpr_slice *buffer); | ||
|
||
// Gets BIGNUM from b64 string, used for extracting pkey from jwk. | ||
// Result owned by rsa_. | ||
BIGNUM *BigNumFromBase64String(const char *b64); | ||
BIGNUM *BigNumFromBase64String(grpc_exec_ctx *exec_ctx, const char *b64); | ||
|
||
} // namespace | ||
|
||
|
@@ -185,7 +187,8 @@ JwtValidatorImpl::JwtValidatorImpl(const char *jwt, size_t jwt_len) | |
x509_(nullptr), | ||
rsa_(nullptr), | ||
pkey_(nullptr), | ||
md_ctx_(nullptr) { | ||
md_ctx_(nullptr), | ||
exec_ctx_(GRPC_EXEC_CTX_INIT) { | ||
header_buffer_ = gpr_empty_slice(); | ||
signed_buffer_ = gpr_empty_slice(); | ||
sig_buffer_ = gpr_empty_slice(); | ||
|
@@ -204,7 +207,7 @@ JwtValidatorImpl::~JwtValidatorImpl() { | |
grpc_json_destroy(pkey_json_); | ||
} | ||
if (claims_ != nullptr) { | ||
grpc_jwt_claims_destroy(claims_); | ||
grpc_jwt_claims_destroy(&exec_ctx_, claims_); | ||
} | ||
if (!GPR_SLICE_IS_EMPTY(header_buffer_)) { | ||
gpr_slice_unref(header_buffer_); | ||
|
@@ -304,7 +307,8 @@ grpc_jwt_verifier_status JwtValidatorImpl::ParseImpl() { | |
if (dot == nullptr) { | ||
return GRPC_JWT_VERIFIER_BAD_FORMAT; | ||
} | ||
header_json_ = DecodeBase64AndParseJson(cur, dot - cur, &header_buffer_); | ||
header_json_ = | ||
DecodeBase64AndParseJson(&exec_ctx_, cur, dot - cur, &header_buffer_); | ||
CreateJoseHeader(); | ||
if (header_ == nullptr) { | ||
return GRPC_JWT_VERIFIER_BAD_FORMAT; | ||
|
@@ -323,7 +327,7 @@ grpc_jwt_verifier_status JwtValidatorImpl::ParseImpl() { | |
// case, and it is owned by claims_ for successful case. | ||
gpr_slice claims_buffer = gpr_empty_slice(); | ||
grpc_json *claims_json = | ||
DecodeBase64AndParseJson(cur, dot - cur, &claims_buffer); | ||
DecodeBase64AndParseJson(&exec_ctx_, cur, dot - cur, &claims_buffer); | ||
if (claims_json == nullptr) { | ||
if (!GPR_SLICE_IS_EMPTY(claims_buffer)) { | ||
gpr_slice_unref(claims_buffer); | ||
|
@@ -332,10 +336,13 @@ grpc_jwt_verifier_status JwtValidatorImpl::ParseImpl() { | |
} | ||
UpdateAudience(claims_json); | ||
// Takes ownershp of claims_json and claims_buffer. | ||
claims_ = grpc_jwt_claims_from_json(claims_json, claims_buffer); | ||
if (claims_ == nullptr) { | ||
claims_ = grpc_jwt_claims_from_json(&exec_ctx_, claims_json, claims_buffer); | ||
|
||
// issuer is mandatory. grpc_jwt_claims_issuer checks if claims_ is nullptr. | ||
if (grpc_jwt_claims_issuer(claims_) == nullptr) { | ||
return GRPC_JWT_VERIFIER_BAD_FORMAT; | ||
} | ||
|
||
// Check timestamp. | ||
// Passing in its own audience to skip audience check. | ||
// Audience check should be done by the caller. | ||
|
@@ -354,8 +361,8 @@ grpc_jwt_verifier_status JwtValidatorImpl::ParseImpl() { | |
return GRPC_JWT_VERIFIER_BAD_FORMAT; | ||
} | ||
cur = dot + 1; | ||
sig_buffer_ = | ||
grpc_base64_decode_with_len(cur, jwt_len - signed_jwt_len - 1, 1); | ||
sig_buffer_ = grpc_base64_decode_with_len(&exec_ctx_, cur, | ||
jwt_len - signed_jwt_len - 1, 1); | ||
if (GPR_SLICE_IS_EMPTY(sig_buffer_)) { | ||
return GRPC_JWT_VERIFIER_BAD_FORMAT; | ||
} | ||
|
@@ -576,9 +583,11 @@ bool JwtValidatorImpl::ExtractPubkeyFromJwk(const grpc_json *jkey) { | |
} | ||
|
||
const char *rsa_n = GetStringValue(jkey, "n"); | ||
rsa_->n = rsa_n == nullptr ? nullptr : BigNumFromBase64String(rsa_n); | ||
rsa_->n = | ||
rsa_n == nullptr ? nullptr : BigNumFromBase64String(&exec_ctx_, rsa_n); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if it the right format, can you double check by clang-format? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a merge from master. I am not going to change anything here since these changes your are proposing should be done in master. |
||
const char *rsa_e = GetStringValue(jkey, "e"); | ||
rsa_->e = rsa_e == nullptr ? nullptr : BigNumFromBase64String(rsa_e); | ||
rsa_->e = | ||
rsa_e == nullptr ? nullptr : BigNumFromBase64String(&exec_ctx_, rsa_e); | ||
|
||
if (rsa_->e == nullptr || rsa_->n == nullptr) { | ||
gpr_log(GPR_ERROR, "Missing RSA public key field."); | ||
|
@@ -651,7 +660,7 @@ grpc_jwt_verifier_status JwtValidatorImpl::VerifyHsSignature(const char *pkey, | |
const EVP_MD *md = EvpMdFromAlg(header_->alg); | ||
GPR_ASSERT(md != nullptr); // Checked before. | ||
|
||
pkey_buffer_ = grpc_base64_decode_with_len(pkey, pkey_len, 1); | ||
pkey_buffer_ = grpc_base64_decode_with_len(&exec_ctx_, pkey, pkey_len, 1); | ||
if (GPR_SLICE_IS_EMPTY(pkey_buffer_)) { | ||
gpr_log(GPR_ERROR, "Unable to decode base64 of secret"); | ||
return GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR; | ||
|
@@ -742,11 +751,11 @@ size_t HashSizeFromAlg(const char *alg) { | |
} | ||
} | ||
|
||
grpc_json *DecodeBase64AndParseJson(const char *str, size_t len, | ||
gpr_slice *buffer) { | ||
grpc_json *DecodeBase64AndParseJson(grpc_exec_ctx *exec_ctx, const char *str, | ||
size_t len, gpr_slice *buffer) { | ||
grpc_json *json; | ||
|
||
*buffer = grpc_base64_decode_with_len(str, len, 1); | ||
*buffer = grpc_base64_decode_with_len(exec_ctx, str, len, 1); | ||
if (GPR_SLICE_IS_EMPTY(*buffer)) { | ||
gpr_log(GPR_ERROR, "Invalid base64."); | ||
return nullptr; | ||
|
@@ -760,12 +769,12 @@ grpc_json *DecodeBase64AndParseJson(const char *str, size_t len, | |
return json; | ||
} | ||
|
||
BIGNUM *BigNumFromBase64String(const char *b64) { | ||
BIGNUM *BigNumFromBase64String(grpc_exec_ctx *exec_ctx, const char *b64) { | ||
BIGNUM *result = nullptr; | ||
gpr_slice bin; | ||
|
||
if (b64 == nullptr) return nullptr; | ||
bin = grpc_base64_decode(b64, 1); | ||
bin = grpc_base64_decode(exec_ctx, b64, 1); | ||
if (GPR_SLICE_IS_EMPTY(bin)) { | ||
gpr_log(GPR_ERROR, "Invalid base64 for big num."); | ||
return nullptr; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a merge from master. Please look at the exact file from master branch: I am not going to change any of the code merged. This will cause more conflicts later when we merge from / to master again. All these suggestion should be fixed only in master.
https://github.com/istio/proxy/blob/master/.gitignore