1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* rgw_crypt_sanitize.cc
*
* Created on: Mar 3, 2017
* Author: adam
*/
#include "rgw_common.h"
#include "rgw_crypt_sanitize.h"
#include "boost/algorithm/string/predicate.hpp"
namespace rgw {
namespace crypt_sanitize {
const char* HTTP_X_AMZ_SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY = "HTTP_X_AMZ_SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY";
const char* x_amz_server_side_encryption_customer_key = "x-amz-server-side-encryption-customer-key";
const char* dollar_x_amz_server_side_encryption_customer_key = "$x-amz-server-side-encryption-customer-key";
const char* suppression_message = "=suppressed due to key presence=";
std::ostream& operator<<(std::ostream& out, const env& e) {
if (g_ceph_context->_conf->rgw_crypt_suppress_logs) {
if (boost::algorithm::iequals(
e.name,
HTTP_X_AMZ_SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY))
{
out << suppression_message;
return out;
}
if (boost::algorithm::iequals(e.name, "QUERY_STRING") &&
boost::algorithm::ifind_first(
e.value,
x_amz_server_side_encryption_customer_key))
{
out << suppression_message;
return out;
}
}
out << e.value;
return out;
}
std::ostream& operator<<(std::ostream& out, const x_meta_map& x) {
if (g_ceph_context->_conf->rgw_crypt_suppress_logs &&
boost::algorithm::iequals(x.name, x_amz_server_side_encryption_customer_key))
{
out << suppression_message;
return out;
}
out << x.value;
return out;
}
std::ostream& operator<<(std::ostream& out, const s3_policy& x) {
if (g_ceph_context->_conf->rgw_crypt_suppress_logs &&
boost::algorithm::iequals(x.name, dollar_x_amz_server_side_encryption_customer_key))
{
out << suppression_message;
return out;
}
out << x.value;
return out;
}
std::ostream& operator<<(std::ostream& out, const auth& x) {
if (g_ceph_context->_conf->rgw_crypt_suppress_logs &&
x.s->info.env->get(HTTP_X_AMZ_SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY, nullptr) != nullptr)
{
out << suppression_message;
return out;
}
out << x.value;
return out;
}
std::ostream& operator<<(std::ostream& out, const log_content& x) {
if (g_ceph_context->_conf->rgw_crypt_suppress_logs &&
boost::algorithm::ifind_first(x.buf, x_amz_server_side_encryption_customer_key)) {
out << suppression_message;
return out;
}
out << x.buf;
return out;
}
}
}
|