@voxgig/sdkgen 4.32.1 → 4.34.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/action/copies.d.ts +21 -0
- package/dist/action/copies.js +146 -0
- package/dist/action/copies.js.map +1 -0
- package/dist/action/doctor.d.ts +15 -2
- package/dist/action/doctor.js +169 -23
- package/dist/action/doctor.js.map +1 -1
- package/dist/action/edition.js +6 -2
- package/dist/action/edition.js.map +1 -1
- package/dist/action/feature.js +6 -2
- package/dist/action/feature.js.map +1 -1
- package/dist/action/package.js +28 -10
- package/dist/action/package.js.map +1 -1
- package/dist/action/remove.js +2 -0
- package/dist/action/remove.js.map +1 -1
- package/dist/action/resolve.d.ts +1 -0
- package/dist/action/resolve.js +10 -2
- package/dist/action/resolve.js.map +1 -1
- package/dist/action/target.js +6 -2
- package/dist/action/target.js.map +1 -1
- package/dist/helpers/naming.js +1 -1
- package/dist/helpers/naming.js.map +1 -1
- package/dist/sdkgen.d.ts +2 -1
- package/dist/sdkgen.js +36 -3
- package/dist/sdkgen.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/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/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/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/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/action/copies.ts +219 -0
- package/src/action/doctor.ts +247 -21
- package/src/action/edition.ts +10 -2
- package/src/action/feature.ts +11 -2
- package/src/action/package.ts +31 -10
- package/src/action/remove.ts +4 -0
- package/src/action/resolve.ts +16 -3
- package/src/action/target.ts +10 -2
- package/src/helpers/naming.ts +1 -1
- package/src/sdkgen.ts +45 -5
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
use std::rc::Rc;
|
|
3
3
|
|
|
4
4
|
use crate::core::context::Context;
|
|
5
|
+
use crate::core::helpers::{call_vfn, get_str, getp, jo};
|
|
5
6
|
use crate::core::types::Feature;
|
|
6
7
|
use crate::feature::support::*;
|
|
7
8
|
use crate::utility::voxgigstruct::Value;
|
|
@@ -42,13 +43,47 @@ impl LogFeature {
|
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
let opname =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
None =>
|
|
46
|
+
let (entity, opname) = {
|
|
47
|
+
let op = ctx.op.borrow();
|
|
48
|
+
(op.entity.clone(), op.name.clone())
|
|
49
|
+
};
|
|
50
|
+
let spec = match ctx.spec.borrow().clone() {
|
|
51
|
+
Some(sp) => sp.borrow().to_value(),
|
|
52
|
+
None => Value::Noval,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// A log line leaves the pipeline, so it carries the cleaned record:
|
|
56
|
+
// the spec after auth holds the credential, and a logger serialises
|
|
57
|
+
// whatever it is handed.
|
|
58
|
+
let record = ctx.util().clean(
|
|
59
|
+
ctx,
|
|
60
|
+
&jo(vec![
|
|
61
|
+
("hook", Value::str(hook)),
|
|
62
|
+
(
|
|
63
|
+
"op",
|
|
64
|
+
jo(vec![
|
|
65
|
+
("entity", Value::str(entity)),
|
|
66
|
+
("name", Value::str(opname.clone())),
|
|
67
|
+
]),
|
|
68
|
+
),
|
|
69
|
+
("spec", spec),
|
|
70
|
+
("ctx", ctx.to_value()),
|
|
71
|
+
]),
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
let logger = getp(&self.options, "logger");
|
|
75
|
+
if let Value::Func(_) = logger {
|
|
76
|
+
call_vfn(&logger, &record);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let specinfo = match getp(&record, "spec") {
|
|
81
|
+
Value::Map(_) => format!(
|
|
82
|
+
"{} {}",
|
|
83
|
+
get_str(&getp(&record, "spec"), "method").unwrap_or_default(),
|
|
84
|
+
get_str(&getp(&record, "spec"), "path").unwrap_or_default()
|
|
85
|
+
),
|
|
86
|
+
_ => String::new(),
|
|
52
87
|
};
|
|
53
88
|
|
|
54
89
|
eprintln!(
|
|
@@ -12,10 +12,50 @@ use crate::utility::voxgigstruct::Value;
|
|
|
12
12
|
pub struct ProxyTrack {
|
|
13
13
|
// Activity tracking (mirrors the ts client._proxy record).
|
|
14
14
|
pub routed: i64,
|
|
15
|
+
/// The proxy URL as it may be shown: userinfo masked.
|
|
15
16
|
pub url: String,
|
|
17
|
+
/// The proxy URL as it is used, kept off the tracking record.
|
|
18
|
+
raw_url: String,
|
|
16
19
|
pub no_proxy: Vec<String>,
|
|
17
20
|
}
|
|
18
21
|
|
|
22
|
+
// A proxy URL may carry credentials as userinfo, from the option or the
|
|
23
|
+
// environment, and neither is under a sensitive key name.
|
|
24
|
+
fn userinfo(url: &str) -> Vec<String> {
|
|
25
|
+
let rest = match url.find("://") {
|
|
26
|
+
Some(i) => &url[i + 3..],
|
|
27
|
+
None => url,
|
|
28
|
+
};
|
|
29
|
+
let authority = &rest[..rest.find('/').unwrap_or(rest.len())];
|
|
30
|
+
let at = match authority.rfind('@') {
|
|
31
|
+
Some(i) => i,
|
|
32
|
+
None => return Vec::new(),
|
|
33
|
+
};
|
|
34
|
+
authority[..at]
|
|
35
|
+
.splitn(2, ':')
|
|
36
|
+
.filter(|p| !p.is_empty())
|
|
37
|
+
.map(|p| p.to_string())
|
|
38
|
+
.collect()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
fn percent_decode(s: &str) -> String {
|
|
42
|
+
let bytes = s.as_bytes();
|
|
43
|
+
let mut out: Vec<u8> = Vec::with_capacity(bytes.len());
|
|
44
|
+
let mut i = 0;
|
|
45
|
+
while i < bytes.len() {
|
|
46
|
+
if b'%' == bytes[i] && i + 2 < bytes.len() {
|
|
47
|
+
if let Ok(b) = u8::from_str_radix(&s[i + 1..i + 3], 16) {
|
|
48
|
+
out.push(b);
|
|
49
|
+
i += 3;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
out.push(bytes[i]);
|
|
54
|
+
i += 1;
|
|
55
|
+
}
|
|
56
|
+
String::from_utf8(out).unwrap_or_else(|_| s.to_string())
|
|
57
|
+
}
|
|
58
|
+
|
|
19
59
|
pub struct ProxyFeature {
|
|
20
60
|
pub name: String,
|
|
21
61
|
pub active: bool,
|
|
@@ -117,9 +157,15 @@ impl Feature for ProxyFeature {
|
|
|
117
157
|
.filter(|s| !s.is_empty())
|
|
118
158
|
.collect();
|
|
119
159
|
|
|
160
|
+
for part in userinfo(&url) {
|
|
161
|
+
ctx.util().clean_add(ctx, &part);
|
|
162
|
+
ctx.util().clean_add(ctx, &percent_decode(&part));
|
|
163
|
+
}
|
|
164
|
+
|
|
120
165
|
{
|
|
121
166
|
let mut t = self.track.borrow_mut();
|
|
122
|
-
t.url = url;
|
|
167
|
+
t.url = ctx.util().clean_str(ctx, &url);
|
|
168
|
+
t.raw_url = url;
|
|
123
169
|
t.no_proxy = no_proxy;
|
|
124
170
|
}
|
|
125
171
|
|
|
@@ -137,7 +183,7 @@ impl Feature for ProxyFeature {
|
|
|
137
183
|
fn route(track: &Rc<RefCell<ProxyTrack>>, url: &str, fetchdef: &Value) -> Value {
|
|
138
184
|
let (proxy_url, no_proxy) = {
|
|
139
185
|
let t = track.borrow();
|
|
140
|
-
(t.
|
|
186
|
+
(t.raw_url.clone(), t.no_proxy.clone())
|
|
141
187
|
};
|
|
142
188
|
|
|
143
189
|
if proxy_url.is_empty() || bypass(&no_proxy, url) {
|
|
@@ -253,6 +253,7 @@ impl Feature for SecretsFeature {
|
|
|
253
253
|
let mut specs: Vec<ProviderSpec> = Vec::new();
|
|
254
254
|
|
|
255
255
|
if !explicit.is_empty() {
|
|
256
|
+
register(&state.options, &explicit);
|
|
256
257
|
match envkey(&state.secretname, "") {
|
|
257
258
|
Ok(key) => {
|
|
258
259
|
let mut values: BTreeMap<String, String> = BTreeMap::new();
|
|
@@ -444,6 +445,10 @@ fn resolve_once(state: &Rc<RefCell<SecretsState>>) -> Result<bool, ProjectNameEr
|
|
|
444
445
|
// falls through.
|
|
445
446
|
let found = found.map_err(|err| fail(&format!("{}", err)))?;
|
|
446
447
|
|
|
448
|
+
if let Some(value) = &found {
|
|
449
|
+
register(&state.borrow().options, value);
|
|
450
|
+
}
|
|
451
|
+
|
|
447
452
|
{
|
|
448
453
|
let mut s = state.borrow_mut();
|
|
449
454
|
|
|
@@ -649,10 +654,17 @@ fn buy(state: &Rc<RefCell<SecretsState>>) -> Result<String, ProjectNameError> {
|
|
|
649
654
|
|
|
650
655
|
let token = buy_once(state)?;
|
|
651
656
|
state.borrow_mut().cred = token.clone();
|
|
657
|
+
register(&state.borrow().options, &token);
|
|
652
658
|
|
|
653
659
|
Ok(token)
|
|
654
660
|
}
|
|
655
661
|
|
|
662
|
+
// A resolved or bought value arrives under no option key the intake
|
|
663
|
+
// registration saw; the options map is the client's own, Rc-shared.
|
|
664
|
+
fn register(options: &Value, value: &str) {
|
|
665
|
+
crate::utility::clean::clean_add_opts(options, value);
|
|
666
|
+
}
|
|
667
|
+
|
|
656
668
|
fn buy_once(state: &Rc<RefCell<SecretsState>>) -> Result<String, ProjectNameError> {
|
|
657
669
|
let (refresh, exchange, options, secretname) = {
|
|
658
670
|
let s = state.borrow();
|
|
@@ -1189,7 +1189,7 @@ fn feature_debug_redacts_and_honours_onentry_max() {
|
|
|
1189
1189
|
let headers = getp(&seen.borrow()[0], "headers");
|
|
1190
1190
|
assert_eq!(
|
|
1191
1191
|
getp(&headers, "authorization"),
|
|
1192
|
-
Value::str("
|
|
1192
|
+
Value::str("[redacted]"),
|
|
1193
1193
|
"expected redacted authorization"
|
|
1194
1194
|
);
|
|
1195
1195
|
}
|
|
@@ -1247,7 +1247,7 @@ fn feature_debug_injected_clock_and_custom_redact() {
|
|
|
1247
1247
|
});
|
|
1248
1248
|
let fb = f.borrow();
|
|
1249
1249
|
let headers = getp(&fb.entries[0], "headers");
|
|
1250
|
-
assert_eq!(getp(&headers, "x-secret"), Value::str("
|
|
1250
|
+
assert_eq!(getp(&headers, "x-secret"), Value::str("[redacted]"));
|
|
1251
1251
|
assert_eq!(getp(&headers, "x-ok"), Value::str("show"));
|
|
1252
1252
|
}
|
|
1253
1253
|
|
|
@@ -1,13 +1,454 @@
|
|
|
1
1
|
use std::rc::Rc;
|
|
2
2
|
|
|
3
3
|
use crate::core::context::Context;
|
|
4
|
+
use crate::core::error::ProjectNameError;
|
|
5
|
+
use crate::core::helpers::{getp, getpath, jo, setp};
|
|
6
|
+
use crate::utility::voxgigstruct as vs;
|
|
4
7
|
use crate::utility::voxgigstruct::Value;
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
// Every registered secret VALUE (and its encoded forms) is replaced wherever
|
|
10
|
+
// it appears in a string, and every value under a sensitive KEY name is
|
|
11
|
+
// masked whatever it holds. The registry is the Rc-shared `values` list of
|
|
12
|
+
// `options.__derived__.clean`, so a feature registering a value later
|
|
13
|
+
// reaches the list every context reads.
|
|
14
|
+
|
|
15
|
+
const MAXDEPTH: usize = 32;
|
|
16
|
+
const CIRCULAR: &str = "[circular]";
|
|
17
|
+
const DEFAULT_MASK: &str = "[redacted]";
|
|
18
|
+
|
|
19
|
+
struct CleanConfig {
|
|
20
|
+
active: bool,
|
|
21
|
+
keys: Vec<String>,
|
|
22
|
+
values: Vec<String>,
|
|
23
|
+
mask: String,
|
|
24
|
+
hint: usize,
|
|
25
|
+
min: usize,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
fn normkey(key: &str) -> String {
|
|
29
|
+
key.to_lowercase()
|
|
30
|
+
.chars()
|
|
31
|
+
.filter(|c| '-' != *c && '_' != *c)
|
|
32
|
+
.collect()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
fn strs(val: &Value) -> Vec<String> {
|
|
36
|
+
match val {
|
|
37
|
+
Value::List(l) => l
|
|
38
|
+
.borrow()
|
|
39
|
+
.iter()
|
|
40
|
+
.filter_map(|v| match v {
|
|
41
|
+
Value::Str(s) => Some(s.clone()),
|
|
42
|
+
_ => None,
|
|
43
|
+
})
|
|
44
|
+
.collect(),
|
|
45
|
+
Value::Str(s) => s
|
|
46
|
+
.split(',')
|
|
47
|
+
.map(|p| p.trim().to_string())
|
|
48
|
+
.filter(|p| !p.is_empty())
|
|
49
|
+
.collect(),
|
|
50
|
+
_ => Vec::new(),
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
fn splitkeys(keys: &Value) -> Vec<String> {
|
|
55
|
+
strs(keys)
|
|
56
|
+
.iter()
|
|
57
|
+
.map(|k| normkey(k))
|
|
58
|
+
.filter(|k| !k.is_empty())
|
|
59
|
+
.collect()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/// The comma-separated literal values a caller registers; a list is taken
|
|
63
|
+
/// as-is for a caller that has one.
|
|
64
|
+
pub fn splitvalues(values: &Value) -> Vec<String> {
|
|
65
|
+
strs(values)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// The spec carries numbers as strings, so every target reads it alike.
|
|
69
|
+
fn count(val: &Value, dflt: usize) -> usize {
|
|
70
|
+
let n = match val {
|
|
71
|
+
Value::Num(n) => *n,
|
|
72
|
+
Value::Str(s) => s.trim().parse::<f64>().unwrap_or(f64::NAN),
|
|
73
|
+
_ => f64::NAN,
|
|
74
|
+
};
|
|
75
|
+
if n.is_finite() && 0.0 <= n {
|
|
76
|
+
n.floor() as usize
|
|
77
|
+
} else {
|
|
78
|
+
dflt
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/// The derived clean block from a clean option block: what make_options
|
|
83
|
+
/// stores under `__derived__.clean`.
|
|
84
|
+
pub fn make_clean_config(cleanopts: &Value) -> Value {
|
|
85
|
+
let active = !matches!(getp(cleanopts, "active"), Value::Bool(false));
|
|
86
|
+
let mask = match getp(cleanopts, "mask") {
|
|
87
|
+
Value::Str(s) => s,
|
|
88
|
+
_ => DEFAULT_MASK.to_string(),
|
|
89
|
+
};
|
|
90
|
+
jo(vec![
|
|
91
|
+
("active", Value::Bool(active)),
|
|
92
|
+
(
|
|
93
|
+
"keys",
|
|
94
|
+
Value::list(splitkeys(&getp(cleanopts, "keys")).into_iter().map(Value::str).collect()),
|
|
95
|
+
),
|
|
96
|
+
("values", Value::empty_list()),
|
|
97
|
+
("mask", Value::str(mask)),
|
|
98
|
+
("hint", Value::Num(count(&getp(cleanopts, "hint"), 0) as f64)),
|
|
99
|
+
("min", Value::Num(count(&getp(cleanopts, "min"), 4).max(1) as f64)),
|
|
100
|
+
])
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
fn derived_block(options: &Value) -> Value {
|
|
104
|
+
getpath(&["__derived__", "clean"], options)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// A context without options (make_error is reached with a bare one) falls
|
|
108
|
+
// back to the schema defaults, so nothing leaves raw for want of a
|
|
109
|
+
// constructor.
|
|
110
|
+
fn config_block(ctx: &Context) -> Value {
|
|
111
|
+
let options = ctx.options.borrow().clone();
|
|
112
|
+
let derived = derived_block(&options);
|
|
113
|
+
if let Value::Map(_) = derived {
|
|
114
|
+
return derived;
|
|
115
|
+
}
|
|
116
|
+
make_clean_config(&getp(&crate::core::schema::optspec(), "clean"))
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
fn read_config(block: &Value) -> CleanConfig {
|
|
120
|
+
CleanConfig {
|
|
121
|
+
active: !matches!(getp(block, "active"), Value::Bool(false)),
|
|
122
|
+
keys: strs(&getp(block, "keys")),
|
|
123
|
+
values: strs(&getp(block, "values")),
|
|
124
|
+
mask: match getp(block, "mask") {
|
|
125
|
+
Value::Str(s) => s,
|
|
126
|
+
_ => DEFAULT_MASK.to_string(),
|
|
127
|
+
},
|
|
128
|
+
hint: count(&getp(block, "hint"), 0),
|
|
129
|
+
min: count(&getp(block, "min"), 4).max(1),
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/// Standard base64 (RFC 4648), for the encoded form of a registered value
|
|
134
|
+
/// and for the `Authorization: Basic` composite.
|
|
135
|
+
pub fn base64_encode(input: &[u8]) -> String {
|
|
136
|
+
const ALPHABET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
137
|
+
|
|
138
|
+
let mut out = String::with_capacity((input.len() + 2) / 3 * 4);
|
|
139
|
+
|
|
140
|
+
for chunk in input.chunks(3) {
|
|
141
|
+
let b0 = chunk[0] as usize;
|
|
142
|
+
let b1 = *chunk.get(1).unwrap_or(&0) as usize;
|
|
143
|
+
let b2 = *chunk.get(2).unwrap_or(&0) as usize;
|
|
144
|
+
|
|
145
|
+
out.push(ALPHABET[b0 >> 2] as char);
|
|
146
|
+
out.push(ALPHABET[((b0 & 0x03) << 4) | (b1 >> 4)] as char);
|
|
147
|
+
out.push(if 1 < chunk.len() {
|
|
148
|
+
ALPHABET[((b1 & 0x0f) << 2) | (b2 >> 6)] as char
|
|
149
|
+
} else {
|
|
150
|
+
'='
|
|
151
|
+
});
|
|
152
|
+
out.push(if 2 < chunk.len() {
|
|
153
|
+
ALPHABET[b2 & 0x3f] as char
|
|
154
|
+
} else {
|
|
155
|
+
'='
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
out
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// The encoded forms a value travels in: Basic and Bearer both carry base64,
|
|
163
|
+
// a query credential is percent-encoded, and a JSON dump escapes it.
|
|
164
|
+
fn forms(value: &str) -> Vec<String> {
|
|
165
|
+
let mut out: Vec<String> = vec![value.to_string()];
|
|
166
|
+
let mut add = |s: String| {
|
|
167
|
+
if !s.is_empty() && !out.contains(&s) {
|
|
168
|
+
out.push(s);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
add(base64_encode(value.as_bytes()));
|
|
172
|
+
add(vs::esc_url(&Value::str(value)));
|
|
173
|
+
let json = vs::jsonify(&Value::str(value), None);
|
|
174
|
+
if 2 <= json.len() {
|
|
175
|
+
add(json[1..json.len() - 1].to_string());
|
|
176
|
+
}
|
|
177
|
+
out
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/// Register a secret value against an options map. Idempotent; shorter
|
|
181
|
+
/// than `min` is not a secret the SDK can mask without blanking ordinary
|
|
182
|
+
/// text. A map with no derived block registers nothing.
|
|
183
|
+
pub fn clean_add_opts(options: &Value, value: &str) {
|
|
184
|
+
let block = derived_block(options);
|
|
185
|
+
if !matches!(block, Value::Map(_)) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
let min = count(&getp(&block, "min"), 4).max(1);
|
|
189
|
+
if value.chars().count() < min {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
let list = match getp(&block, "values") {
|
|
193
|
+
Value::List(l) => l,
|
|
194
|
+
_ => {
|
|
195
|
+
let l = Value::empty_list();
|
|
196
|
+
setp(&block, "values", l.clone());
|
|
197
|
+
match l {
|
|
198
|
+
Value::List(l) => l,
|
|
199
|
+
_ => return,
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
let mut items = list.borrow_mut();
|
|
204
|
+
let mut changed = false;
|
|
205
|
+
for form in forms(value) {
|
|
206
|
+
if form.chars().count() < min {
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
let present = items.iter().any(|v| matches!(v, Value::Str(s) if *s == form));
|
|
210
|
+
if !present {
|
|
211
|
+
items.push(Value::str(form));
|
|
212
|
+
changed = true;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if changed {
|
|
216
|
+
items.sort_by(|a, b| {
|
|
217
|
+
let la = a.as_str().map(|s| s.len()).unwrap_or(0);
|
|
218
|
+
let lb = b.as_str().map(|s| s.len()).unwrap_or(0);
|
|
219
|
+
lb.cmp(&la)
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/// Register a secret value the context's options will mask from now on.
|
|
225
|
+
pub fn clean_add(ctx: &Rc<Context>, value: &str) {
|
|
226
|
+
let options = ctx.options.borrow().clone();
|
|
227
|
+
clean_add_opts(&options, value);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
fn mask_value(cfg: &CleanConfig, value: &str) -> String {
|
|
231
|
+
let n = value.chars().count();
|
|
232
|
+
if 0 < cfg.hint && n > 2 * cfg.hint {
|
|
233
|
+
let tail: String = value.chars().skip(n - cfg.hint).collect();
|
|
234
|
+
return format!("{}{}", cfg.mask, tail);
|
|
235
|
+
}
|
|
236
|
+
cfg.mask.clone()
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
fn clean_string(cfg: &CleanConfig, text: &str) -> String {
|
|
240
|
+
let mut out = text.to_string();
|
|
241
|
+
for value in &cfg.values {
|
|
242
|
+
if out.contains(value.as_str()) {
|
|
243
|
+
out = out.replace(value.as_str(), &mask_value(cfg, value));
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
out
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
fn sensitive_key(cfg: &CleanConfig, key: Option<&str>) -> bool {
|
|
250
|
+
let key = match key {
|
|
251
|
+
Some(k) => k,
|
|
252
|
+
None => return false,
|
|
253
|
+
};
|
|
254
|
+
let nk = normkey(key);
|
|
255
|
+
cfg.keys.iter().any(|k| nk.contains(k.as_str()))
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
fn node_ptr(val: &Value) -> Option<usize> {
|
|
259
|
+
match val {
|
|
260
|
+
Value::List(l) => Some(Rc::as_ptr(l) as *const () as usize),
|
|
261
|
+
Value::Map(m) => Some(Rc::as_ptr(m) as *const () as usize),
|
|
262
|
+
_ => None,
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// A plain-data copy of what is about to leave: functions are dropped,
|
|
267
|
+
// cycles are cut, and no live node is shared with the copy - masking the
|
|
268
|
+
// copy must never mask the pipeline's own spec.
|
|
269
|
+
fn snapshot(cfg: &CleanConfig, val: &Value, key: Option<&str>, depth: usize, seen: &mut Vec<usize>) -> Value {
|
|
270
|
+
match val {
|
|
271
|
+
Value::Noval | Value::Null => val.clone(),
|
|
272
|
+
Value::Str(s) => {
|
|
273
|
+
if sensitive_key(cfg, key) {
|
|
274
|
+
Value::str(mask_value(cfg, s))
|
|
275
|
+
} else {
|
|
276
|
+
Value::str(clean_string(cfg, s))
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
Value::Func(_) => Value::Noval,
|
|
280
|
+
Value::Bool(_) | Value::Num(_) | Value::Sentinel(_) => {
|
|
281
|
+
if sensitive_key(cfg, key) {
|
|
282
|
+
Value::str(cfg.mask.clone())
|
|
283
|
+
} else {
|
|
284
|
+
val.clone()
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
Value::List(_) | Value::Map(_) => {
|
|
288
|
+
let ptr = node_ptr(val).unwrap_or(0);
|
|
289
|
+
if MAXDEPTH <= depth || seen.contains(&ptr) {
|
|
290
|
+
return Value::str(CIRCULAR);
|
|
291
|
+
}
|
|
292
|
+
if sensitive_key(cfg, key) {
|
|
293
|
+
return Value::str(cfg.mask.clone());
|
|
294
|
+
}
|
|
295
|
+
seen.push(ptr);
|
|
296
|
+
let out = match val {
|
|
297
|
+
Value::List(l) => {
|
|
298
|
+
let items: Vec<Value> = l
|
|
299
|
+
.borrow()
|
|
300
|
+
.iter()
|
|
301
|
+
.map(|v| snapshot(cfg, v, None, depth + 1, seen))
|
|
302
|
+
.collect();
|
|
303
|
+
Value::list(items)
|
|
304
|
+
}
|
|
305
|
+
Value::Map(m) => {
|
|
306
|
+
let out = Value::empty_map();
|
|
307
|
+
for (k, v) in m.borrow().iter() {
|
|
308
|
+
let cv = snapshot(cfg, v, Some(k), depth + 1, seen);
|
|
309
|
+
if !cv.is_noval() {
|
|
310
|
+
let name = clean_name(cfg, &out, k);
|
|
311
|
+
setp(&out, &name, cv);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
out
|
|
315
|
+
}
|
|
316
|
+
_ => Value::Noval,
|
|
317
|
+
};
|
|
318
|
+
seen.pop();
|
|
319
|
+
out
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// A registered value used as a property name is masked like any other
|
|
325
|
+
// string; names that mask alike take a counter, so none is lost.
|
|
326
|
+
fn clean_name(cfg: &CleanConfig, out: &Value, key: &str) -> String {
|
|
327
|
+
let taken = |n: &str| match out {
|
|
328
|
+
Value::Map(m) => m.borrow().get(n).is_some(),
|
|
329
|
+
_ => false,
|
|
330
|
+
};
|
|
331
|
+
let name = clean_string(cfg, key);
|
|
332
|
+
if name == key || !taken(&name) {
|
|
333
|
+
return name;
|
|
334
|
+
}
|
|
335
|
+
let mut i = 1;
|
|
336
|
+
while taken(&format!("{}#{}", name, i)) {
|
|
337
|
+
i += 1;
|
|
338
|
+
}
|
|
339
|
+
format!("{}#{}", name, i)
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
fn clean_with(cfg: &CleanConfig, val: &Value) -> Value {
|
|
343
|
+
if !cfg.active {
|
|
344
|
+
return val.clone();
|
|
345
|
+
}
|
|
346
|
+
match val {
|
|
347
|
+
Value::Str(s) => Value::str(clean_string(cfg, s)),
|
|
348
|
+
_ => snapshot(cfg, val, None, 0, &mut Vec::new()),
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/// Clean a value on its way out. A string is redacted; anything else comes
|
|
353
|
+
/// back as a masked plain-data copy. Takes the bare context so a `Debug`
|
|
354
|
+
/// impl can reach it.
|
|
355
|
+
pub fn clean_value(ctx: &Context, val: &Value) -> Value {
|
|
356
|
+
clean_with(&read_config(&config_block(ctx)), val)
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
pub fn clean_util(ctx: &Rc<Context>, val: &Value) -> Value {
|
|
360
|
+
clean_value(ctx, val)
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/// String flavour of clean.
|
|
364
|
+
pub fn clean_str(ctx: &Rc<Context>, val: &str) -> String {
|
|
365
|
+
let cfg = read_config(&config_block(ctx));
|
|
366
|
+
if !cfg.active {
|
|
367
|
+
return val.to_string();
|
|
368
|
+
}
|
|
369
|
+
clean_string(&cfg, val)
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/// Clean a value against an options map rather than a context, for a
|
|
373
|
+
/// feature that holds the options but no context.
|
|
374
|
+
pub fn clean_opts(options: &Value, val: &Value) -> Value {
|
|
375
|
+
let block = derived_block(options);
|
|
376
|
+
if !matches!(block, Value::Map(_)) {
|
|
377
|
+
return val.clone();
|
|
378
|
+
}
|
|
379
|
+
clean_with(&read_config(&block), val)
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/// Is this key name sensitive under the context's clean configuration?
|
|
383
|
+
pub fn clean_key(ctx: &Rc<Context>, key: &str) -> bool {
|
|
384
|
+
sensitive_key(&read_config(&config_block(ctx)), Some(key))
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/// An error that never passed through make_error, returned as its cleaned
|
|
388
|
+
/// self: every text field and both snapshots.
|
|
389
|
+
pub fn clean_error(ctx: &Rc<Context>, mut err: ProjectNameError) -> ProjectNameError {
|
|
390
|
+
let cfg = read_config(&config_block(ctx));
|
|
391
|
+
if cfg.active {
|
|
392
|
+
err.msg = clean_string(&cfg, &err.msg);
|
|
393
|
+
err.code = clean_string(&cfg, &err.code);
|
|
394
|
+
err.result = clean_with(&cfg, &err.result);
|
|
395
|
+
err.spec = clean_with(&cfg, &err.spec);
|
|
396
|
+
}
|
|
397
|
+
err
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/// Every scalar under a sensitive name, at any depth and of any shape, is
|
|
401
|
+
/// registered against `options`: a credential mistyped as a map or a number
|
|
402
|
+
/// is still a credential.
|
|
403
|
+
pub fn clean_add_sensitive_opts(options: &Value, val: &Value) {
|
|
404
|
+
let block = derived_block(options);
|
|
405
|
+
if !matches!(block, Value::Map(_)) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
let cfg = read_config(&block);
|
|
409
|
+
add_sensitive(&cfg, options, val, false, 0, &mut Vec::new());
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
pub fn clean_add_sensitive(ctx: &Rc<Context>, val: &Value) {
|
|
413
|
+
let options = ctx.options.borrow().clone();
|
|
414
|
+
clean_add_sensitive_opts(&options, val);
|
|
8
415
|
}
|
|
9
416
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
417
|
+
fn add_sensitive(
|
|
418
|
+
cfg: &CleanConfig,
|
|
419
|
+
options: &Value,
|
|
420
|
+
val: &Value,
|
|
421
|
+
under: bool,
|
|
422
|
+
depth: usize,
|
|
423
|
+
seen: &mut Vec<usize>,
|
|
424
|
+
) {
|
|
425
|
+
if MAXDEPTH <= depth {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
match val {
|
|
429
|
+
Value::Str(s) if under => clean_add_opts(options, s),
|
|
430
|
+
Value::Num(n) if under => clean_add_opts(options, &vs::value::num_to_string(*n)),
|
|
431
|
+
Value::List(_) | Value::Map(_) => {
|
|
432
|
+
let ptr = node_ptr(val).unwrap_or(0);
|
|
433
|
+
if seen.contains(&ptr) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
seen.push(ptr);
|
|
437
|
+
match val {
|
|
438
|
+
Value::List(l) => {
|
|
439
|
+
for v in l.borrow().iter() {
|
|
440
|
+
add_sensitive(cfg, options, v, under, depth + 1, seen);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
Value::Map(m) => {
|
|
444
|
+
for (k, v) in m.borrow().iter() {
|
|
445
|
+
let sub = under || sensitive_key(cfg, Some(k));
|
|
446
|
+
add_sensitive(cfg, options, v, sub, depth + 1, seen);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
_ => {}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
_ => {}
|
|
453
|
+
}
|
|
13
454
|
}
|