-
Notifications
You must be signed in to change notification settings - Fork 2
feat(xtest): add exp-go-sdk using experimental TDF writer #414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
93457ab
6906bcd
4241d13
a959cd5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| .PHONY: all clean | ||
|
|
||
| all: dist/main/cli.sh dist/main/exp-go-sdk | ||
|
|
||
| dist/main/exp-go-sdk: main.go go.mod go.sum | ||
| mkdir -p dist/main | ||
| go build -o dist/main/exp-go-sdk . | ||
|
|
||
| dist/main/cli.sh: cli.sh | ||
| mkdir -p dist/main | ||
| cp cli.sh dist/main/cli.sh | ||
| chmod +x dist/main/cli.sh | ||
|
|
||
| clean: | ||
| rm -rf dist |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Common shell wrapper used to interface to SDK implementation. | ||
| # | ||
| # Usage: ./cli.sh <encrypt | decrypt> <src-file> <dst-file> <fmt> | ||
| # | ||
| # Extended Utilities: | ||
| # | ||
| # ./cli.sh supports <feature> | ||
| # Check if the SDK supports a specific feature. | ||
| # | ||
| # Extended Configuration: | ||
| # XT_WITH_ECDSA_BINDING [boolean] - Use ECDSA binding for encryption | ||
| # XT_WITH_ECWRAP [boolean] - Use EC wrap for encryption/decryption | ||
| # XT_WITH_VERIFY_ASSERTIONS [boolean] - Verify assertions during decryption | ||
| # XT_WITH_ASSERTIONS [string] - Path to assertions file, or JSON encoded as string | ||
| # XT_WITH_ASSERTION_VERIFICATION_KEYS [string] - Path to assertion verification private key file | ||
| # XT_WITH_ATTRIBUTES [string] - Attributes to be used for encryption | ||
| # XT_WITH_MIME_TYPE [string] - MIME type for the encrypted file | ||
| # | ||
| SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) | ||
|
|
||
| cmd="$SCRIPT_DIR/exp-go-sdk" | ||
| if [ ! -f "$cmd" ]; then | ||
| echo "exp-go-sdk binary not found at $cmd" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "$1" == "supports" ]; then | ||
| "$cmd" supports "$2" | ||
| exit $? | ||
| fi | ||
|
|
||
| XTEST_DIR="$SCRIPT_DIR" | ||
| while [ ! -f "$XTEST_DIR/test.env" ] && [ "$(basename "$XTEST_DIR")" != "xtest" ]; do | ||
| XTEST_DIR=$(dirname "$XTEST_DIR") | ||
| done | ||
|
|
||
| if [ -f "$XTEST_DIR/test.env" ]; then | ||
| # shellcheck disable=SC1091 | ||
| source "$XTEST_DIR/test.env" | ||
| else | ||
| echo "test.env not found, stopping at xtest directory." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "$4" != "ztdf" ]; then | ||
| echo "Unsupported container format: $4" | ||
| exit 2 | ||
| fi | ||
|
|
||
| args=( | ||
| --output "$3" | ||
| --platform-endpoint "$PLATFORMURL" | ||
| --client-id "$CLIENTID" | ||
| --client-secret "$CLIENTSECRET" | ||
| ) | ||
|
|
||
| if [ "$1" == "encrypt" ]; then | ||
| if [ -n "$XT_WITH_MIME_TYPE" ]; then | ||
| args+=(--mime-type "$XT_WITH_MIME_TYPE") | ||
| fi | ||
|
|
||
| if [ -n "$XT_WITH_ATTRIBUTES" ]; then | ||
| args+=(--attributes "$XT_WITH_ATTRIBUTES") | ||
| fi | ||
|
|
||
| if [ -n "$XT_WITH_ASSERTIONS" ]; then | ||
| args+=(--assertions "$XT_WITH_ASSERTIONS") | ||
| fi | ||
|
|
||
| if [ "$XT_WITH_ECWRAP" == "true" ]; then | ||
| args+=(--ecwrap) | ||
| fi | ||
|
|
||
| echo "$cmd" encrypt "${args[@]}" "$2" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The script echoes the full command line before execution, which includes the |
||
| "$cmd" encrypt "${args[@]}" "$2" | ||
| elif [ "$1" == "decrypt" ]; then | ||
| if [ -n "$XT_WITH_ASSERTION_VERIFICATION_KEYS" ]; then | ||
| args+=(--assertion-verification-keys "$XT_WITH_ASSERTION_VERIFICATION_KEYS") | ||
| fi | ||
| if [ "$XT_WITH_VERIFY_ASSERTIONS" == 'false' ]; then | ||
| args+=(--no-verify-assertions) | ||
| fi | ||
| if [ -n "$XT_WITH_KAS_ALLOWLIST" ]; then | ||
| args+=(--kas-allowlist "$XT_WITH_KAS_ALLOWLIST") | ||
| fi | ||
| if [ "$XT_WITH_IGNORE_KAS_ALLOWLIST" == "true" ]; then | ||
| args+=(--ignore-kas-allowlist) | ||
| fi | ||
|
|
||
| echo "$cmd" decrypt "${args[@]}" "$2" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| "$cmd" decrypt "${args[@]}" "$2" | ||
| else | ||
| echo "Incorrect argument provided" | ||
| exit 1 | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| module github.com/opentdf/tests/xtest/sdk/exp-go-sdk | ||
|
|
||
| go 1.25.0 | ||
pflynn-virtru marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| require ( | ||
| github.com/opentdf/platform/protocol/go v0.15.0 | ||
| github.com/opentdf/platform/sdk v0.12.0 | ||
| ) | ||
|
|
||
| require ( | ||
| buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250603165357-b52ab10f4468.1 // indirect | ||
| connectrpc.com/connect v1.19.1 // indirect | ||
| github.com/Masterminds/semver/v3 v3.4.0 // indirect | ||
| github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect | ||
| github.com/goccy/go-json v0.10.5 // indirect | ||
| github.com/google/uuid v1.6.0 // indirect | ||
| github.com/gowebpki/jcs v1.0.1 // indirect | ||
| github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.3 // indirect | ||
| github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect | ||
| github.com/lestrrat-go/blackmagic v1.0.4 // indirect | ||
| github.com/lestrrat-go/httpcc v1.0.1 // indirect | ||
| github.com/lestrrat-go/httprc v1.0.6 // indirect | ||
| github.com/lestrrat-go/iter v1.0.2 // indirect | ||
| github.com/lestrrat-go/jwx/v2 v2.1.6 // indirect | ||
| github.com/lestrrat-go/option v1.0.1 // indirect | ||
| github.com/opentdf/platform/lib/ocrypto v0.9.0 // indirect | ||
| github.com/segmentio/asm v1.2.0 // indirect | ||
| github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect | ||
| github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect | ||
| github.com/xeipuuv/gojsonschema v1.2.0 // indirect | ||
| golang.org/x/crypto v0.45.0 // indirect | ||
| golang.org/x/net v0.47.0 // indirect | ||
| golang.org/x/oauth2 v0.34.0 // indirect | ||
| golang.org/x/sys v0.38.0 // indirect | ||
| golang.org/x/text v0.32.0 // indirect | ||
| google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8 // indirect | ||
| google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 // indirect | ||
| google.golang.org/grpc v1.77.0 // indirect | ||
| google.golang.org/protobuf v1.36.10 // indirect | ||
| ) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should skip
exp-go-sdkfor workflow calls from other repos until it is stable?