diff --git a/.gitignore b/.gitignore index f5b4317..c8a664a 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ apis.json avd/ .cxx/ .transforms/ +initial-config.* diff --git a/app/android/kotlin/ShipFast/app/src/certificate_pinning/res/xml/network_security_config.xml b/app/android/kotlin/ShipFast/app/src/certificate_pinning/res/xml/network_security_config.xml new file mode 100644 index 0000000..1f8de14 --- /dev/null +++ b/app/android/kotlin/ShipFast/app/src/certificate_pinning/res/xml/network_security_config.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + shipfast.demo.approov.io + + + + NHnhk73iktV22yFicZC844iGk+LH5X3yRrC6ZTZJ80w= + + + + + + + + + + + + + diff --git a/app/android/kotlin/ShipFast/app/src/main/AndroidManifest.xml b/app/android/kotlin/ShipFast/app/src/main/AndroidManifest.xml index ad78950..42d8231 100644 --- a/app/android/kotlin/ShipFast/app/src/main/AndroidManifest.xml +++ b/app/android/kotlin/ShipFast/app/src/main/AndroidManifest.xml @@ -9,6 +9,7 @@ ?> = Approov.getPins("public-key-sha256") as Map?> + for ((key, value) in pins) { + for (pin in value!!) pinBuilder = pinBuilder.add(key!!, "sha256/$pin") } // remove any existing ApproovTokenInterceptor from the builder diff --git a/app/android/kotlin/ShipFast/app/src/main/res/xml/network_security_config.xml b/app/android/kotlin/ShipFast/app/src/main/res/xml/network_security_config.xml index 543c96e..03d3940 100644 --- a/app/android/kotlin/ShipFast/app/src/main/res/xml/network_security_config.xml +++ b/app/android/kotlin/ShipFast/app/src/main/res/xml/network_security_config.xml @@ -2,19 +2,18 @@ + - - - - - - + + + + + - shipfast.demo.approov.io - - NHnhk73iktV22yFicZC844iGk+LH5X3yRrC6ZTZJ80w= - - - - + + + + + + diff --git a/bin/java-shell.sh b/bin/java-shell.sh index 9d3b833..069e70b 100755 --- a/bin/java-shell.sh +++ b/bin/java-shell.sh @@ -51,6 +51,19 @@ unpack Unpacks the APK to readable code " } +Trim() { + local string="${1? Missing string to trim!}" + local remove="${2:-" "}" + + # Left trim + local string="${string#"${string%%[!${remove}]*}"}" + + # Right trim + local string="${string%"${string##*[!${remove}]}"}" + + echo -n "${string}" +} + Apk_Repackage() { Docker_Run "./app/android/kotlin/ShipFast/bin/repackage-apk.sh app/android/kotlin/ShipFast" } @@ -60,9 +73,15 @@ Apk_Unpack() { } Adb_Install() { - local USB_DEVICE_PATH=$(lsusb | grep -i "${device_brand}" - | awk '{print "/dev/bus/usb/" $2 "/" $4}') + local USB_DEVICE_PATH="$(lsusb | grep -i "${device_brand}" - | head -1 | awk '{print "/dev/bus/usb/" $2 "/" $4}')" + local USB_DEVICE_PATH="$(Trim "${USB_DEVICE_PATH}")" local RUN_MODE="--privileged" + if [ -z "${USB_DEVICE_PATH}" ]; then + printf "\nERROR: Unable to find any device named with brand '${device_brand}'\n\n" + return 1 + fi + local _apk_dir="app/android/kotlin/ShipFast/app/build/outputs/apk/${product_flavour}/release/app-${product_flavour}-release.apk" Docker_Run "adb install -r ${_apk_dir}"