@voxgig/sdkgen 4.32.0 → 4.33.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/dist/helpers/naming.js +1 -1
- package/dist/helpers/naming.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/model/sdkgen.aontu +7 -1
- package/package.json +1 -1
- package/project/.sdk/model/feature/debug.aontu +3 -1
- package/project/.sdk/src/cmp/c/PrepareAuth_c.ts +8 -28
- package/project/.sdk/src/cmp/c/TestClean_c.ts +774 -0
- package/project/.sdk/src/cmp/c/Test_c.ts +3 -0
- package/project/.sdk/src/cmp/c/fragment/Entity.fragment.c +16 -5
- package/project/.sdk/src/cmp/c/fragment/Main.fragment.c +1 -1
- package/project/.sdk/src/cmp/clojure/PrepareAuth_clojure.ts +3 -0
- package/project/.sdk/src/cmp/clojure/TestClean_clojure.ts +473 -0
- package/project/.sdk/src/cmp/clojure/Test_clojure.ts +6 -0
- package/project/.sdk/src/cmp/clojure/fragment/Entity.fragment.clj +18 -8
- package/project/.sdk/src/cmp/cpp/PrepareAuth_cpp.ts +3 -0
- package/project/.sdk/src/cmp/cpp/TestClean_cpp.ts +782 -0
- package/project/.sdk/src/cmp/cpp/TestEntity_cpp.ts +1 -1
- package/project/.sdk/src/cmp/cpp/Test_cpp.ts +2 -0
- package/project/.sdk/src/cmp/csharp/PrepareAuth_csharp.ts +3 -0
- package/project/.sdk/src/cmp/csharp/TestClean_csharp.ts +887 -0
- package/project/.sdk/src/cmp/csharp/Test_csharp.ts +2 -0
- package/project/.sdk/src/cmp/csharp/fragment/EntityBase.fragment.cs +68 -4
- package/project/.sdk/src/cmp/csharp/fragment/Main.fragment.cs +8 -2
- package/project/.sdk/src/cmp/csharp/fragment/SdkError.fragment.cs +49 -0
- package/project/.sdk/src/cmp/elixir/PrepareAuth_elixir.ts +3 -0
- package/project/.sdk/src/cmp/elixir/Schema_elixir.ts +20 -10
- package/project/.sdk/src/cmp/elixir/TestClean_elixir.ts +666 -0
- package/project/.sdk/src/cmp/elixir/Test_elixir.ts +4 -0
- package/project/.sdk/src/cmp/elixir/fragment/Main.fragment.ex +1 -1
- package/project/.sdk/src/cmp/elixir/fragment/Pipeline.fragment.ex +14 -2
- package/project/.sdk/src/cmp/go/PrepareAuth_go.ts +3 -0
- package/project/.sdk/src/cmp/go/TestClean_go.ts +804 -0
- package/project/.sdk/src/cmp/go/Test_go.ts +3 -0
- package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +54 -4
- package/project/.sdk/src/cmp/go/fragment/Main.fragment.go +27 -2
- package/project/.sdk/src/cmp/java/PrepareAuth_java.ts +3 -0
- package/project/.sdk/src/cmp/java/TestClean_java.ts +884 -0
- package/project/.sdk/src/cmp/java/Test_java.ts +2 -0
- package/project/.sdk/src/cmp/java/fragment/EntityBase.fragment.java +56 -11
- package/project/.sdk/src/cmp/java/fragment/SdkError.fragment.java +36 -3
- package/project/.sdk/src/cmp/js/PrepareAuth_js.ts +3 -0
- package/project/.sdk/src/cmp/js/TestClean_js.ts +458 -0
- package/project/.sdk/src/cmp/js/Test_js.ts +2 -0
- package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +5 -4
- package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +7 -1
- package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +7 -1
- package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +7 -1
- package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +7 -1
- package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +7 -1
- package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +11 -2
- package/project/.sdk/src/cmp/js/fragment/SdkError.fragment.js +17 -1
- package/project/.sdk/src/cmp/kotlin/Package_kotlin.ts +5 -0
- package/project/.sdk/src/cmp/kotlin/PrepareAuth_kotlin.ts +3 -0
- package/project/.sdk/src/cmp/kotlin/TestClean_kotlin.ts +654 -0
- package/project/.sdk/src/cmp/kotlin/Test_kotlin.ts +3 -0
- package/project/.sdk/src/cmp/kotlin/fragment/EntityBase.fragment.kt +44 -11
- package/project/.sdk/src/cmp/kotlin/fragment/SdkError.fragment.kt +31 -0
- package/project/.sdk/src/cmp/lua/PrepareAuth_lua.ts +3 -0
- package/project/.sdk/src/cmp/lua/TestClean_lua.ts +769 -0
- package/project/.sdk/src/cmp/lua/Test_lua.ts +3 -0
- package/project/.sdk/src/cmp/lua/fragment/Entity.fragment.lua +77 -1
- package/project/.sdk/src/cmp/lua/fragment/Main.fragment.lua +49 -2
- package/project/.sdk/src/cmp/ocaml/Entity_ocaml.ts +3 -2
- package/project/.sdk/src/cmp/ocaml/PrepareAuth_ocaml.ts +4 -25
- package/project/.sdk/src/cmp/ocaml/TestClean_ocaml.ts +538 -0
- package/project/.sdk/src/cmp/ocaml/Test_ocaml.ts +5 -0
- package/project/.sdk/src/cmp/ocaml/fragment/RunOp.fragment.ml +16 -4
- package/project/.sdk/src/cmp/perl/PrepareAuth_perl.ts +3 -0
- package/project/.sdk/src/cmp/perl/TestClean_perl.ts +619 -0
- package/project/.sdk/src/cmp/perl/Test_perl.ts +3 -0
- package/project/.sdk/src/cmp/perl/fragment/Entity.fragment.pm +67 -5
- package/project/.sdk/src/cmp/perl/fragment/Main.fragment.pm +13 -1
- package/project/.sdk/src/cmp/php/PrepareAuth_php.ts +3 -0
- package/project/.sdk/src/cmp/php/TestClean_php.ts +809 -0
- package/project/.sdk/src/cmp/php/Test_php.ts +2 -0
- package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +96 -55
- package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +15 -2
- package/project/.sdk/src/cmp/py/PrepareAuth_py.ts +3 -0
- package/project/.sdk/src/cmp/py/TestClean_py.ts +549 -0
- package/project/.sdk/src/cmp/py/Test_py.ts +3 -0
- package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +83 -55
- package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +19 -3
- package/project/.sdk/src/cmp/rb/PrepareAuth_rb.ts +3 -0
- package/project/.sdk/src/cmp/rb/TestClean_rb.ts +535 -0
- package/project/.sdk/src/cmp/rb/Test_rb.ts +3 -0
- package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +108 -46
- package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +12 -1
- package/project/.sdk/src/cmp/rust/PrepareAuth_rust.ts +9 -45
- package/project/.sdk/src/cmp/rust/TestClean_rust.ts +881 -0
- package/project/.sdk/src/cmp/rust/Test_rust.ts +3 -0
- package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +14 -6
- package/project/.sdk/src/cmp/rust/fragment/Main.fragment.rs +17 -1
- package/project/.sdk/src/cmp/rust/fragment/SdkError.fragment.rs +34 -2
- package/project/.sdk/src/cmp/scala/PrepareAuth_scala.ts +3 -0
- package/project/.sdk/src/cmp/scala/TestClean_scala.ts +608 -0
- package/project/.sdk/src/cmp/scala/Test_scala.ts +3 -0
- package/project/.sdk/src/cmp/scala/fragment/EntityBase.fragment.scala +58 -6
- package/project/.sdk/src/cmp/swift/PrepareAuth_swift.ts +3 -0
- package/project/.sdk/src/cmp/swift/TestClean_swift.ts +671 -0
- package/project/.sdk/src/cmp/swift/Test_swift.ts +3 -0
- package/project/.sdk/src/cmp/swift/fragment/EntityBase.fragment.swift +10 -0
- package/project/.sdk/src/cmp/swift/fragment/Main.fragment.swift +16 -2
- package/project/.sdk/src/cmp/swift/fragment/SdkError.fragment.swift +47 -3
- package/project/.sdk/src/cmp/ts/PrepareAuth_ts.ts +3 -0
- package/project/.sdk/src/cmp/ts/TestClean_ts.ts +465 -0
- package/project/.sdk/src/cmp/ts/Test_ts.ts +2 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +5 -4
- package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +7 -1
- package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +7 -1
- package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +7 -1
- package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +7 -1
- package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +7 -1
- package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +8 -2
- package/project/.sdk/src/cmp/ts/fragment/SdkError.fragment.ts +20 -2
- package/project/.sdk/src/cmp/zig/PrepareAuth_zig.ts +3 -0
- package/project/.sdk/src/cmp/zig/TestClean_zig.ts +791 -0
- package/project/.sdk/src/cmp/zig/Test_zig.ts +5 -0
- package/project/.sdk/src/cmp/zig/fragment/Build.fragment.zig +19 -0
- package/project/.sdk/src/cmp/zig/fragment/Entity.fragment.zig +14 -5
- package/project/.sdk/src/cmp/zig/fragment/Main.fragment.zig +1 -1
- package/project/.sdk/tm/c/core/context.c +25 -0
- package/project/.sdk/tm/c/core/error.c +16 -0
- package/project/.sdk/tm/c/core/sdk.h +22 -0
- package/project/.sdk/tm/c/feature/audit.c +2 -0
- package/project/.sdk/tm/c/feature/cost.c +1 -0
- package/project/.sdk/tm/c/feature/debug.c +19 -29
- package/project/.sdk/tm/c/feature/log.c +21 -2
- package/project/.sdk/tm/c/feature/proxy.c +55 -3
- package/project/.sdk/tm/c/feature/secrets.c +7 -0
- package/project/.sdk/tm/c/feature/telemetry.c +2 -0
- package/project/.sdk/tm/c/tests/feature_test.c +2 -2
- package/project/.sdk/tm/c/utility/clean.c +530 -8
- package/project/.sdk/tm/c/utility/done.c +28 -12
- package/project/.sdk/tm/c/utility/make_error.c +4 -3
- package/project/.sdk/tm/c/utility/make_options.c +71 -45
- package/project/.sdk/tm/clojure/feature/secrets/sdk/feature/secrets.clj +15 -0
- package/project/.sdk/tm/clojure/src/sdk/client.clj +20 -4
- package/project/.sdk/tm/clojure/src/sdk/core.clj +319 -35
- package/project/.sdk/tm/clojure/src/sdk/features.clj +68 -30
- package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +4 -2
- package/project/.sdk/tm/clojure/test/sdk/test/pipeline.clj +47 -20
- package/project/.sdk/tm/clojure/test/sdk/test_runner.clj +4 -0
- package/project/.sdk/tm/cpp/core/types.hpp +93 -3
- package/project/.sdk/tm/cpp/feature/audit.hpp +1 -0
- package/project/.sdk/tm/cpp/feature/cost.hpp +1 -0
- package/project/.sdk/tm/cpp/feature/debug.hpp +20 -12
- package/project/.sdk/tm/cpp/feature/log.hpp +31 -9
- package/project/.sdk/tm/cpp/feature/proxy.hpp +52 -6
- package/project/.sdk/tm/cpp/feature/secrets.hpp +13 -0
- package/project/.sdk/tm/cpp/feature/telemetry.hpp +4 -2
- package/project/.sdk/tm/cpp/test/feature_test.cpp +2 -2
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +426 -51
- package/project/.sdk/tm/csharp/core/Context.cs +32 -0
- package/project/.sdk/tm/csharp/core/Utility.cs +2 -0
- package/project/.sdk/tm/csharp/feature/AuditFeature.cs +1 -0
- package/project/.sdk/tm/csharp/feature/CostFeature.cs +7 -5
- package/project/.sdk/tm/csharp/feature/DebugFeature.cs +19 -16
- package/project/.sdk/tm/csharp/feature/FeatureOptions.cs +16 -0
- package/project/.sdk/tm/csharp/feature/LogFeature.cs +4 -1
- package/project/.sdk/tm/csharp/feature/ProxyFeature.cs +26 -5
- package/project/.sdk/tm/csharp/feature/SecretsFeature.cs +16 -0
- package/project/.sdk/tm/csharp/feature/TelemetryFeature.cs +4 -2
- package/project/.sdk/tm/csharp/test/FeatureTest.cs +2 -2
- package/project/.sdk/tm/csharp/utility/Clean.cs +440 -2
- package/project/.sdk/tm/csharp/utility/Done.cs +27 -11
- package/project/.sdk/tm/csharp/utility/MakeError.cs +19 -8
- package/project/.sdk/tm/csharp/utility/MakeOptions.cs +119 -29
- package/project/.sdk/tm/csharp/utility/MakeResponse.cs +21 -11
- package/project/.sdk/tm/csharp/utility/Register.cs +1 -0
- package/project/.sdk/tm/elixir/lib/projectname/context.ex +19 -0
- package/project/.sdk/tm/elixir/lib/projectname/entity_base.ex +22 -1
- package/project/.sdk/tm/elixir/lib/projectname/error.ex +24 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/audit.ex +2 -2
- package/project/.sdk/tm/elixir/lib/projectname/feature/cost.ex +2 -2
- package/project/.sdk/tm/elixir/lib/projectname/feature/debug.ex +13 -13
- package/project/.sdk/tm/elixir/lib/projectname/feature/log.ex +18 -5
- package/project/.sdk/tm/elixir/lib/projectname/feature/proxy.ex +19 -1
- package/project/.sdk/tm/elixir/lib/projectname/feature/secrets.ex +15 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/telemetry.ex +4 -2
- package/project/.sdk/tm/elixir/lib/projectname/feature.ex +22 -0
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +464 -41
- package/project/.sdk/tm/elixir/test/feature_test.exs +3 -2
- package/project/.sdk/tm/go/core/context.go +42 -0
- package/project/.sdk/tm/go/core/error.go +30 -10
- package/project/.sdk/tm/go/core/utility_type.go +2 -0
- package/project/.sdk/tm/go/feature/audit_feature.go +1 -0
- package/project/.sdk/tm/go/feature/base_feature.go +12 -0
- package/project/.sdk/tm/go/feature/cost_feature.go +2 -2
- package/project/.sdk/tm/go/feature/debug_feature.go +14 -12
- package/project/.sdk/tm/go/feature/log_feature.go +13 -8
- package/project/.sdk/tm/go/feature/proxy_feature.go +26 -6
- package/project/.sdk/tm/go/feature/secrets_feature.go +19 -0
- package/project/.sdk/tm/go/feature/telemetry_feature.go +4 -2
- package/project/.sdk/tm/go/test/feature_test.go +2 -2
- package/project/.sdk/tm/go/utility/clean.go +585 -2
- package/project/.sdk/tm/go/utility/done.go +29 -9
- package/project/.sdk/tm/go/utility/make_error.go +51 -16
- package/project/.sdk/tm/go/utility/make_options.go +77 -36
- package/project/.sdk/tm/go/utility/register.go +12 -0
- package/project/.sdk/tm/java/core/Context.java +29 -0
- package/project/.sdk/tm/java/core/SdkClient.java +4 -2
- package/project/.sdk/tm/java/core/Utility.java +7 -0
- package/project/.sdk/tm/java/feature/AuditFeature.java +6 -0
- package/project/.sdk/tm/java/feature/CostFeature.java +5 -0
- package/project/.sdk/tm/java/feature/DebugFeature.java +25 -14
- package/project/.sdk/tm/java/feature/LogFeature.java +11 -4
- package/project/.sdk/tm/java/feature/ProxyFeature.java +41 -6
- package/project/.sdk/tm/java/feature/SecretsFeature.java +18 -0
- package/project/.sdk/tm/java/feature/TelemetryFeature.java +8 -2
- package/project/.sdk/tm/java/test/FeatureTest.java +2 -2
- package/project/.sdk/tm/java/utility/Clean.java +519 -1
- package/project/.sdk/tm/java/utility/Done.java +1 -1
- package/project/.sdk/tm/java/utility/MakeError.java +5 -1
- package/project/.sdk/tm/java/utility/MakeOptions.java +55 -31
- package/project/.sdk/tm/java/utility/Register.java +4 -0
- package/project/.sdk/tm/js/src/Context.js +5 -1
- package/project/.sdk/tm/js/src/Response.js +14 -1
- package/project/.sdk/tm/js/src/feature/audit/AuditFeature.js +2 -2
- package/project/.sdk/tm/js/src/feature/cost/CostFeature.js +2 -2
- package/project/.sdk/tm/js/src/feature/debug/DebugFeature.js +13 -7
- package/project/.sdk/tm/js/src/feature/log/LogFeature.js +9 -5
- package/project/.sdk/tm/js/src/feature/proxy/ProxyFeature.js +19 -1
- package/project/.sdk/tm/js/src/feature/secrets/SecretsFeature.js +14 -0
- package/project/.sdk/tm/js/src/feature/telemetry/TelemetryFeature.js +4 -2
- package/project/.sdk/tm/js/src/utility/CleanUtility.js +294 -21
- package/project/.sdk/tm/js/src/utility/DoneUtility.js +17 -5
- package/project/.sdk/tm/js/src/utility/MakeErrorUtility.js +18 -2
- package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +39 -15
- package/project/.sdk/tm/js/src/utility/Utility.js +4 -2
- package/project/.sdk/tm/js/test/feature/harness.js +11 -1
- package/project/.sdk/tm/js/test/feature.test.js +9 -2
- package/project/.sdk/tm/js/test/utility/PrimaryUtility.test.js +25 -0
- package/project/.sdk/tm/kotlin/core/Context.kt +19 -0
- package/project/.sdk/tm/kotlin/core/SdkClient.kt +9 -2
- package/project/.sdk/tm/kotlin/core/Utility.kt +2 -0
- package/project/.sdk/tm/kotlin/feature/AuditFeature.kt +11 -9
- package/project/.sdk/tm/kotlin/feature/CostFeature.kt +8 -5
- package/project/.sdk/tm/kotlin/feature/DebugFeature.kt +15 -22
- package/project/.sdk/tm/kotlin/feature/LogFeature.kt +8 -4
- package/project/.sdk/tm/kotlin/feature/ProxyFeature.kt +26 -2
- package/project/.sdk/tm/kotlin/feature/SecretsFeature.kt +11 -0
- package/project/.sdk/tm/kotlin/feature/TelemetryFeature.kt +4 -2
- package/project/.sdk/tm/kotlin/test/FeatureTest.kt +2 -2
- package/project/.sdk/tm/kotlin/utility/CoreUtil.kt +447 -11
- package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +38 -31
- package/project/.sdk/tm/kotlin/utility/Register.kt +1 -0
- package/project/.sdk/tm/lua/core/context.lua +43 -0
- package/project/.sdk/tm/lua/core/error.lua +36 -1
- package/project/.sdk/tm/lua/core/utility_type.lua +4 -0
- package/project/.sdk/tm/lua/feature/audit_feature.lua +2 -2
- package/project/.sdk/tm/lua/feature/cost_feature.lua +2 -2
- package/project/.sdk/tm/lua/feature/debug_feature.lua +21 -17
- package/project/.sdk/tm/lua/feature/log_feature.lua +2 -1
- package/project/.sdk/tm/lua/feature/proxy_feature.lua +23 -1
- package/project/.sdk/tm/lua/feature/secrets_feature.lua +18 -0
- package/project/.sdk/tm/lua/feature/telemetry_feature.lua +4 -2
- package/project/.sdk/tm/lua/test/feature/secrets/secrets_feature_test.lua +3 -2
- package/project/.sdk/tm/lua/test/feature_test.lua +10 -3
- package/project/.sdk/tm/lua/utility/clean.lua +426 -2
- package/project/.sdk/tm/lua/utility/clean_explain.lua +34 -0
- package/project/.sdk/tm/lua/utility/done.lua +1 -7
- package/project/.sdk/tm/lua/utility/make_error.lua +3 -1
- package/project/.sdk/tm/lua/utility/make_options.lua +76 -30
- package/project/.sdk/tm/lua/utility/register.lua +4 -1
- package/project/.sdk/tm/ocaml/Makefile +5 -1
- package/project/.sdk/tm/ocaml/feature/secrets_feature.ml +12 -1
- package/project/.sdk/tm/ocaml/sdk_features.ml +78 -18
- package/project/.sdk/tm/ocaml/sdk_helpers.ml +27 -0
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +304 -26
- package/project/.sdk/tm/ocaml/sdk_types.ml +1 -0
- package/project/.sdk/tm/ocaml/test/feature/secrets/t_secrets.ml +3 -1
- package/project/.sdk/tm/ocaml/test/t_feature.ml +2 -2
- package/project/.sdk/tm/perl/core/context.pm +27 -0
- package/project/.sdk/tm/perl/core/error.pm +52 -5
- package/project/.sdk/tm/perl/feature/audit_feature.pm +2 -2
- package/project/.sdk/tm/perl/feature/cost_feature.pm +2 -2
- package/project/.sdk/tm/perl/feature/debug_feature.pm +17 -13
- package/project/.sdk/tm/perl/feature/log_feature.pm +3 -1
- package/project/.sdk/tm/perl/feature/proxy_feature.pm +21 -1
- package/project/.sdk/tm/perl/feature/secrets_feature.pm +20 -1
- package/project/.sdk/tm/perl/feature/telemetry_feature.pm +4 -2
- package/project/.sdk/tm/perl/t/feature.t +4 -2
- package/project/.sdk/tm/perl/utility/clean.pm +345 -1
- package/project/.sdk/tm/perl/utility/done.pm +24 -6
- package/project/.sdk/tm/perl/utility/make_error.pm +17 -4
- package/project/.sdk/tm/perl/utility/make_options.pm +33 -14
- package/project/.sdk/tm/php/core/Context.php +24 -1
- package/project/.sdk/tm/php/core/Error.php +34 -3
- package/project/.sdk/tm/php/core/UtilityType.php +4 -0
- package/project/.sdk/tm/php/feature/AuditFeature.php +2 -2
- package/project/.sdk/tm/php/feature/CostFeature.php +2 -2
- package/project/.sdk/tm/php/feature/DebugFeature.php +18 -9
- package/project/.sdk/tm/php/feature/LogFeature.php +5 -2
- package/project/.sdk/tm/php/feature/ProxyFeature.php +20 -1
- package/project/.sdk/tm/php/feature/SecretsFeature.php +18 -0
- package/project/.sdk/tm/php/feature/TelemetryFeature.php +4 -2
- package/project/.sdk/tm/php/test/FeatureTest.php +2 -2
- package/project/.sdk/tm/php/utility/Clean.php +438 -2
- package/project/.sdk/tm/php/utility/Done.php +14 -7
- package/project/.sdk/tm/php/utility/MakeError.php +9 -7
- package/project/.sdk/tm/php/utility/MakeOptions.php +62 -38
- package/project/.sdk/tm/php/utility/Register.php +2 -0
- package/project/.sdk/tm/py/pkg/core/context.py +17 -0
- package/project/.sdk/tm/py/pkg/core/error.py +42 -1
- package/project/.sdk/tm/py/pkg/core/utility_type.py +4 -0
- package/project/.sdk/tm/py/pkg/feature/audit_feature.py +2 -2
- package/project/.sdk/tm/py/pkg/feature/cost_feature.py +2 -2
- package/project/.sdk/tm/py/pkg/feature/debug_feature.py +17 -12
- package/project/.sdk/tm/py/pkg/feature/log_feature.py +2 -1
- package/project/.sdk/tm/py/pkg/feature/proxy_feature.py +18 -1
- package/project/.sdk/tm/py/pkg/feature/secrets_feature.py +12 -0
- package/project/.sdk/tm/py/pkg/feature/telemetry_feature.py +4 -2
- package/project/.sdk/tm/py/pkg/utility/clean.py +311 -1
- package/project/.sdk/tm/py/pkg/utility/done.py +18 -5
- package/project/.sdk/tm/py/pkg/utility/make_error.py +9 -6
- package/project/.sdk/tm/py/pkg/utility/make_options.py +64 -25
- package/project/.sdk/tm/py/pkg/utility/make_response.py +19 -13
- package/project/.sdk/tm/py/pkg/utility/register.py +4 -2
- package/project/.sdk/tm/py/test/feature_harness.py +4 -0
- package/project/.sdk/tm/py/test/test_feature.py +2 -2
- package/project/.sdk/tm/py/test/test_primary_utility.py +1 -0
- package/project/.sdk/tm/rb/core/context.rb +28 -0
- package/project/.sdk/tm/rb/core/error.rb +30 -0
- package/project/.sdk/tm/rb/core/utility_type.rb +1 -1
- package/project/.sdk/tm/rb/feature/audit_feature.rb +2 -2
- package/project/.sdk/tm/rb/feature/cost_feature.rb +2 -2
- package/project/.sdk/tm/rb/feature/debug_feature.rb +15 -12
- package/project/.sdk/tm/rb/feature/log_feature.rb +3 -1
- package/project/.sdk/tm/rb/feature/proxy_feature.rb +25 -1
- package/project/.sdk/tm/rb/feature/secrets_feature.rb +17 -0
- package/project/.sdk/tm/rb/feature/telemetry_feature.rb +4 -2
- package/project/.sdk/tm/rb/test/feature_test.rb +4 -2
- package/project/.sdk/tm/rb/utility/clean.rb +312 -1
- package/project/.sdk/tm/rb/utility/done.rb +15 -5
- package/project/.sdk/tm/rb/utility/make_error.rb +13 -4
- package/project/.sdk/tm/rb/utility/make_options.rb +31 -12
- package/project/.sdk/tm/rb/utility/register.rb +2 -0
- package/project/.sdk/tm/rust/core/context.rs +55 -0
- package/project/.sdk/tm/rust/core/utility_type.rs +17 -0
- package/project/.sdk/tm/rust/feature/audit.rs +2 -0
- package/project/.sdk/tm/rust/feature/cost.rs +3 -2
- package/project/.sdk/tm/rust/feature/debug.rs +16 -16
- package/project/.sdk/tm/rust/feature/log.rs +42 -7
- package/project/.sdk/tm/rust/feature/proxy.rs +48 -2
- package/project/.sdk/tm/rust/feature/secrets.rs +12 -0
- package/project/.sdk/tm/rust/feature/telemetry.rs +2 -0
- package/project/.sdk/tm/rust/tests/feature_test.rs +2 -2
- package/project/.sdk/tm/rust/utility/clean.rs +446 -5
- package/project/.sdk/tm/rust/utility/done.rs +22 -12
- package/project/.sdk/tm/rust/utility/make_error.rs +4 -1
- package/project/.sdk/tm/rust/utility/make_options.rs +73 -19
- package/project/.sdk/tm/scala/Makefile +3 -1
- package/project/.sdk/tm/scala/core/Context.scala +16 -0
- package/project/.sdk/tm/scala/core/SdkClient.scala +14 -4
- package/project/.sdk/tm/scala/core/SdkError.scala +28 -0
- package/project/.sdk/tm/scala/core/Types.scala +3 -0
- package/project/.sdk/tm/scala/core/Utility.scala +2 -0
- package/project/.sdk/tm/scala/feature/AuditFeature.scala +16 -10
- package/project/.sdk/tm/scala/feature/CostFeature.scala +10 -5
- package/project/.sdk/tm/scala/feature/DebugFeature.scala +24 -21
- package/project/.sdk/tm/scala/feature/LogFeature.scala +9 -4
- package/project/.sdk/tm/scala/feature/ProxyFeature.scala +23 -2
- package/project/.sdk/tm/scala/feature/SecretsFeature.scala +14 -0
- package/project/.sdk/tm/scala/feature/TelemetryFeature.scala +9 -2
- package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +2 -2
- package/project/.sdk/tm/scala/utility/Make.scala +63 -20
- package/project/.sdk/tm/scala/utility/Misc.scala +358 -5
- package/project/.sdk/tm/scala/utility/Register.scala +1 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Context.swift +29 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Utility.swift +2 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/AuditFeature.swift +10 -9
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/CostFeature.swift +7 -5
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/DebugFeature.swift +19 -15
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/FeatureOptions.swift +16 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/LogFeature.swift +4 -1
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/ProxyFeature.swift +20 -5
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/SecretsFeature.swift +13 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TelemetryFeature.swift +4 -2
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeError.swift +15 -5
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +58 -19
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Register.swift +1 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/ResultUtil.swift +391 -4
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +2 -2
- package/project/.sdk/tm/ts/src/Context.ts +5 -1
- package/project/.sdk/tm/ts/src/Response.ts +14 -1
- package/project/.sdk/tm/ts/src/feature/audit/AuditFeature.ts +2 -2
- package/project/.sdk/tm/ts/src/feature/cost/CostFeature.ts +2 -2
- package/project/.sdk/tm/ts/src/feature/debug/DebugFeature.ts +13 -7
- package/project/.sdk/tm/ts/src/feature/log/LogFeature.ts +9 -5
- package/project/.sdk/tm/ts/src/feature/proxy/ProxyFeature.ts +19 -1
- package/project/.sdk/tm/ts/src/feature/secrets/SecretsFeature.ts +12 -0
- package/project/.sdk/tm/ts/src/feature/telemetry/TelemetryFeature.ts +4 -2
- package/project/.sdk/tm/ts/src/utility/CleanUtility.ts +287 -9
- package/project/.sdk/tm/ts/src/utility/DoneUtility.ts +18 -5
- package/project/.sdk/tm/ts/src/utility/MakeErrorUtility.ts +18 -8
- package/project/.sdk/tm/ts/src/utility/MakeOptionsUtility.ts +38 -16
- package/project/.sdk/tm/ts/src/utility/Utility.ts +4 -2
- package/project/.sdk/tm/ts/test/feature/harness.ts +11 -1
- package/project/.sdk/tm/ts/test/feature.test.ts +9 -2
- package/project/.sdk/tm/ts/test/utility/PrimaryUtility.test.ts +25 -0
- package/project/.sdk/tm/zig/core/context.zig +34 -0
- package/project/.sdk/tm/zig/core/error.zig +22 -1
- package/project/.sdk/tm/zig/core/utility.zig +403 -39
- package/project/.sdk/tm/zig/feature/audit.zig +4 -2
- package/project/.sdk/tm/zig/feature/cost.zig +3 -2
- package/project/.sdk/tm/zig/feature/debug.zig +20 -25
- package/project/.sdk/tm/zig/feature/log.zig +3 -1
- package/project/.sdk/tm/zig/feature/proxy.zig +47 -6
- package/project/.sdk/tm/zig/feature/secrets.zig +7 -0
- package/project/.sdk/tm/zig/feature/telemetry.zig +4 -2
- package/project/.sdk/tm/zig/test/feature_test.zig +2 -2
- package/project/sdkgen-package.json +1 -1
- package/src/helpers/naming.ts +1 -1
|
@@ -1,7 +1,590 @@
|
|
|
1
1
|
package utility
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"encoding/base64"
|
|
6
|
+
"encoding/json"
|
|
7
|
+
"fmt"
|
|
8
|
+
"math"
|
|
9
|
+
"reflect"
|
|
10
|
+
"sort"
|
|
11
|
+
"strconv"
|
|
12
|
+
"strings"
|
|
13
|
+
"sync"
|
|
14
|
+
|
|
15
|
+
vs "github.com/voxgig/struct"
|
|
16
|
+
|
|
17
|
+
"GOMODULE/core"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
// Everything that leaves the pipeline passes through clean: the error, the
|
|
21
|
+
// explain record, the serialised context, and whatever a feature emits. A
|
|
22
|
+
// registered secret VALUE (and its encoded forms) is replaced wherever it
|
|
23
|
+
// appears in a string; a value under a sensitive KEY name is masked whatever
|
|
24
|
+
// it holds. Inside the pipeline data stays raw for the hooks that add to it.
|
|
25
|
+
|
|
26
|
+
const cleanMaxDepth = 32
|
|
27
|
+
const cleanCircular = "[circular]"
|
|
28
|
+
|
|
29
|
+
// The derived clean block makeOptions builds, shared by every context of a
|
|
30
|
+
// client. Unlike the ts reference it is appended to from any goroutine
|
|
31
|
+
// (prepareAuth registers per request), so the registry is locked.
|
|
32
|
+
type cleanConfig struct {
|
|
33
|
+
active bool
|
|
34
|
+
keys []string
|
|
35
|
+
mask string
|
|
36
|
+
hint int
|
|
37
|
+
min int
|
|
38
|
+
|
|
39
|
+
mu sync.RWMutex
|
|
40
|
+
values []string
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// What a snapshot has no data form for (a function, a channel).
|
|
44
|
+
type cleanDrop struct{}
|
|
45
|
+
|
|
46
|
+
// A plain error whose message was cleaned; the cause stays reachable by
|
|
47
|
+
// Unwrap, the way ctx does on the SDK error, and never by a printer.
|
|
48
|
+
type cleanedError struct {
|
|
49
|
+
msg string
|
|
50
|
+
cause error
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
func (e *cleanedError) Error() string { return e.msg }
|
|
54
|
+
func (e *cleanedError) Unwrap() error { return e.cause }
|
|
55
|
+
|
|
56
|
+
func cleanNormKey(key string) string {
|
|
57
|
+
return strings.NewReplacer("-", "", "_", "").Replace(strings.ToLower(key))
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
func cleanSplit(raw any) []string {
|
|
61
|
+
out := []string{}
|
|
62
|
+
switch v := raw.(type) {
|
|
63
|
+
case []string:
|
|
64
|
+
return append(out, v...)
|
|
65
|
+
case []any:
|
|
66
|
+
for _, item := range v {
|
|
67
|
+
if s, ok := item.(string); ok {
|
|
68
|
+
out = append(out, s)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return out
|
|
72
|
+
case string:
|
|
73
|
+
for _, part := range strings.Split(v, ",") {
|
|
74
|
+
if part = strings.TrimSpace(part); part != "" {
|
|
75
|
+
out = append(out, part)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return out
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
func cleanSplitKeys(raw any) []string {
|
|
83
|
+
out := []string{}
|
|
84
|
+
for _, k := range cleanSplit(raw) {
|
|
85
|
+
if nk := cleanNormKey(k); nk != "" {
|
|
86
|
+
out = append(out, nk)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return out
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// The spec carries numbers as strings, so every target reads it alike.
|
|
93
|
+
func cleanCount(val any, dflt int) int {
|
|
94
|
+
var n float64
|
|
95
|
+
switch v := val.(type) {
|
|
96
|
+
case string:
|
|
97
|
+
f, err := strconv.ParseFloat(strings.TrimSpace(v), 64)
|
|
98
|
+
if err != nil {
|
|
99
|
+
return dflt
|
|
100
|
+
}
|
|
101
|
+
n = f
|
|
102
|
+
case json.Number:
|
|
103
|
+
f, err := v.Float64()
|
|
104
|
+
if err != nil {
|
|
105
|
+
return dflt
|
|
106
|
+
}
|
|
107
|
+
n = f
|
|
108
|
+
default:
|
|
109
|
+
rv := reflect.ValueOf(val)
|
|
110
|
+
switch rv.Kind() {
|
|
111
|
+
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
|
112
|
+
n = float64(rv.Int())
|
|
113
|
+
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
|
114
|
+
n = float64(rv.Uint())
|
|
115
|
+
case reflect.Float32, reflect.Float64:
|
|
116
|
+
n = rv.Float()
|
|
117
|
+
default:
|
|
118
|
+
return dflt
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
n = math.Floor(n)
|
|
122
|
+
if math.IsNaN(n) || math.IsInf(n, 0) || n < 0 {
|
|
123
|
+
return dflt
|
|
124
|
+
}
|
|
125
|
+
return int(n)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
func makeCleanConfig(cleanopts map[string]any) *cleanConfig {
|
|
129
|
+
cfg := &cleanConfig{
|
|
130
|
+
active: true,
|
|
131
|
+
keys: cleanSplitKeys(cleanopts["keys"]),
|
|
132
|
+
values: []string{},
|
|
133
|
+
mask: "[redacted]",
|
|
134
|
+
hint: cleanCount(cleanopts["hint"], 0),
|
|
135
|
+
min: cleanCount(cleanopts["min"], 4),
|
|
136
|
+
}
|
|
137
|
+
if active, ok := cleanopts["active"].(bool); ok && !active {
|
|
138
|
+
cfg.active = false
|
|
139
|
+
}
|
|
140
|
+
if mask, ok := cleanopts["mask"].(string); ok {
|
|
141
|
+
cfg.mask = mask
|
|
142
|
+
}
|
|
143
|
+
if cfg.min < 1 {
|
|
144
|
+
cfg.min = 1
|
|
145
|
+
}
|
|
146
|
+
return cfg
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// The derived block makeOptions builds; a context without options (makeError
|
|
150
|
+
// is reached with a bare one) falls back to the schema defaults, so nothing
|
|
151
|
+
// leaves raw for want of a constructor.
|
|
152
|
+
func cleanConfigOf(ctx *core.Context) *cleanConfig {
|
|
153
|
+
if ctx != nil && ctx.Options != nil {
|
|
154
|
+
if derived, ok := ctx.Options["__derived__"].(map[string]any); ok {
|
|
155
|
+
if cfg, ok := derived["clean"].(*cleanConfig); ok {
|
|
156
|
+
return cfg
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
spec, _ := core.OPTSPEC["clean"].(map[string]any)
|
|
161
|
+
return makeCleanConfig(spec)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// encodeURIComponent, byte for byte: the query form of a credential.
|
|
165
|
+
func cleanPercent(s string) string {
|
|
166
|
+
const keep = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.!~*'()"
|
|
167
|
+
var b strings.Builder
|
|
168
|
+
for i := 0; i < len(s); i++ {
|
|
169
|
+
c := s[i]
|
|
170
|
+
if strings.IndexByte(keep, c) >= 0 {
|
|
171
|
+
b.WriteByte(c)
|
|
172
|
+
} else {
|
|
173
|
+
b.WriteString(fmt.Sprintf("%%%02X", c))
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return b.String()
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
func cleanJSONEscape(s string) string {
|
|
180
|
+
var buf bytes.Buffer
|
|
181
|
+
enc := json.NewEncoder(&buf)
|
|
182
|
+
enc.SetEscapeHTML(false)
|
|
183
|
+
if err := enc.Encode(s); err != nil {
|
|
184
|
+
return ""
|
|
185
|
+
}
|
|
186
|
+
out := strings.TrimSpace(buf.String())
|
|
187
|
+
if len(out) < 2 {
|
|
188
|
+
return ""
|
|
189
|
+
}
|
|
190
|
+
return out[1 : len(out)-1]
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// The encoded forms a value travels in: Basic and Bearer both carry base64,
|
|
194
|
+
// a query credential is percent-encoded, and a JSON dump escapes it.
|
|
195
|
+
func cleanForms(value string) []string {
|
|
196
|
+
out := []string{value}
|
|
197
|
+
add := func(s string) {
|
|
198
|
+
if s != "" && !cleanHas(out, s) {
|
|
199
|
+
out = append(out, s)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
add(base64.StdEncoding.EncodeToString([]byte(value)))
|
|
203
|
+
add(cleanPercent(value))
|
|
204
|
+
add(cleanJSONEscape(value))
|
|
205
|
+
return out
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
func cleanHas(list []string, s string) bool {
|
|
209
|
+
for _, item := range list {
|
|
210
|
+
if item == s {
|
|
211
|
+
return true
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return false
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Register a secret value. Idempotent; shorter than `min` is not a secret
|
|
218
|
+
// the SDK can mask without blanking ordinary text.
|
|
219
|
+
func (cfg *cleanConfig) add(value string) {
|
|
220
|
+
if len(value) < cfg.min {
|
|
221
|
+
return
|
|
222
|
+
}
|
|
223
|
+
cfg.mu.Lock()
|
|
224
|
+
defer cfg.mu.Unlock()
|
|
225
|
+
changed := false
|
|
226
|
+
for _, form := range cleanForms(value) {
|
|
227
|
+
if len(form) >= cfg.min && !cleanHas(cfg.values, form) {
|
|
228
|
+
cfg.values = append(cfg.values, form)
|
|
229
|
+
changed = true
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if changed {
|
|
233
|
+
sort.SliceStable(cfg.values, func(i, j int) bool {
|
|
234
|
+
return len(cfg.values[i]) > len(cfg.values[j])
|
|
235
|
+
})
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
func cleanAddUtil(ctx *core.Context, val any) {
|
|
240
|
+
if s, ok := val.(string); ok {
|
|
241
|
+
cleanConfigOf(ctx).add(s)
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// A number registers as its decimal text, the form a message quotes it in.
|
|
246
|
+
func cleanScalarText(val any) (string, bool) {
|
|
247
|
+
switch v := val.(type) {
|
|
248
|
+
case string:
|
|
249
|
+
return v, true
|
|
250
|
+
case json.Number:
|
|
251
|
+
return v.String(), true
|
|
252
|
+
case bool:
|
|
253
|
+
return "", false
|
|
254
|
+
}
|
|
255
|
+
rv := reflect.ValueOf(val)
|
|
256
|
+
switch rv.Kind() {
|
|
257
|
+
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
|
258
|
+
return strconv.FormatInt(rv.Int(), 10), true
|
|
259
|
+
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
|
260
|
+
return strconv.FormatUint(rv.Uint(), 10), true
|
|
261
|
+
case reflect.Float32, reflect.Float64:
|
|
262
|
+
return strconv.FormatFloat(rv.Float(), 'f', -1, 64), true
|
|
263
|
+
}
|
|
264
|
+
return "", false
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Every scalar under a sensitive name, at any depth and of any shape: a
|
|
268
|
+
// credential mistyped as a map or a number is still a credential, and the
|
|
269
|
+
// validation that rejects it can quote it.
|
|
270
|
+
func (cfg *cleanConfig) addSensitive(val any, under bool, depth int, seen []uintptr) {
|
|
271
|
+
if val == nil || cleanMaxDepth <= depth {
|
|
272
|
+
return
|
|
273
|
+
}
|
|
274
|
+
if s, ok := cleanScalarText(val); ok {
|
|
275
|
+
if under {
|
|
276
|
+
cfg.add(s)
|
|
277
|
+
}
|
|
278
|
+
return
|
|
279
|
+
}
|
|
280
|
+
rv := reflect.ValueOf(val)
|
|
281
|
+
switch rv.Kind() {
|
|
282
|
+
case reflect.Map, reflect.Slice:
|
|
283
|
+
if rv.IsNil() {
|
|
284
|
+
return
|
|
285
|
+
}
|
|
286
|
+
id := rv.Pointer()
|
|
287
|
+
for _, s := range seen {
|
|
288
|
+
if s == id {
|
|
289
|
+
return
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
seen = append(seen, id)
|
|
293
|
+
case reflect.Array:
|
|
294
|
+
default:
|
|
295
|
+
return
|
|
296
|
+
}
|
|
297
|
+
if rv.Kind() == reflect.Map {
|
|
298
|
+
iter := rv.MapRange()
|
|
299
|
+
for iter.Next() {
|
|
300
|
+
k := fmt.Sprint(iter.Key().Interface())
|
|
301
|
+
cfg.addSensitive(iter.Value().Interface(), under || cfg.sensitive(k), depth+1, seen)
|
|
302
|
+
}
|
|
303
|
+
return
|
|
304
|
+
}
|
|
305
|
+
for i := 0; i < rv.Len(); i++ {
|
|
306
|
+
cfg.addSensitive(rv.Index(i).Interface(), under, depth+1, seen)
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
func cleanAddSensitive(ctx *core.Context, val any) {
|
|
311
|
+
cleanConfigOf(ctx).addSensitive(val, false, 0, nil)
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// One pass over one value: the registry as it stood when the pass began,
|
|
315
|
+
// and the ancestors of the node in hand, for cutting cycles.
|
|
316
|
+
type cleaner struct {
|
|
317
|
+
cfg *cleanConfig
|
|
318
|
+
values []string
|
|
319
|
+
seen []uintptr
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
func newCleaner(cfg *cleanConfig) *cleaner {
|
|
323
|
+
cfg.mu.RLock()
|
|
324
|
+
values := append([]string(nil), cfg.values...)
|
|
325
|
+
cfg.mu.RUnlock()
|
|
326
|
+
return &cleaner{cfg: cfg, values: values}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
func (c *cleaner) maskValue(value string) string {
|
|
330
|
+
if 0 < c.cfg.hint {
|
|
331
|
+
runes := []rune(value)
|
|
332
|
+
if len(runes) > 2*c.cfg.hint {
|
|
333
|
+
return c.cfg.mask + string(runes[len(runes)-c.cfg.hint:])
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return c.cfg.mask
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
func (c *cleaner) cleanString(text string) string {
|
|
340
|
+
out := text
|
|
341
|
+
for _, value := range c.values {
|
|
342
|
+
if strings.Contains(out, value) {
|
|
343
|
+
out = strings.ReplaceAll(out, value, c.maskValue(value))
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return out
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
func (cfg *cleanConfig) sensitive(key string) bool {
|
|
350
|
+
nk := cleanNormKey(key)
|
|
351
|
+
for _, k := range cfg.keys {
|
|
352
|
+
if strings.Contains(nk, k) {
|
|
353
|
+
return true
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return false
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
func (c *cleaner) sensitiveKey(key string) bool {
|
|
360
|
+
return c.cfg.sensitive(key)
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// A plain-data copy of what is about to leave: the SDK's own types become
|
|
364
|
+
// their records, a json.Marshaler is honoured (the go spelling of toJSON),
|
|
365
|
+
// functions and channels are dropped, cycles are cut, and no live object is
|
|
366
|
+
// shared with the copy - masking the copy must never mask the pipeline's own
|
|
367
|
+
// spec.
|
|
368
|
+
func (c *cleaner) snapshot(val any, key string, haskey bool, depth int) any {
|
|
369
|
+
if val == nil {
|
|
370
|
+
return nil
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
sensitive := haskey && c.sensitiveKey(key)
|
|
374
|
+
|
|
375
|
+
switch v := val.(type) {
|
|
376
|
+
case string:
|
|
377
|
+
if sensitive {
|
|
378
|
+
return c.maskValue(v)
|
|
379
|
+
}
|
|
380
|
+
return c.cleanString(v)
|
|
381
|
+
case bool, int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64,
|
|
382
|
+
float32, float64, json.Number:
|
|
383
|
+
if sensitive {
|
|
384
|
+
return c.cfg.mask
|
|
385
|
+
}
|
|
386
|
+
return v
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if sensitive {
|
|
390
|
+
return c.cfg.mask
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if cleanMaxDepth <= depth {
|
|
394
|
+
return cleanCircular
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
rv := reflect.ValueOf(val)
|
|
398
|
+
switch rv.Kind() {
|
|
399
|
+
case reflect.Map, reflect.Ptr, reflect.Slice:
|
|
400
|
+
if rv.IsNil() {
|
|
401
|
+
return nil
|
|
402
|
+
}
|
|
403
|
+
id := rv.Pointer()
|
|
404
|
+
for _, seen := range c.seen {
|
|
405
|
+
if seen == id {
|
|
406
|
+
return cleanCircular
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
c.seen = append(c.seen, id)
|
|
410
|
+
defer func() { c.seen = c.seen[:len(c.seen)-1] }()
|
|
411
|
+
case reflect.Func, reflect.Chan, reflect.UnsafePointer:
|
|
412
|
+
return cleanDrop{}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
switch v := val.(type) {
|
|
416
|
+
case map[string]any:
|
|
417
|
+
return c.plain(v, depth)
|
|
418
|
+
case []any:
|
|
419
|
+
return c.list(v, depth)
|
|
420
|
+
case *vs.ListRef[any]:
|
|
421
|
+
return c.list(v.List, depth)
|
|
422
|
+
case *core.Context:
|
|
423
|
+
return c.plain(v.Record(), depth)
|
|
424
|
+
case *core.ProjectNameError:
|
|
425
|
+
return c.plain(v.Record(), depth)
|
|
426
|
+
case error:
|
|
427
|
+
return map[string]any{"message": c.cleanString(v.Error())}
|
|
428
|
+
case *core.Spec:
|
|
429
|
+
return c.plain(cleanSpecRecord(v), depth)
|
|
430
|
+
case *core.Result:
|
|
431
|
+
return c.plain(cleanResultRecord(v), depth)
|
|
432
|
+
case *core.Response:
|
|
433
|
+
return c.plain(map[string]any{
|
|
434
|
+
"status": v.Status, "statusText": v.StatusText, "headers": v.Headers,
|
|
435
|
+
"body": v.Body, "err": v.Err,
|
|
436
|
+
}, depth)
|
|
437
|
+
case *core.Operation:
|
|
438
|
+
return c.plain(map[string]any{
|
|
439
|
+
"entity": v.Entity, "name": v.Name, "input": v.Input,
|
|
440
|
+
"points": v.Points, "alias": v.Alias,
|
|
441
|
+
}, depth)
|
|
442
|
+
case *core.Control:
|
|
443
|
+
return c.plain(map[string]any{
|
|
444
|
+
"throw": v.Throw, "err": v.Err, "explain": v.Explain,
|
|
445
|
+
"actor": v.Actor, "paging": v.Paging,
|
|
446
|
+
}, depth)
|
|
447
|
+
case core.Entity:
|
|
448
|
+
// Data() fires the GetData hook, and a hook that logs would come
|
|
449
|
+
// straight back here; the name is all an entity says of itself.
|
|
450
|
+
return map[string]any{"name": v.GetName()}
|
|
451
|
+
case json.Marshaler:
|
|
452
|
+
return c.roundtrip(val, key, haskey, depth)
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
switch rv.Kind() {
|
|
456
|
+
case reflect.Ptr:
|
|
457
|
+
return c.snapshot(rv.Elem().Interface(), key, haskey, depth+1)
|
|
458
|
+
case reflect.Map:
|
|
459
|
+
byname := map[string]any{}
|
|
460
|
+
iter := rv.MapRange()
|
|
461
|
+
for iter.Next() {
|
|
462
|
+
byname[fmt.Sprint(iter.Key().Interface())] = iter.Value().Interface()
|
|
463
|
+
}
|
|
464
|
+
return c.plain(byname, depth)
|
|
465
|
+
case reflect.Slice, reflect.Array:
|
|
466
|
+
out := make([]any, 0, rv.Len())
|
|
467
|
+
for i := 0; i < rv.Len(); i++ {
|
|
468
|
+
out = append(out, c.item(rv.Index(i).Interface(), depth))
|
|
469
|
+
}
|
|
470
|
+
return out
|
|
471
|
+
case reflect.Struct:
|
|
472
|
+
return c.roundtrip(val, key, haskey, depth)
|
|
473
|
+
}
|
|
4
474
|
|
|
5
|
-
func cleanUtil(ctx *core.Context, val any) any {
|
|
6
475
|
return val
|
|
7
476
|
}
|
|
477
|
+
|
|
478
|
+
// A struct leaves as encoding/json would write it, then reads back as plain
|
|
479
|
+
// data for the walk; one that cannot be encoded leaves as its printed form,
|
|
480
|
+
// value-redacted.
|
|
481
|
+
func (c *cleaner) roundtrip(val any, key string, haskey bool, depth int) any {
|
|
482
|
+
raw, err := json.Marshal(val)
|
|
483
|
+
if err != nil {
|
|
484
|
+
return c.cleanString(fmt.Sprintf("%v", val))
|
|
485
|
+
}
|
|
486
|
+
var plain any
|
|
487
|
+
if err := json.Unmarshal(raw, &plain); err != nil {
|
|
488
|
+
return c.cleanString(string(raw))
|
|
489
|
+
}
|
|
490
|
+
return c.snapshot(plain, key, haskey, depth+1)
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// Keys in sorted order, so the counter a masked name takes does not depend
|
|
494
|
+
// on map iteration.
|
|
495
|
+
func (c *cleaner) plain(m map[string]any, depth int) map[string]any {
|
|
496
|
+
keys := make([]string, 0, len(m))
|
|
497
|
+
for k := range m {
|
|
498
|
+
keys = append(keys, k)
|
|
499
|
+
}
|
|
500
|
+
sort.Strings(keys)
|
|
501
|
+
out := make(map[string]any, len(m))
|
|
502
|
+
for _, k := range keys {
|
|
503
|
+
if s := c.snapshot(m[k], k, true, depth+1); (cleanDrop{}) != s {
|
|
504
|
+
out[c.cleanName(out, k)] = s
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
return out
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// A registered value used as a property name is masked like any other
|
|
511
|
+
// string; names that mask alike take a counter, so none is lost.
|
|
512
|
+
func (c *cleaner) cleanName(out map[string]any, key string) string {
|
|
513
|
+
name := c.cleanString(key)
|
|
514
|
+
if _, taken := out[name]; name == key || !taken {
|
|
515
|
+
return name
|
|
516
|
+
}
|
|
517
|
+
i := 1
|
|
518
|
+
for {
|
|
519
|
+
cand := name + "#" + strconv.Itoa(i)
|
|
520
|
+
if _, taken := out[cand]; !taken {
|
|
521
|
+
return cand
|
|
522
|
+
}
|
|
523
|
+
i++
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
func (c *cleaner) list(l []any, depth int) []any {
|
|
528
|
+
out := make([]any, 0, len(l))
|
|
529
|
+
for _, v := range l {
|
|
530
|
+
out = append(out, c.item(v, depth))
|
|
531
|
+
}
|
|
532
|
+
return out
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
func (c *cleaner) item(v any, depth int) any {
|
|
536
|
+
s := c.snapshot(v, "", false, depth+1)
|
|
537
|
+
if (cleanDrop{}) == s {
|
|
538
|
+
return nil
|
|
539
|
+
}
|
|
540
|
+
return s
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
func cleanSpecRecord(s *core.Spec) map[string]any {
|
|
544
|
+
return map[string]any{
|
|
545
|
+
"parts": s.Parts, "headers": s.Headers, "alias": s.Alias,
|
|
546
|
+
"base": s.Base, "prefix": s.Prefix, "suffix": s.Suffix,
|
|
547
|
+
"params": s.Params, "query": s.Query, "step": s.Step,
|
|
548
|
+
"method": s.Method, "body": s.Body, "url": s.Url, "path": s.Path,
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
func cleanResultRecord(r *core.Result) map[string]any {
|
|
553
|
+
return map[string]any{
|
|
554
|
+
"ok": r.Ok, "status": r.Status, "statusText": r.StatusText,
|
|
555
|
+
"headers": r.Headers, "body": r.Body, "err": r.Err,
|
|
556
|
+
"resdata": r.Resdata, "resmatch": r.Resmatch,
|
|
557
|
+
"paging": r.Paging, "streaming": r.Streaming,
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// Clean a value on its way out. A string is redacted; the SDK error is
|
|
562
|
+
// redacted IN PLACE (it is about to be returned, and its identity matters to
|
|
563
|
+
// the caller); anything else comes back as a masked plain-data copy.
|
|
564
|
+
func cleanUtil(ctx *core.Context, val any) any {
|
|
565
|
+
cfg := cleanConfigOf(ctx)
|
|
566
|
+
|
|
567
|
+
if !cfg.active {
|
|
568
|
+
return val
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
c := newCleaner(cfg)
|
|
572
|
+
|
|
573
|
+
switch v := val.(type) {
|
|
574
|
+
case string:
|
|
575
|
+
return c.cleanString(v)
|
|
576
|
+
case *core.ProjectNameError:
|
|
577
|
+
if v == nil {
|
|
578
|
+
return v
|
|
579
|
+
}
|
|
580
|
+
v.Msg = c.cleanString(v.Msg)
|
|
581
|
+
v.Code = c.cleanString(v.Code)
|
|
582
|
+
v.Result = c.item(v.Result, 0)
|
|
583
|
+
v.Spec = c.item(v.Spec, 0)
|
|
584
|
+
return v
|
|
585
|
+
case error:
|
|
586
|
+
return &cleanedError{msg: c.cleanString(v.Error()), cause: v}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
return c.item(val, -1)
|
|
590
|
+
}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
package utility
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import (
|
|
4
|
+
"reflect"
|
|
5
|
+
|
|
6
|
+
"GOMODULE/core"
|
|
7
|
+
)
|
|
4
8
|
|
|
5
9
|
func doneUtil(ctx *core.Context) (any, error) {
|
|
6
|
-
|
|
7
|
-
ctx.Ctrl.Explain = cleanUtil(ctx, ctx.Ctrl.Explain).(map[string]any)
|
|
8
|
-
if explainResult, ok := ctx.Ctrl.Explain["result"]; ok {
|
|
9
|
-
if rm, ok := explainResult.(map[string]any); ok {
|
|
10
|
-
delete(rm, "err")
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
10
|
+
cleanExplain(ctx)
|
|
14
11
|
|
|
15
12
|
if ctx.Result != nil && ctx.Result.Ok {
|
|
16
13
|
return ctx.Result.Resdata, nil
|
|
@@ -18,3 +15,26 @@ func doneUtil(ctx *core.Context) (any, error) {
|
|
|
18
15
|
|
|
19
16
|
return makeErrorUtil(ctx, nil)
|
|
20
17
|
}
|
|
18
|
+
|
|
19
|
+
// The explain map IS the caller's (`ctrl["explain"]`), so the cleaned copy
|
|
20
|
+
// is written back into it rather than swapped in. With clean off it is the
|
|
21
|
+
// same map, which the copy-back would empty.
|
|
22
|
+
func cleanExplain(ctx *core.Context) {
|
|
23
|
+
explain := ctx.Ctrl.Explain
|
|
24
|
+
if explain == nil {
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
cleaned, ok := cleanUtil(ctx, explain).(map[string]any)
|
|
28
|
+
if ok && reflect.ValueOf(cleaned).Pointer() != reflect.ValueOf(explain).Pointer() {
|
|
29
|
+
for k := range explain {
|
|
30
|
+
delete(explain, k)
|
|
31
|
+
}
|
|
32
|
+
for k, v := range cleaned {
|
|
33
|
+
explain[k] = v
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// With clean off, explain.result is the live *core.Result, never a map.
|
|
37
|
+
if rm, ok := explain["result"].(map[string]any); ok {
|
|
38
|
+
delete(rm, "err")
|
|
39
|
+
}
|
|
40
|
+
}
|