78
78
#define FLB_OCI_MATCH_PREFIX "oci_match_"
79
79
#define FLB_OCI_MATCH_PREFIX_SIZE sizeof(FLB_OCI_MATCH_PREFIX)-1
80
80
81
+ #define FLB_OCI_LOG_TIMEZONE_KEY "oci_la_timezone"
82
+ #define FLB_OCI_LOG_TIMEZONE_KEY_SIZE sizeof(FLB_OCI_LOG_TIMEZONE_KEY) - 1
83
+
84
+ #define FLB_OCI_LOG_TIMEZONE "timezone"
85
+ #define FLB_OCI_LOG_TIMEZONE_SIZE sizeof(FLB_OCI_LOG_TIMEZONE) - 1
86
+
81
87
#ifdef FLB_HAVE_REGEX
82
88
#define FLB_OCI_MATCH_REGEX_PREFIX "oci_match_regex_"
83
89
#define FLB_OCI_MATCH_REGEX_PREFIX_SIZE sizeof(FLB_OCI_MATCH_REGEX_PREFIX)-1
97
103
#define FLB_OCI_PARAM_INCLUDE_COLLECT_TIME "include_collect_time"
98
104
#define FLB_OCI_PARAM_INCLUDE_COLLECT_TIME_SIZE sizeof(FLB_OCI_PARAM_INCLUDE_COLLECT_TIME)-1
99
105
100
- #define FLB_OCI_MATCH_ID_MAX 1000 // TO avoid too large memory allocation
106
+ #define FLB_OCI_MATCH_ID_MAX 1000 // TO avoid too large memory allocation
101
107
102
108
#define FLB_OCI_DEFAULT_COLLECT_TIME "oci_collect_time"
103
109
#define FLB_OCI_DEFAULT_COLLECT_TIME_SIZE sizeof(FLB_OCI_DEFAULT_COLLECT_TIME)-1
150
156
#define FLB_OCI_ERROR_CODE_TOO_MANY_REQUESTS "TooManyRequests"
151
157
#define FLB_OCI_ERROR_CODE_INTERNAL_SERVER_ERROR "InternalServerError"
152
158
159
+ /* for imds request*/
160
+ #define ORACLE_IMDS_HOST "169.254.169.254"
161
+ #define ORACLE_IMDS_BASE_URL "/opc/v2"
162
+ #define ORACLE_IMDS_REGION_PATH "/instance/region"
163
+ #define ORACLE_IMDS_LEAF_CERT_PATH "/identity/cert.pem"
164
+ #define ORACLE_IMDS_LEAF_KEY_PATH "/identity/key.pem"
165
+ #define ORACLE_IMDS_INTERMEDIATE_CERT_PATH "/identity/intermediate.pem"
166
+ #define ORACLE_AUTH_HEADER "Authorization: Bearer Oracle"
167
+ #define ORACLE_IMDS_TOKEN_PATH "/opc/v2/instancePrincipal/token"
168
+
169
+
170
+ #define COUNT_OF_REGION (sizeof(region_mappings) / sizeof(region_mappings[0]) - 1)
171
+
172
+ /* for chunking */
173
+ #define MAX_PAYLOAD_SIZE_BYTES (3800000) // 3.8 mb
174
+
153
175
#include <fluent-bit/flb_upstream.h>
154
176
#include <fluent-bit/flb_sds.h>
155
177
#include <fluent-bit/flb_record_accessor.h>
156
178
#include <fluent-bit/flb_hash_table.h>
179
+ #include <fluent-bit/flb_output_plugin.h>
180
+ #include <fluent-bit/flb_upstream.h>
181
+ #include <fluent-bit/flb_upstream_conn.h>
182
+ #include <fluent-bit/flb_http_client.h>
183
+ #include <fluent-bit/flb_log_event_decoder.h>
184
+ #include <fluent-bit/flb_hash_table.h>
185
+ #include <fluent-bit/flb_pack.h>
186
+ #include <fluent-bit/flb_crypto.h>
187
+ #include <fluent-bit/flb_base64.h>
188
+ #include <fluent-bit/flb_hash.h>
189
+ #include <fluent-bit/flb_sds.h>
157
190
#include <monkey/mk_core/mk_list.h>
158
-
159
- struct metadata_obj {
191
+ #include <fluent-bit/flb_jsmn.h>
192
+ #include <openssl/evp.h>
193
+ #include <openssl/pem.h>
194
+ #include <openssl/bio.h>
195
+ #include <openssl/buffer.h>
196
+ #include <openssl/opensslv.h>
197
+ #include <openssl/err.h>
198
+ #include <openssl/x509v3.h>
199
+ #include <openssl/x509.h>
200
+ #include <openssl/rsa.h>
201
+ #include <msgpack.h>
202
+ #include <string.h>
203
+
204
+ struct metadata_obj
205
+ {
160
206
flb_sds_t key ;
161
207
flb_sds_t val ;
162
208
struct mk_list _head ;
@@ -165,23 +211,65 @@ struct metadata_obj {
165
211
166
212
struct flb_oci_error_response
167
213
{
168
- flb_sds_t code ;
169
- flb_sds_t message ;
214
+ flb_sds_t code ;
215
+ flb_sds_t message ;
216
+ };
217
+
218
+ struct flb_oracle_imds
219
+ {
220
+ flb_sds_t region ;
221
+ flb_sds_t leaf_cert ;
222
+ flb_sds_t leaf_key ;
223
+ flb_sds_t intermediate_cert ;
224
+ flb_sds_t tenancy_ocid ;
225
+ flb_sds_t fingerprint ;
226
+ flb_sds_t session_pubkey ;
227
+ flb_sds_t session_privkey ;
228
+ struct flb_upstream * upstream ;
229
+ struct flb_output_instance * ins ;
170
230
};
171
231
172
- struct flb_oci_logan {
232
+ struct oci_security_token
233
+ {
234
+ flb_sds_t token ;
235
+ time_t expires_at ;
236
+ flb_sds_t session_privkey ;
237
+ };
238
+
239
+ typedef struct
240
+ {
241
+ const char * region ;
242
+ const char * realm ;
243
+ } region_realm_mapping_t ;
244
+
245
+ typedef struct
246
+ {
247
+ const char * short_name ;
248
+ const char * long_name ;
249
+ } region_mapping_t ;
250
+
251
+ typedef struct
252
+ {
253
+ const char * realm_code ;
254
+ const char * domain_suffix ;
255
+ } realm_mapping_t ;
256
+
257
+ struct flb_oci_logan
258
+ {
173
259
flb_sds_t namespace ;
174
260
flb_sds_t config_file_location ;
175
261
flb_sds_t profile_name ;
176
262
int oci_config_in_record ;
177
263
flb_sds_t uri ;
178
264
265
+ char * domain_suffix ;
179
266
struct flb_upstream * u ;
180
267
flb_sds_t proxy ;
181
268
char * proxy_host ;
182
269
int proxy_port ;
183
270
184
271
// oci_la_* configs
272
+
185
273
flb_sds_t oci_la_entity_id ;
186
274
187
275
flb_sds_t oci_la_entity_type ;
@@ -194,22 +282,37 @@ struct flb_oci_logan {
194
282
195
283
flb_sds_t oci_la_log_set_id ;
196
284
285
+ flb_sds_t oci_la_timezone ;
286
+
197
287
struct mk_list * oci_la_global_metadata ;
198
288
struct mk_list global_metadata_fields ;
199
289
struct mk_list * oci_la_metadata ;
200
290
struct mk_list log_event_metadata_fields ;
201
291
202
- // config_file
292
+ // config_file
203
293
flb_sds_t user ;
204
294
flb_sds_t region ;
205
295
flb_sds_t tenancy ;
206
296
flb_sds_t key_fingerprint ;
207
297
flb_sds_t key_file ;
208
298
/* For OCI signing */
209
- flb_sds_t key_id ; // tenancy/user/key_fingerprint
299
+ flb_sds_t key_id ; // tenancy/user/key_fingerprint
210
300
flb_sds_t private_key ;
211
-
212
301
struct flb_output_instance * ins ;
213
302
303
+ // instance prinicipal auth
304
+ struct flb_oracle_imds imds ;
305
+ EVP_PKEY * session_key_pair ;
306
+ struct oci_security_token security_token ;
307
+ char * auth_type ;
308
+
309
+ // dump payload
310
+ char * payload_files_location ;
311
+ bool dump_payload_file ;
214
312
};
313
+
314
+ int is_valid_timezone (const char * log_timezone );
315
+ const char * get_domain_suffix_for_realm (const char * realm );
316
+ const char * determine_realm_from_region (const char * region );
317
+ const char * long_region_name (char * short_region_name );
215
318
#endif
0 commit comments