@voxgig/sdkgen 4.49.1 → 4.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/voxgig-sdkgen +1 -1
- package/package.json +1 -1
- package/project/.sdk/model/feature/cache.aontu +6 -4
- package/project/.sdk/model/target/lua.aontu +6 -0
- package/project/.sdk/src/cmp/c/Config_c.ts +3 -134
- package/project/.sdk/src/cmp/c/TestClean_c.ts +14 -0
- package/project/.sdk/src/cmp/clojure/TestClean_clojure.ts +10 -5
- package/project/.sdk/src/cmp/cpp/TestClean_cpp.ts +13 -0
- package/project/.sdk/src/cmp/csharp/TestClean_csharp.ts +9 -0
- package/project/.sdk/src/cmp/elixir/TestClean_elixir.ts +11 -3
- package/project/.sdk/src/cmp/go/TestClean_go.ts +39 -3
- package/project/.sdk/src/cmp/java/TestClean_java.ts +8 -0
- package/project/.sdk/src/cmp/js/TestClean_js.ts +13 -5
- package/project/.sdk/src/cmp/kotlin/TestClean_kotlin.ts +22 -0
- package/project/.sdk/src/cmp/lua/TestClean_lua.ts +12 -3
- package/project/.sdk/src/cmp/ocaml/TestClean_ocaml.ts +18 -4
- package/project/.sdk/src/cmp/perl/TestClean_perl.ts +12 -3
- package/project/.sdk/src/cmp/php/TestClean_php.ts +10 -3
- package/project/.sdk/src/cmp/py/TestClean_py.ts +10 -3
- package/project/.sdk/src/cmp/rb/TestClean_rb.ts +10 -3
- package/project/.sdk/src/cmp/rust/TestClean_rust.ts +10 -0
- package/project/.sdk/src/cmp/scala/TestClean_scala.ts +34 -0
- package/project/.sdk/src/cmp/swift/TestClean_swift.ts +20 -10
- package/project/.sdk/src/cmp/ts/TestClean_ts.ts +13 -5
- package/project/.sdk/src/cmp/zig/TestClean_zig.ts +12 -0
- package/project/.sdk/tm/c/core/context.c +1 -0
- package/project/.sdk/tm/c/core/sdk.h +7 -4
- package/project/.sdk/tm/c/feature/cache.c +243 -13
- package/project/.sdk/tm/c/feature/debug.c +1 -0
- package/project/.sdk/tm/c/feature/secrets.c +27 -38
- package/project/.sdk/tm/c/feature/telemetry.c +1 -0
- package/project/.sdk/tm/c/tests/feature_test.c +142 -0
- package/project/.sdk/tm/c/utility/clean.c +26 -33
- package/project/.sdk/tm/c/utility/make_options.c +9 -8
- package/project/.sdk/tm/clojure/feature/secrets/sdk/feature/secrets.clj +14 -11
- package/project/.sdk/tm/clojure/src/sdk/client.clj +3 -1
- package/project/.sdk/tm/clojure/src/sdk/core.clj +19 -11
- package/project/.sdk/tm/clojure/src/sdk/features.clj +83 -10
- package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +47 -0
- package/project/.sdk/tm/clojure/test/sdk/test/pipeline.clj +1 -0
- package/project/.sdk/tm/cpp/Makefile +5 -0
- package/project/.sdk/tm/cpp/core/types.hpp +11 -4
- package/project/.sdk/tm/cpp/feature/audit.hpp +6 -7
- package/project/.sdk/tm/cpp/feature/cache.hpp +188 -9
- package/project/.sdk/tm/cpp/feature/debug.hpp +1 -0
- package/project/.sdk/tm/cpp/feature/secrets.hpp +12 -0
- package/project/.sdk/tm/cpp/feature/telemetry.hpp +1 -0
- package/project/.sdk/tm/cpp/test/feature_test.cpp +128 -0
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +9 -7
- package/project/.sdk/tm/csharp/core/Context.cs +4 -0
- package/project/.sdk/tm/csharp/feature/CacheFeature.cs +126 -12
- package/project/.sdk/tm/csharp/feature/DebugFeature.cs +1 -0
- package/project/.sdk/tm/csharp/feature/SecretsFeature.cs +9 -27
- package/project/.sdk/tm/csharp/feature/TelemetryFeature.cs +1 -0
- package/project/.sdk/tm/csharp/test/FeatureTest.cs +101 -0
- package/project/.sdk/tm/csharp/utility/Clean.cs +5 -10
- package/project/.sdk/tm/csharp/utility/Fetcher.cs +7 -1
- package/project/.sdk/tm/csharp/utility/MakeOptions.cs +5 -12
- package/project/.sdk/tm/elixir/lib/projectname/context.ex +2 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/cache.ex +146 -30
- package/project/.sdk/tm/elixir/lib/projectname/feature/debug.ex +1 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/secrets.ex +10 -56
- package/project/.sdk/tm/elixir/lib/projectname/feature/telemetry.ex +1 -0
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +18 -12
- package/project/.sdk/tm/elixir/test/feature_test.exs +84 -0
- package/project/.sdk/tm/go/core/context.go +6 -0
- package/project/.sdk/tm/go/feature/cache_feature.go +131 -4
- package/project/.sdk/tm/go/feature/debug_feature.go +3 -2
- package/project/.sdk/tm/go/feature/secrets_feature.go +17 -71
- package/project/.sdk/tm/go/feature/telemetry_feature.go +5 -4
- package/project/.sdk/tm/go/test/feature_corpus_test.go +150 -2
- package/project/.sdk/tm/go/test/feature_test.go +101 -0
- package/project/.sdk/tm/go/utility/clean.go +5 -7
- package/project/.sdk/tm/go/utility/fetcher.go +11 -0
- package/project/.sdk/tm/go/utility/make_options.go +5 -7
- package/project/.sdk/tm/java/core/Context.java +9 -0
- package/project/.sdk/tm/java/feature/CacheFeature.java +123 -17
- package/project/.sdk/tm/java/feature/DebugFeature.java +1 -0
- package/project/.sdk/tm/java/feature/SecretsFeature.java +9 -92
- package/project/.sdk/tm/java/feature/TelemetryFeature.java +1 -0
- package/project/.sdk/tm/java/test/FeatureCorpusTest.java +141 -2
- package/project/.sdk/tm/java/test/FeatureTest.java +88 -0
- package/project/.sdk/tm/java/utility/Clean.java +6 -10
- package/project/.sdk/tm/java/utility/Fetcher.java +5 -1
- package/project/.sdk/tm/java/utility/MakeOptions.java +3 -1
- package/project/.sdk/tm/js/src/Context.js +4 -0
- package/project/.sdk/tm/js/src/feature/cache/CacheFeature.js +118 -11
- package/project/.sdk/tm/js/src/feature/cost/CostFeature.js +3 -2
- package/project/.sdk/tm/js/src/feature/debug/DebugFeature.js +1 -0
- package/project/.sdk/tm/js/src/feature/metrics/MetricsFeature.js +1 -1
- package/project/.sdk/tm/js/src/feature/paging/PagingFeature.js +4 -4
- package/project/.sdk/tm/js/src/feature/rbac/RbacFeature.js +4 -4
- package/project/.sdk/tm/js/src/feature/secrets/SecretsFeature.js +16 -6
- package/project/.sdk/tm/js/src/feature/telemetry/TelemetryFeature.js +1 -0
- package/project/.sdk/tm/js/src/feature/validate/ValidateFeature.js +2 -1
- package/project/.sdk/tm/js/src/utility/CleanUtility.js +1 -1
- package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +6 -6
- package/project/.sdk/tm/js/test/feature/Corpus.test.js +100 -2
- package/project/.sdk/tm/js/test/feature/harness.js +3 -3
- package/project/.sdk/tm/js/test/feature.test.js +17 -0
- package/project/.sdk/tm/js/test/pipeline.test.js +1 -1
- package/project/.sdk/tm/kotlin/core/Context.kt +3 -0
- package/project/.sdk/tm/kotlin/feature/CacheFeature.kt +102 -7
- package/project/.sdk/tm/kotlin/feature/DebugFeature.kt +1 -0
- package/project/.sdk/tm/kotlin/feature/SecretsFeature.kt +10 -20
- package/project/.sdk/tm/kotlin/feature/TelemetryFeature.kt +1 -0
- package/project/.sdk/tm/kotlin/test/FeatureTest.kt +79 -0
- package/project/.sdk/tm/kotlin/utility/CoreUtil.kt +5 -5
- package/project/.sdk/tm/kotlin/utility/Fetcher.kt +4 -0
- package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +3 -1
- package/project/.sdk/tm/lua/core/context.lua +6 -0
- package/project/.sdk/tm/lua/feature/cache_feature.lua +212 -15
- package/project/.sdk/tm/lua/feature/debug_feature.lua +1 -0
- package/project/.sdk/tm/lua/feature/secrets_feature.lua +15 -80
- package/project/.sdk/tm/lua/feature/telemetry_feature.lua +1 -0
- package/project/.sdk/tm/lua/test/feature_test.lua +108 -0
- package/project/.sdk/tm/lua/utility/clean.lua +6 -9
- package/project/.sdk/tm/lua/utility/fetcher.lua +9 -0
- package/project/.sdk/tm/lua/utility/make_options.lua +5 -5
- package/project/.sdk/tm/ocaml/feature/secrets_feature.ml +21 -6
- package/project/.sdk/tm/ocaml/sdk_features.ml +108 -8
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +13 -10
- package/project/.sdk/tm/ocaml/sdk_types.ml +2 -0
- package/project/.sdk/tm/ocaml/test/t_feature.ml +51 -1
- package/project/.sdk/tm/perl/core/context.pm +3 -0
- package/project/.sdk/tm/perl/feature/audit_feature.pm +4 -7
- package/project/.sdk/tm/perl/feature/cache_feature.pm +111 -15
- package/project/.sdk/tm/perl/feature/debug_feature.pm +1 -0
- package/project/.sdk/tm/perl/feature/secrets_feature.pm +13 -18
- package/project/.sdk/tm/perl/feature/telemetry_feature.pm +1 -0
- package/project/.sdk/tm/perl/t/feature.t +86 -0
- package/project/.sdk/tm/perl/t/feature_corpus.t +80 -4
- package/project/.sdk/tm/perl/utility/clean.pm +6 -8
- package/project/.sdk/tm/perl/utility/fetcher.pm +4 -0
- package/project/.sdk/tm/perl/utility/make_options.pm +5 -5
- package/project/.sdk/tm/php/core/Context.php +4 -0
- package/project/.sdk/tm/php/feature/CacheFeature.php +98 -13
- package/project/.sdk/tm/php/feature/DebugFeature.php +1 -0
- package/project/.sdk/tm/php/feature/SecretsFeature.php +18 -15
- package/project/.sdk/tm/php/feature/TelemetryFeature.php +1 -0
- package/project/.sdk/tm/php/test/FeatureCorpusTest.php +113 -3
- package/project/.sdk/tm/php/test/FeatureTest.php +90 -0
- package/project/.sdk/tm/php/utility/Clean.php +3 -10
- package/project/.sdk/tm/php/utility/Fetcher.php +8 -3
- package/project/.sdk/tm/php/utility/MakeOptions.php +5 -7
- package/project/.sdk/tm/py/pkg/core/context.py +4 -0
- package/project/.sdk/tm/py/pkg/feature/cache_feature.py +79 -13
- package/project/.sdk/tm/py/pkg/feature/debug_feature.py +1 -0
- package/project/.sdk/tm/py/pkg/feature/secrets_feature.py +15 -66
- package/project/.sdk/tm/py/pkg/feature/telemetry_feature.py +1 -0
- package/project/.sdk/tm/py/pkg/utility/clean.py +4 -10
- package/project/.sdk/tm/py/pkg/utility/make_options.py +8 -9
- package/project/.sdk/tm/py/test/feature/secrets/test_secrets.py +23 -9
- package/project/.sdk/tm/py/test/test_feature.py +73 -0
- package/project/.sdk/tm/py/test/test_feature_corpus.py +88 -3
- package/project/.sdk/tm/rb/core/context.rb +4 -1
- package/project/.sdk/tm/rb/feature/audit_feature.rb +6 -5
- package/project/.sdk/tm/rb/feature/cache_feature.rb +75 -11
- package/project/.sdk/tm/rb/feature/debug_feature.rb +1 -0
- package/project/.sdk/tm/rb/feature/secrets_feature.rb +9 -64
- package/project/.sdk/tm/rb/feature/telemetry_feature.rb +1 -0
- package/project/.sdk/tm/rb/test/feature_corpus_test.rb +85 -3
- package/project/.sdk/tm/rb/test/feature_test.rb +93 -0
- package/project/.sdk/tm/rb/utility/clean.rb +6 -7
- package/project/.sdk/tm/rb/utility/fetcher.rb +6 -0
- package/project/.sdk/tm/rb/utility/make_options.rb +5 -5
- package/project/.sdk/tm/rust/core/context.rs +8 -0
- package/project/.sdk/tm/rust/feature/cache.rs +120 -3
- package/project/.sdk/tm/rust/feature/debug.rs +1 -0
- package/project/.sdk/tm/rust/feature/secrets.rs +36 -98
- package/project/.sdk/tm/rust/feature/telemetry.rs +1 -0
- package/project/.sdk/tm/rust/tests/feature/secrets/main.rs +3 -3
- package/project/.sdk/tm/rust/tests/feature_test.rs +141 -0
- package/project/.sdk/tm/rust/utility/clean.rs +35 -43
- package/project/.sdk/tm/rust/utility/fetcher.rs +6 -0
- package/project/.sdk/tm/rust/utility/make_options.rs +8 -11
- package/project/.sdk/tm/scala/core/Context.scala +4 -0
- package/project/.sdk/tm/scala/feature/CacheFeature.scala +117 -11
- package/project/.sdk/tm/scala/feature/DebugFeature.scala +1 -0
- package/project/.sdk/tm/scala/feature/SecretsFeature.scala +11 -24
- package/project/.sdk/tm/scala/feature/TelemetryFeature.scala +1 -0
- package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +52 -1
- package/project/.sdk/tm/scala/utility/Fetcher.scala +5 -0
- package/project/.sdk/tm/scala/utility/Make.scala +3 -1
- package/project/.sdk/tm/scala/utility/Misc.scala +5 -8
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Context.swift +3 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/CacheFeature.swift +122 -11
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/DebugFeature.swift +1 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/SecretsFeature.swift +9 -13
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TelemetryFeature.swift +1 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Fetcher.swift +4 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +5 -4
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/ResultUtil.swift +4 -5
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +79 -0
- package/project/.sdk/tm/ts/src/Context.ts +4 -0
- package/project/.sdk/tm/ts/src/feature/cache/CacheFeature.ts +115 -4
- package/project/.sdk/tm/ts/src/feature/cost/CostFeature.ts +3 -2
- package/project/.sdk/tm/ts/src/feature/debug/DebugFeature.ts +1 -0
- package/project/.sdk/tm/ts/src/feature/metrics/MetricsFeature.ts +1 -1
- package/project/.sdk/tm/ts/src/feature/paging/PagingFeature.ts +4 -4
- package/project/.sdk/tm/ts/src/feature/rbac/RbacFeature.ts +4 -4
- package/project/.sdk/tm/ts/src/feature/secrets/SecretsFeature.ts +14 -2
- package/project/.sdk/tm/ts/src/feature/telemetry/TelemetryFeature.ts +1 -0
- package/project/.sdk/tm/ts/src/feature/validate/ValidateFeature.ts +2 -1
- package/project/.sdk/tm/ts/src/utility/CleanUtility.ts +1 -1
- package/project/.sdk/tm/ts/src/utility/MakeOptionsUtility.ts +6 -6
- package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +101 -2
- package/project/.sdk/tm/ts/test/feature/harness.ts +3 -3
- package/project/.sdk/tm/ts/test/feature.test.ts +17 -0
- package/project/.sdk/tm/ts/test/pipeline.test.ts +1 -1
- package/project/.sdk/tm/zig/core/context.zig +5 -0
- package/project/.sdk/tm/zig/core/utility.zig +11 -9
- package/project/.sdk/tm/zig/feature/cache.zig +144 -13
- package/project/.sdk/tm/zig/feature/debug.zig +1 -0
- package/project/.sdk/tm/zig/feature/secrets.zig +6 -1
- package/project/.sdk/tm/zig/feature/telemetry.zig +1 -0
- package/project/.sdk/tm/zig/test/feature_test.zig +100 -0
- package/project/sdkgen-package.json +1 -1
|
@@ -125,6 +125,7 @@ static void debug_pre_request(DebugFeature* df, Context* ctx) {
|
|
|
125
125
|
voxgig_value* entry = v_map();
|
|
126
126
|
char* op = dot_join(entity, opname);
|
|
127
127
|
setp(entry, "op", v_str(op));
|
|
128
|
+
setp(entry, "correlationId", v_str(ctx->id));
|
|
128
129
|
setp(entry, "start", v_num((double)fopt_now_call(df->options)));
|
|
129
130
|
if (ctx->spec) {
|
|
130
131
|
Spec* s = ctx->spec;
|
|
@@ -59,12 +59,9 @@
|
|
|
59
59
|
// fails). Conflating the last two is the failure this library exists
|
|
60
60
|
// to prevent.
|
|
61
61
|
//
|
|
62
|
-
// * The exchange
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
// when a plugin group is active, the SDK's own client (utility/http.c)
|
|
66
|
-
// when none is (see Config_c; the generated kinds.mk beside it is what
|
|
67
|
-
// links libcurl on the same condition).
|
|
62
|
+
// * The exchange goes through fetcher_util, the SDK's own transport
|
|
63
|
+
// beneath every feature's wrapper: options.system.fetch when supplied,
|
|
64
|
+
// else the SDK's own client (utility/http.c).
|
|
68
65
|
//
|
|
69
66
|
// * sek_new is documented NOT REENTRANT (a file-scope slot for the
|
|
70
67
|
// duration of the call). It runs once, in the client constructor,
|
|
@@ -85,13 +82,6 @@
|
|
|
85
82
|
#include <stdlib.h>
|
|
86
83
|
#include <string.h>
|
|
87
84
|
|
|
88
|
-
// The exchange transport of last resort, defined in the GENERATED
|
|
89
|
-
// feature/secrets/kinds.c (Config_c) - libcurl when a plugin group is
|
|
90
|
-
// active, the SDK's own client otherwise. Prototyped here rather than in
|
|
91
|
-
// sdk.h because core/ must not know a gated feature's internals.
|
|
92
|
-
voxgig_value* secrets_rawfetch(Context* ctx, const char* url,
|
|
93
|
-
voxgig_value* fetchdef, PNError** err);
|
|
94
|
-
|
|
95
85
|
typedef struct {
|
|
96
86
|
const char* path;
|
|
97
87
|
const char* method;
|
|
@@ -120,6 +110,8 @@ typedef struct {
|
|
|
120
110
|
// The LIVE options map (root ctx options): read for `apikey` and `auth`,
|
|
121
111
|
// never written.
|
|
122
112
|
voxgig_value* liveopts;
|
|
113
|
+
// The client's clean registry, which a resolved value joins.
|
|
114
|
+
voxgig_value* cleancfg;
|
|
123
115
|
|
|
124
116
|
// What prepare_auth was generated from: the config declares auth only
|
|
125
117
|
// where it places a credential, and Basic only where it composes one.
|
|
@@ -144,6 +136,9 @@ typedef struct {
|
|
|
144
136
|
|
|
145
137
|
SecretsExchange* exchange;
|
|
146
138
|
char* refresh;
|
|
139
|
+
// The transport's refusal of the last purchase, which the gate answers
|
|
140
|
+
// in place of a resolution error.
|
|
141
|
+
PNError* refused;
|
|
147
142
|
|
|
148
143
|
SecretsTrack track;
|
|
149
144
|
} SecretsFeature;
|
|
@@ -345,7 +340,7 @@ static void secrets_reauth(SecretsFeature* f, voxgig_value* fetchdef) {
|
|
|
345
340
|
snprintf(pair, n, "%s:%s", f->cred, secret);
|
|
346
341
|
value = clean_base64(pair);
|
|
347
342
|
free(pair);
|
|
348
|
-
if (NULL != value)
|
|
343
|
+
if (NULL != value) clean_add_cfg(f->cleancfg, value);
|
|
349
344
|
} else {
|
|
350
345
|
value = strdup(f->cred);
|
|
351
346
|
}
|
|
@@ -375,7 +370,7 @@ static void secrets_reauth(SecretsFeature* f, voxgig_value* fetchdef) {
|
|
|
375
370
|
static void secrets_setcred(SecretsFeature* f, const char* value) {
|
|
376
371
|
free(f->cred);
|
|
377
372
|
f->cred = strdup(NULL == value ? "" : value);
|
|
378
|
-
if ('\0' != f->cred[0])
|
|
373
|
+
if ('\0' != f->cred[0]) clean_add_cfg(f->cleancfg, f->cred);
|
|
379
374
|
}
|
|
380
375
|
|
|
381
376
|
// ---- the exchange -----------------------------------------------------------
|
|
@@ -449,25 +444,23 @@ static char* secrets_moved(sek_pool* pool, const char* url, const char* at, voxg
|
|
|
449
444
|
return secrets_origin(next, to, sizeof(to), NULL) && 0 == strcmp(own, to) ? next : NULL;
|
|
450
445
|
}
|
|
451
446
|
|
|
452
|
-
// One request of the exchange
|
|
453
|
-
//
|
|
454
|
-
|
|
447
|
+
// One request of the exchange, through the SDK's own transport beneath every
|
|
448
|
+
// feature's wrapper: it holds the test feature's block and the GET-only
|
|
449
|
+
// guard, and its refusal is kept for the gate. A pool-owned message on failure.
|
|
450
|
+
static const char* secrets_send(SecretsFeature* f, Context* ctx,
|
|
455
451
|
const char* url, voxgig_value* fetchdef, voxgig_value** res) {
|
|
456
|
-
if (voxgig_is_func(sys_fetch)) {
|
|
457
|
-
*res = call_vfn(sys_fetch, clist(2, v_str(url), v_share(fetchdef)));
|
|
458
|
-
const char* emsg = get_str(*res, "__err__");
|
|
459
|
-
return NULL == emsg ? NULL : sek_strdup(f->pool, emsg);
|
|
460
|
-
}
|
|
461
452
|
PNError* ferr = NULL;
|
|
462
|
-
*res =
|
|
463
|
-
|
|
464
|
-
|
|
453
|
+
*res = fetcher_util(NULL, ctx, url, fetchdef, &ferr);
|
|
454
|
+
if (NULL == ferr) return NULL;
|
|
455
|
+
f->refused = ferr;
|
|
456
|
+
return sek_strdup(f->pool, ferr->msg ? ferr->msg : "secrets: transport failed");
|
|
465
457
|
}
|
|
466
458
|
|
|
467
459
|
// Buy an access token with the refresh token. Answers sekreto-style: a
|
|
468
460
|
// pool-owned message, or NULL for success with the token in f->cred.
|
|
469
461
|
static const char* secrets_buy(SecretsFeature* f, Context* ctx) {
|
|
470
462
|
SecretsExchange* x = f->exchange;
|
|
463
|
+
f->refused = NULL;
|
|
471
464
|
|
|
472
465
|
// TEST MODE BUYS NOTHING. The test feature replaces the transport so no
|
|
473
466
|
// request leaves the process; an exchange here would be the one HTTP
|
|
@@ -518,15 +511,8 @@ static const char* secrets_buy(SecretsFeature* f, Context* ctx) {
|
|
|
518
511
|
"body", v_str(bodytext),
|
|
519
512
|
"redirect", v_str("manual"));
|
|
520
513
|
|
|
521
|
-
// Deliberately NOT the SDK transport. The transport is what this feature
|
|
522
|
-
// wraps, and sending the token request back through it would recurse on
|
|
523
|
-
// the first expiry - and would route the exchange through the test mock,
|
|
524
|
-
// which knows nothing about it. options.system.fetch when the caller
|
|
525
|
-
// supplied one (the seam every live c request already uses), else the
|
|
526
|
-
// bundled transport of last resort from the generated kinds.c.
|
|
527
|
-
voxgig_value* sys_fetch = getpath2(options, "system", "fetch");
|
|
528
514
|
voxgig_value* res = NULL;
|
|
529
|
-
const char* sent = secrets_send(f, ctx,
|
|
515
|
+
const char* sent = secrets_send(f, ctx, url, fetchdef, &res);
|
|
530
516
|
if (NULL != sent) return sent;
|
|
531
517
|
|
|
532
518
|
// By option alone, and only while the exchange stays on its own origin.
|
|
@@ -535,7 +521,7 @@ static const char* secrets_buy(SecretsFeature* f, Context* ctx) {
|
|
|
535
521
|
char* next = secrets_moved(f->pool, url, at, res);
|
|
536
522
|
if (NULL == next) break;
|
|
537
523
|
at = next;
|
|
538
|
-
sent = secrets_send(f, ctx,
|
|
524
|
+
sent = secrets_send(f, ctx, at, fetchdef, &res);
|
|
539
525
|
if (NULL != sent) return sent;
|
|
540
526
|
}
|
|
541
527
|
|
|
@@ -612,7 +598,7 @@ static const char* secrets_resolve(SecretsFeature* f, Context* ctx) {
|
|
|
612
598
|
// say whether it does.
|
|
613
599
|
free(f->refresh);
|
|
614
600
|
f->refresh = strdup(found ? found : "");
|
|
615
|
-
if ('\0' != f->refresh[0])
|
|
601
|
+
if ('\0' != f->refresh[0]) clean_add_cfg(f->cleancfg, f->refresh);
|
|
616
602
|
|
|
617
603
|
if ('\0' == f->cred[0]) {
|
|
618
604
|
// A starting access token supplied as the OPTION: read from the frozen
|
|
@@ -655,7 +641,8 @@ static voxgig_value* secrets_fetch(Fetcher* self, Context* ctx, const char* url,
|
|
|
655
641
|
const char* rerr = secrets_resolve(f, ctx);
|
|
656
642
|
if (NULL != rerr) {
|
|
657
643
|
f->track.refused++;
|
|
658
|
-
*err = context_make_error(ctx, "secrets_resolve", rerr);
|
|
644
|
+
*err = NULL != f->refused ? f->refused : context_make_error(ctx, "secrets_resolve", rerr);
|
|
645
|
+
f->refused = NULL;
|
|
659
646
|
return NULL;
|
|
660
647
|
}
|
|
661
648
|
|
|
@@ -701,6 +688,7 @@ static voxgig_value* secrets_fetch(Fetcher* self, Context* ctx, const char* url,
|
|
|
701
688
|
// The purchase failed: answer with the API's own refusal rather
|
|
702
689
|
// than this one. The caller asked for data, and the refusal is
|
|
703
690
|
// the more useful of the two - the exchange error is a symptom.
|
|
691
|
+
f->refused = NULL;
|
|
704
692
|
free(used);
|
|
705
693
|
return out;
|
|
706
694
|
}
|
|
@@ -733,6 +721,7 @@ static void secrets_init(Feature* fb, Context* ctx, voxgig_value* options) {
|
|
|
733
721
|
|
|
734
722
|
f->client = ctx->client;
|
|
735
723
|
f->liveopts = ctx->options;
|
|
724
|
+
f->cleancfg = ctx->cleancfg;
|
|
736
725
|
|
|
737
726
|
voxgig_value* declared = NULL == ctx->config ? NULL : getpath2(ctx->config, "options", "auth");
|
|
738
727
|
f->declared = voxgig_is_map(declared);
|
|
@@ -802,7 +791,7 @@ static void secrets_init(Feature* fb, Context* ctx, voxgig_value* options) {
|
|
|
802
791
|
} else {
|
|
803
792
|
explicit = get_str(xopts, "refresh");
|
|
804
793
|
}
|
|
805
|
-
if (NULL != explicit && '\0' != explicit[0])
|
|
794
|
+
if (NULL != explicit && '\0' != explicit[0]) clean_add_cfg(f->cleancfg, explicit);
|
|
806
795
|
|
|
807
796
|
size_t cap = 4;
|
|
808
797
|
size_t count = 0;
|
|
@@ -116,6 +116,7 @@ static void telemetry_pre_point(TelemetryFeature* tf, Context* ctx) {
|
|
|
116
116
|
char* spanid = telemetry_id(tf, "span");
|
|
117
117
|
setp(span, "spanId", v_str(spanid));
|
|
118
118
|
free(spanid);
|
|
119
|
+
setp(span, "correlationId", v_str(ctx->id));
|
|
119
120
|
|
|
120
121
|
size_t nl = strlen(entity) + strlen(opname) + 2; // '.' + '\0'
|
|
121
122
|
char* namebuf = (char*)malloc(nl);
|
|
@@ -501,6 +501,105 @@ static void test_cache_inactive_does_not_wrap(void) {
|
|
|
501
501
|
CHECK_INT_EQ(rec_count(calls), 2, "cache inactive: 2 calls");
|
|
502
502
|
}
|
|
503
503
|
|
|
504
|
+
uint64_t feature_cache_siphash24(const uint8_t key[16], const uint8_t* in, size_t len);
|
|
505
|
+
|
|
506
|
+
// The reference vectors of the SipHash paper: key 00..0f, message 00..len-1.
|
|
507
|
+
static void test_cache_siphash_matches_the_reference_vectors(void) {
|
|
508
|
+
if (!fh_present("cache")) return;
|
|
509
|
+
static const struct { size_t len; uint64_t want; } vectors[] = {
|
|
510
|
+
{0, 0x726fdb47dd0e0e31ULL},
|
|
511
|
+
{1, 0x74f839c593dc67fdULL},
|
|
512
|
+
{2, 0x0d6c8009d9a94f5aULL},
|
|
513
|
+
{3, 0x85676696d7fb7e2dULL},
|
|
514
|
+
{4, 0xcf2794e0277187b7ULL},
|
|
515
|
+
{5, 0x18765564cd99a68dULL},
|
|
516
|
+
{6, 0xcbc9466e58fee3ceULL},
|
|
517
|
+
{7, 0xab0200f58b01d137ULL},
|
|
518
|
+
{8, 0x93f5f5799a932462ULL},
|
|
519
|
+
{15, 0xa129ca6149be45e5ULL},
|
|
520
|
+
{16, 0x3f2acc7f57c29bdbULL},
|
|
521
|
+
{63, 0x958a324ceb064572ULL}
|
|
522
|
+
};
|
|
523
|
+
uint8_t key[16], msg[64];
|
|
524
|
+
for (int i = 0; i < 16; i++) key[i] = (uint8_t)i;
|
|
525
|
+
for (int i = 0; i < 64; i++) msg[i] = (uint8_t)i;
|
|
526
|
+
for (size_t i = 0; i < sizeof(vectors) / sizeof(vectors[0]); i++) {
|
|
527
|
+
CHECK(feature_cache_siphash24(key, msg, vectors[i].len) == vectors[i].want, "cache: siphash reference vector");
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
static voxgig_value* rep_control(void* ud, int64_t n, voxgig_value* fd, Context* ctx, PNError** e) {
|
|
532
|
+
(void)n; (void)fd; (void)ctx; *e = NULL;
|
|
533
|
+
return fh_response(200, cmap(1, "ok", v_bool(true)),
|
|
534
|
+
cmap(1, "Cache-Control", v_str((const char*)ud)));
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
static FhOpSpec op_load_headers(const char* path, voxgig_value* headers) {
|
|
538
|
+
FhOpSpec o = op_load_path(path); o.headers = headers; return o;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
static void test_cache_keys_on_request_headers(void) {
|
|
542
|
+
if (!fh_present("cache")) return;
|
|
543
|
+
voxgig_value* calls;
|
|
544
|
+
Fetcher* srv = fh_recorder(NULL, NULL, &calls);
|
|
545
|
+
Feature* f = feature_cache_new();
|
|
546
|
+
FhFeat feats[] = {{f, cmap(1, "ttl", v_num(10000))}};
|
|
547
|
+
FhHarness h = fh_make(srv, feats, 1);
|
|
548
|
+
fh_op(&h, op_load_headers("/w/1", cmap(1, "x-tenant", v_str("tenant-a"))));
|
|
549
|
+
fh_op(&h, op_load_headers("/w/1", cmap(1, "X-Tenant", v_str("tenant-b"))));
|
|
550
|
+
CHECK_INT_EQ(rec_count(calls), 2, "cache tenant header: 2 calls");
|
|
551
|
+
fh_op(&h, op_load_headers("/w/1", cmap(1, "x-tenant", v_str("tenant-b"))));
|
|
552
|
+
CHECK_INT_EQ(rec_count(calls), 2, "cache same headers: still 2 calls");
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
static void test_cache_a_write_drops_its_collection(void) {
|
|
556
|
+
if (!fh_present("cache")) return;
|
|
557
|
+
voxgig_value* calls;
|
|
558
|
+
Fetcher* srv = fh_recorder(NULL, NULL, &calls);
|
|
559
|
+
Feature* f = feature_cache_new();
|
|
560
|
+
FhFeat feats[] = {{f, cmap(1, "ttl", v_num(10000))}};
|
|
561
|
+
FhHarness h = fh_make(srv, feats, 1);
|
|
562
|
+
const char* paths[] = {"/w/1", "/w", "/w/1/part", "/other/1", "/w/2"};
|
|
563
|
+
for (int i = 0; i < 5; i++) fh_op(&h, op_load_path(paths[i]));
|
|
564
|
+
FhOpSpec w; memset(&w, 0, sizeof(w)); w.op = "update"; w.method = "PUT"; w.path = "/w/1";
|
|
565
|
+
fh_op(&h, w);
|
|
566
|
+
for (int i = 0; i < 5; i++) fh_op(&h, op_load_path(paths[i]));
|
|
567
|
+
CHECK_INT_EQ(rec_count(calls), 9, "cache write: collection refetched");
|
|
568
|
+
CHECK_INT_EQ(fh_track_int(f, "hit"), 2, "cache write: other entity cached");
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
static void test_cache_control_prevents_storing(void) {
|
|
572
|
+
if (!fh_present("cache")) return;
|
|
573
|
+
const char* controls[] = {"no-store", "private", "No-Cache", "max-age=60, private"};
|
|
574
|
+
for (int i = 0; i < 4; i++) {
|
|
575
|
+
voxgig_value* calls;
|
|
576
|
+
Fetcher* srv = fh_recorder(rep_control, (void*)controls[i], &calls);
|
|
577
|
+
Feature* f = feature_cache_new();
|
|
578
|
+
FhFeat feats[] = {{f, cmap(1, "ttl", v_num(10000))}};
|
|
579
|
+
FhHarness h = fh_make(srv, feats, 1);
|
|
580
|
+
fh_op(&h, op_load_path("/w"));
|
|
581
|
+
fh_op(&h, op_load_path("/w"));
|
|
582
|
+
CHECK_INT_EQ(rec_count(calls), 2, controls[i]);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
static void test_cache_max_age_caps_the_ttl(void) {
|
|
587
|
+
if (!fh_present("cache")) return;
|
|
588
|
+
FhClock clock = fh_clock_new();
|
|
589
|
+
voxgig_value* calls;
|
|
590
|
+
Fetcher* srv = fh_recorder(rep_control, (void*)"max-age=1", &calls);
|
|
591
|
+
Feature* f = feature_cache_new();
|
|
592
|
+
FhFeat feats[] = {{f, cmap(2, "ttl", v_num(10000), "now", fh_now_fn(&clock))}};
|
|
593
|
+
FhHarness h = fh_make(srv, feats, 1);
|
|
594
|
+
fh_op(&h, op_load_path("/w"));
|
|
595
|
+
fh_advance(&clock, 500);
|
|
596
|
+
fh_op(&h, op_load_path("/w"));
|
|
597
|
+
CHECK_INT_EQ(rec_count(calls), 1, "cache max-age: a hit inside max-age");
|
|
598
|
+
fh_advance(&clock, 600);
|
|
599
|
+
fh_op(&h, op_load_path("/w"));
|
|
600
|
+
CHECK_INT_EQ(rec_count(calls), 2, "cache max-age: expired before the ttl");
|
|
601
|
+
}
|
|
602
|
+
|
|
504
603
|
// =============================================================================
|
|
505
604
|
// idempotency
|
|
506
605
|
// =============================================================================
|
|
@@ -882,6 +981,42 @@ static void test_audit_inactive_records_nothing(void) {
|
|
|
882
981
|
CHECK_INT_EQ(fh_track_int(f, "records"), 0, "audit inactive: no records");
|
|
883
982
|
}
|
|
884
983
|
|
|
984
|
+
// =============================================================================
|
|
985
|
+
// one call, one id
|
|
986
|
+
// =============================================================================
|
|
987
|
+
|
|
988
|
+
static void test_telemetry_debug_audit_carry_one_calls_context_id(void) {
|
|
989
|
+
if (!fh_present("telemetry,debug,audit")) return;
|
|
990
|
+
voxgig_value* spans = v_list();
|
|
991
|
+
voxgig_value* entries = v_list();
|
|
992
|
+
voxgig_value* records = v_list();
|
|
993
|
+
Feature* tf = feature_telemetry_new();
|
|
994
|
+
Feature* df = feature_debug_new();
|
|
995
|
+
Feature* af = feature_audit_new();
|
|
996
|
+
FhFeat feats[] = {
|
|
997
|
+
{tf, cmap(1, "exporter", vfn(collect_fn, spans))},
|
|
998
|
+
{df, cmap(1, "onEntry", vfn(collect_fn, entries))},
|
|
999
|
+
{af, cmap(1, "sink", vfn(collect_fn, records))},
|
|
1000
|
+
};
|
|
1001
|
+
FhHarness h = fh_make(NULL, feats, 3);
|
|
1002
|
+
fh_op(&h, op_load());
|
|
1003
|
+
FhOpSpec ol; memset(&ol, 0, sizeof(ol)); ol.op = "list";
|
|
1004
|
+
fh_op(&h, ol);
|
|
1005
|
+
CHECK_INT_EQ((int)voxgig_list_len(voxgig_as_list(records)), 2, "one id: 2 audit records");
|
|
1006
|
+
CHECK_INT_EQ((int)voxgig_list_len(voxgig_as_list(spans)), 2, "one id: 2 spans");
|
|
1007
|
+
CHECK_INT_EQ((int)voxgig_list_len(voxgig_as_list(entries)), 2, "one id: 2 debug entries");
|
|
1008
|
+
const char* calls[2];
|
|
1009
|
+
for (int i = 0; i < 2; i++) {
|
|
1010
|
+
calls[i] = get_str(voxgig_getelem(records, v_int(i), v_undef()), "correlationId");
|
|
1011
|
+
CHECK(calls[i] && calls[i][0] != '\0', "one id: audit id is a non-empty string");
|
|
1012
|
+
CHECK_STR_EQ(get_str(voxgig_getelem(spans, v_int(i), v_undef()), "correlationId"),
|
|
1013
|
+
calls[i], "one id: span id is the audit id");
|
|
1014
|
+
CHECK_STR_EQ(get_str(voxgig_getelem(entries, v_int(i), v_undef()), "correlationId"),
|
|
1015
|
+
calls[i], "one id: debug entry id is the audit id");
|
|
1016
|
+
}
|
|
1017
|
+
CHECK(calls[0] && calls[1] && strcmp(calls[0], calls[1]) != 0, "one id: one id per call");
|
|
1018
|
+
}
|
|
1019
|
+
|
|
885
1020
|
// =============================================================================
|
|
886
1021
|
// clienttrack
|
|
887
1022
|
// =============================================================================
|
|
@@ -1180,6 +1315,11 @@ int main(void) {
|
|
|
1180
1315
|
RUN(test_cache_refetches_after_ttl);
|
|
1181
1316
|
RUN(test_cache_evicts_oldest_past_max);
|
|
1182
1317
|
RUN(test_cache_inactive_does_not_wrap);
|
|
1318
|
+
RUN(test_cache_keys_on_request_headers);
|
|
1319
|
+
RUN(test_cache_a_write_drops_its_collection);
|
|
1320
|
+
RUN(test_cache_control_prevents_storing);
|
|
1321
|
+
RUN(test_cache_max_age_caps_the_ttl);
|
|
1322
|
+
RUN(test_cache_siphash_matches_the_reference_vectors);
|
|
1183
1323
|
// idempotency
|
|
1184
1324
|
RUN(test_idempotency_adds_key_to_mutating_ops);
|
|
1185
1325
|
RUN(test_idempotency_adds_key_by_http_method);
|
|
@@ -1212,6 +1352,8 @@ int main(void) {
|
|
|
1212
1352
|
RUN(test_audit_default_actor_anonymous);
|
|
1213
1353
|
RUN(test_audit_injected_clock);
|
|
1214
1354
|
RUN(test_audit_inactive_records_nothing);
|
|
1355
|
+
// one call, one id
|
|
1356
|
+
RUN(test_telemetry_debug_audit_carry_one_calls_context_id);
|
|
1215
1357
|
// clienttrack
|
|
1216
1358
|
RUN(test_clienttrack_stable_client_id_unique_request_ids_ua);
|
|
1217
1359
|
RUN(test_clienttrack_does_not_clobber_caller_ua);
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
// sensitive KEY name is masked whatever it holds. Inside the pipeline data
|
|
8
8
|
// stays raw, so a hook can still read the header it must add to.
|
|
9
9
|
//
|
|
10
|
-
// The registry is the `values` list of the
|
|
11
|
-
//
|
|
12
|
-
// pointer, so a feature registering a value
|
|
13
|
-
// every context reads.
|
|
10
|
+
// The registry is the `values` list of the clean block that make_options
|
|
11
|
+
// builds and holds on the context as `cleancfg`, beside the options rather
|
|
12
|
+
// than in them. Nodes are shared by pointer, so a feature registering a value
|
|
13
|
+
// later reaches the same list every context reads.
|
|
14
14
|
|
|
15
15
|
#include "sdk.h"
|
|
16
16
|
|
|
@@ -142,16 +142,12 @@ voxgig_value* clean_make_config(voxgig_value* cleanopts) {
|
|
|
142
142
|
"min", v_int(min));
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
return getpath2(options, "__derived__", "clean");
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// A context without options (make_error is reached with a bare one) falls
|
|
145
|
+
// A context without a registry (make_error is reached with a bare one) falls
|
|
150
146
|
// back to the schema defaults, so nothing leaves raw for want of a
|
|
151
147
|
// constructor.
|
|
152
148
|
static voxgig_value* config_block(Context* ctx) {
|
|
153
|
-
voxgig_value*
|
|
154
|
-
if (voxgig_is_map(
|
|
149
|
+
voxgig_value* cfg = ctx ? ctx->cleancfg : NULL;
|
|
150
|
+
if (voxgig_is_map(cfg)) return cfg;
|
|
155
151
|
return clean_make_config(getp(shared_optspec(), "clean"));
|
|
156
152
|
}
|
|
157
153
|
|
|
@@ -227,12 +223,11 @@ static int longest_first(const void* a, const void* b) {
|
|
|
227
223
|
return la < lb ? 1 : (la > lb ? -1 : 0);
|
|
228
224
|
}
|
|
229
225
|
|
|
230
|
-
// Register a secret value
|
|
231
|
-
//
|
|
232
|
-
//
|
|
233
|
-
void
|
|
226
|
+
// Register a secret value in a clean registry. Idempotent; shorter than
|
|
227
|
+
// `min` is not a secret the SDK can mask without blanking ordinary text.
|
|
228
|
+
// Anything but a registry map registers nothing.
|
|
229
|
+
void clean_add_cfg(voxgig_value* block, const char* value) {
|
|
234
230
|
if (!value) return;
|
|
235
|
-
voxgig_value* block = derived_block(options);
|
|
236
231
|
if (!voxgig_is_map(block)) return;
|
|
237
232
|
int64_t min = count(getp(block, "min"), 4);
|
|
238
233
|
if (min < 1) min = 1;
|
|
@@ -267,10 +262,10 @@ void clean_add_opts(voxgig_value* options, const char* value) {
|
|
|
267
262
|
}
|
|
268
263
|
}
|
|
269
264
|
|
|
270
|
-
// Register a secret value the context's
|
|
265
|
+
// Register a secret value the context's registry will mask from now on.
|
|
271
266
|
void clean_add_util(Context* ctx, const char* value) {
|
|
272
267
|
if (!ctx) return;
|
|
273
|
-
|
|
268
|
+
clean_add_cfg(ctx->cleancfg, value);
|
|
274
269
|
}
|
|
275
270
|
|
|
276
271
|
static char* mask_value(const CleanCfg* cfg, const char* value) {
|
|
@@ -507,10 +502,9 @@ char* clean_str(Context* ctx, const char* val) {
|
|
|
507
502
|
return clean_string(&cfg, val);
|
|
508
503
|
}
|
|
509
504
|
|
|
510
|
-
// Clean a value against
|
|
511
|
-
//
|
|
512
|
-
voxgig_value*
|
|
513
|
-
voxgig_value* block = derived_block(options);
|
|
505
|
+
// Clean a value against a registry rather than a context, for a feature
|
|
506
|
+
// that holds the registry but no context.
|
|
507
|
+
voxgig_value* clean_cfg(voxgig_value* block, voxgig_value* val) {
|
|
514
508
|
if (!voxgig_is_map(block)) return val;
|
|
515
509
|
CleanCfg cfg;
|
|
516
510
|
read_cfg(block, &cfg);
|
|
@@ -549,17 +543,17 @@ typedef struct {
|
|
|
549
543
|
size_t cap;
|
|
550
544
|
} Visited;
|
|
551
545
|
|
|
552
|
-
static void add_sensitive(const CleanCfg* cfg, voxgig_value*
|
|
546
|
+
static void add_sensitive(const CleanCfg* cfg, voxgig_value* block, voxgig_value* val,
|
|
553
547
|
bool under, size_t depth, Visited* seen) {
|
|
554
548
|
if (!val || CLEAN_MAXDEPTH <= depth) return;
|
|
555
549
|
if (voxgig_is_string(val)) {
|
|
556
|
-
if (under)
|
|
550
|
+
if (under) clean_add_cfg(block, voxgig_as_string(val));
|
|
557
551
|
return;
|
|
558
552
|
}
|
|
559
553
|
if (voxgig_is_number(val)) {
|
|
560
554
|
if (under) {
|
|
561
555
|
char* text = voxgig_stringify(val, -1);
|
|
562
|
-
|
|
556
|
+
clean_add_cfg(block, text);
|
|
563
557
|
free(text);
|
|
564
558
|
}
|
|
565
559
|
return;
|
|
@@ -579,33 +573,32 @@ static void add_sensitive(const CleanCfg* cfg, voxgig_value* options, voxgig_val
|
|
|
579
573
|
if (voxgig_is_list(val)) {
|
|
580
574
|
voxgig_list* l = voxgig_as_list(val);
|
|
581
575
|
for (size_t i = 0; i < l->len; i++) {
|
|
582
|
-
add_sensitive(cfg,
|
|
576
|
+
add_sensitive(cfg, block, l->items[i], under, depth + 1, seen);
|
|
583
577
|
}
|
|
584
578
|
} else {
|
|
585
579
|
voxgig_map* m = voxgig_as_map(val);
|
|
586
580
|
for (size_t i = 0; i < m->len; i++) {
|
|
587
581
|
bool sub = under || sensitive_key(cfg, m->entries[i].key);
|
|
588
|
-
add_sensitive(cfg,
|
|
582
|
+
add_sensitive(cfg, block, m->entries[i].value, sub, depth + 1, seen);
|
|
589
583
|
}
|
|
590
584
|
}
|
|
591
585
|
}
|
|
592
586
|
|
|
593
587
|
// Every scalar under a sensitive name, at any depth and of any shape, is
|
|
594
|
-
// registered
|
|
595
|
-
//
|
|
596
|
-
void
|
|
597
|
-
voxgig_value* block = derived_block(options);
|
|
588
|
+
// registered in `block`: a credential mistyped as a map or a number is
|
|
589
|
+
// still a credential.
|
|
590
|
+
void clean_add_sensitive_cfg(voxgig_value* block, voxgig_value* val) {
|
|
598
591
|
if (!voxgig_is_map(block)) return;
|
|
599
592
|
CleanCfg cfg;
|
|
600
593
|
read_cfg(block, &cfg);
|
|
601
594
|
Visited seen = { NULL, 0, 0 };
|
|
602
|
-
add_sensitive(&cfg,
|
|
595
|
+
add_sensitive(&cfg, block, val, false, 0, &seen);
|
|
603
596
|
free((void*)seen.ptrs);
|
|
604
597
|
}
|
|
605
598
|
|
|
606
599
|
void clean_add_sensitive_util(Context* ctx, voxgig_value* val) {
|
|
607
600
|
if (!ctx) return;
|
|
608
|
-
|
|
601
|
+
clean_add_sensitive_cfg(ctx->cleancfg, val);
|
|
609
602
|
}
|
|
610
603
|
|
|
611
604
|
// Whether a named value is a secret: by its name, or by a registered value
|
|
@@ -216,20 +216,19 @@ voxgig_value* make_options_util(Context* ctx, PNError** err) {
|
|
|
216
216
|
voxgig_value* optspec = shared_optspec();
|
|
217
217
|
|
|
218
218
|
/* The secret registry exists BEFORE validation, fed from the raw input.
|
|
219
|
-
* Its block is shared by pointer: what is registered
|
|
220
|
-
*
|
|
219
|
+
* Its block is shared by pointer: what is registered here is what the
|
|
220
|
+
* context's `cleancfg` carries out below. */
|
|
221
221
|
voxgig_value* cleancfg = clean_make_config(voxgig_merge(
|
|
222
222
|
clist(4, v_map(), voxgig_clone(getp(optspec, "clean")),
|
|
223
223
|
mo_clean_block(cfgopts), mo_clean_block(opts)),
|
|
224
224
|
VOXGIG_MAXDEPTH));
|
|
225
|
-
|
|
226
|
-
clean_add_sensitive_opts(cleanopts, mo_without(opts, "clean", NULL));
|
|
225
|
+
clean_add_sensitive_cfg(cleancfg, mo_without(opts, "clean", NULL));
|
|
227
226
|
voxgig_value* valueblocks[2] = { cfgopts, opts };
|
|
228
227
|
for (int b = 0; b < 2; b++) {
|
|
229
228
|
voxgig_list* rawvals =
|
|
230
229
|
voxgig_as_list(clean_split_values(getpath2(valueblocks[b], "clean", "values")));
|
|
231
230
|
for (size_t i = 0; i < rawvals->len; i++) {
|
|
232
|
-
|
|
231
|
+
clean_add_cfg(cleancfg, voxgig_as_string(rawvals->items[i]));
|
|
233
232
|
}
|
|
234
233
|
}
|
|
235
234
|
|
|
@@ -304,11 +303,13 @@ voxgig_value* make_options_util(Context* ctx, PNError** err) {
|
|
|
304
303
|
}
|
|
305
304
|
}
|
|
306
305
|
|
|
307
|
-
setp(opts, "__derived__",
|
|
308
|
-
|
|
306
|
+
setp(opts, "__derived__", cmap(1, "featureorder", feature_order));
|
|
307
|
+
|
|
308
|
+
// Beside the options, not in them: options_map hands them to callers.
|
|
309
|
+
ctx->cleancfg = v_share(cleancfg);
|
|
309
310
|
|
|
310
311
|
// Again over the merged result: the config's own defaults can carry one.
|
|
311
|
-
|
|
312
|
+
clean_add_sensitive_cfg(cleancfg, mo_without(opts, "clean", "__derived__"));
|
|
312
313
|
|
|
313
314
|
return opts;
|
|
314
315
|
}
|
|
@@ -252,15 +252,10 @@
|
|
|
252
252
|
base0 (let [b (vs/getprop options "base")] (if (string? b) b ""))
|
|
253
253
|
base (str/replace base0 #"/+$" "")
|
|
254
254
|
url (str base "/" (str/replace (:path x) #"^/+" ""))
|
|
255
|
-
|
|
256
|
-
;;
|
|
257
|
-
;;
|
|
258
|
-
|
|
259
|
-
;; purchase through the test mock, which knows nothing about it.
|
|
260
|
-
;; `system.fetch` is honoured because that is the seam a caller
|
|
261
|
-
;; uses to supply a transport at all; otherwise core's own raw
|
|
262
|
-
;; HTTP path, which returns the same [res err] shape.
|
|
263
|
-
fetch (if (vs/isfunc sysfetch) sysfetch core/default-http-fetch)
|
|
255
|
+
;; The SDK's own transport, beneath every feature's wrapper: it
|
|
256
|
+
;; holds the test feature's block and the GET-only guard, and the
|
|
257
|
+
;; wrapped one would recurse on the first expiry.
|
|
258
|
+
fetch (fn [at fd] (core/u-fetcher (st fa :rootctx) at fd))
|
|
264
259
|
;; The body is MARSHALLED, never concatenated: a refresh token (or
|
|
265
260
|
;; a configured request-field name) carrying a quote, backslash or
|
|
266
261
|
;; newline must arrive as that literal value, not as broken JSON.
|
|
@@ -269,7 +264,9 @@
|
|
|
269
264
|
fetchdef (vs/jm "method" (:method x)
|
|
270
265
|
"headers" (vs/jm "content-type" "application/json")
|
|
271
266
|
"body" body
|
|
272
|
-
"redirect" "manual"
|
|
267
|
+
"redirect" "manual"
|
|
268
|
+
;; Its own bound, in milliseconds: the timeout feature's wrapper is above it.
|
|
269
|
+
"timeout" 30000)
|
|
273
270
|
;; By option alone, and only while the exchange stays on its own origin.
|
|
274
271
|
[res err] (loop [at url
|
|
275
272
|
answer (fetch url fetchdef)
|
|
@@ -281,6 +278,8 @@
|
|
|
281
278
|
(recur next (fetch next fetchdef) (inc hops))
|
|
282
279
|
answer)))]
|
|
283
280
|
|
|
281
|
+
(when (core/sdk-error? err)
|
|
282
|
+
(core/sdk-throw err))
|
|
284
283
|
(when (some? err)
|
|
285
284
|
(throw (sekreto/sekretoerror
|
|
286
285
|
(str "secrets: token exchange failed: " (core/err-msg err) " from " url))))
|
|
@@ -480,8 +479,11 @@
|
|
|
480
479
|
;; provider ERROR refuses the request with the provider's own message,
|
|
481
480
|
;; and never an unauthenticated send.
|
|
482
481
|
(let [failed (resolve! fa)]
|
|
483
|
-
(
|
|
482
|
+
(cond
|
|
483
|
+
(core/sdk-error? (core/ex->sdk failed)) [nil (core/ex->sdk failed)]
|
|
484
|
+
(some? failed)
|
|
484
485
|
[nil (core/ctx-error ctx ERROR-CODE (str "secrets: " (core/err-msg failed)))]
|
|
486
|
+
:else
|
|
485
487
|
(do
|
|
486
488
|
(let [token (credential fa)]
|
|
487
489
|
(when (seq token) (reauth! fa fetchdef token)))
|
|
@@ -513,6 +515,7 @@
|
|
|
513
515
|
(let [options (if (vs/ismap options) options (vs/jm))]
|
|
514
516
|
(swap! fa assoc
|
|
515
517
|
:client (core/oget ctx :client)
|
|
518
|
+
:rootctx ctx
|
|
516
519
|
:options options
|
|
517
520
|
:liveopts (core/oget ctx :options)
|
|
518
521
|
:active (= true (vs/getprop options "active")))
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
(defmethod print-method ::options [a ^java.io.Writer w]
|
|
23
23
|
(let [opts (deref a)]
|
|
24
24
|
(.write w (str "#sdk/options "
|
|
25
|
-
(vs/jsonify (core/u-clean (atom {
|
|
25
|
+
(vs/jsonify (core/u-clean (or (:ctx (meta a)) (atom {})) opts) (vs/jm "indent" 0))))))
|
|
26
26
|
|
|
27
27
|
(defn make-sdk [options]
|
|
28
28
|
(let [options (or options (vs/jm))
|
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
(vs/jm "client" client "utility" utility "config" cfg "options" options "shared" (vs/jm)) nil)
|
|
38
38
|
validated ((core/uget rootctx :make-options) rootctx)]
|
|
39
39
|
(reset! (:root-ctx client) rootctx)
|
|
40
|
+
;; The options print cleans against the registry the root context holds.
|
|
41
|
+
(alter-meta! (:options client) assoc :ctx rootctx)
|
|
40
42
|
(reset! (:options client) validated)
|
|
41
43
|
(when (= true (vs/getpath validated "feature.test.active"))
|
|
42
44
|
(reset! (:mode client) "test"))
|