From 076b0a624bf00acdb137052e48a3ed315cac9796 Mon Sep 17 00:00:00 2001 From: Michiel Hazelhof Date: Tue, 15 Jul 2025 11:00:09 +0200 Subject: [PATCH] Upstream patches (#240) --- build.ps1 | 5 ++++- build.sh | 3 ++- generateKeys.ps1 | 3 +++ generateKeys.sh | 1 + licenseGen.ps1 | 3 +++ licenseGen.sh | 1 + src/bitBetter/Program.cs | 2 +- src/licenseGen/Dockerfile | 2 +- src/licenseGen/Program.cs | 8 +++++--- 9 files changed, 21 insertions(+), 7 deletions(-) diff --git a/build.ps1 b/build.ps1 index 54f6f6b..f3d79fc 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,3 +1,6 @@ +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $true + # define temporary directory $tempdirectory = "$pwd\temp" # define services to patch @@ -30,7 +33,7 @@ Copy-Item "$pwd\.keys\cert.cert" -Destination "$pwd\src\bitBetter" Copy-Item "$pwd\.keys\cert.pfx" -Destination "$pwd\src\licenseGen" # build bitBetter and clean the source directory after -docker build -t bitbetter/bitbetter "$pwd\src\bitBetter" +docker build --no-cache -t bitbetter/bitbetter "$pwd\src\bitBetter" Remove-Item "$pwd\src\bitBetter\cert.cert" -Force # gather all running instances diff --git a/build.sh b/build.sh index 97b544d..468e22c 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e # define temporary directory TEMPDIRECTORY="$PWD/temp" @@ -33,7 +34,7 @@ cp -f "$PWD/.keys/cert.cert" "$PWD/src/bitBetter" cp -f "$PWD/.keys/cert.pfx" "$PWD/src/licenseGen" # build bitBetter and clean the source directory after -docker build -t bitbetter/bitbetter "$PWD/src/bitBetter" +docker build --no-cache -t bitbetter/bitbetter "$PWD/src/bitBetter" rm -f "$PWD/src/bitBetter/cert.cert" # gather all running instances diff --git a/generateKeys.ps1 b/generateKeys.ps1 index 690143f..d20aa14 100644 --- a/generateKeys.ps1 +++ b/generateKeys.ps1 @@ -1,3 +1,6 @@ +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $true + # get the basic openssl binary path $opensslbinary = "$Env:Programfiles\OpenSSL-Win64\bin\openssl.exe" diff --git a/generateKeys.sh b/generateKeys.sh index 4850fc2..d561aee 100755 --- a/generateKeys.sh +++ b/generateKeys.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e # Check for openssl command -v openssl >/dev/null 2>&1 || { echo >&2 "openssl required but not found. Aborting."; exit 1; } diff --git a/licenseGen.ps1 b/licenseGen.ps1 index 3907946..36815d6 100644 --- a/licenseGen.ps1 +++ b/licenseGen.ps1 @@ -1,3 +1,6 @@ +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $true + if ($($args.Count) -lt 1) { echo "USAGE: [License Gen args...]" echo "ACTIONS:" diff --git a/licenseGen.sh b/licenseGen.sh index 29c9e62..3d93aa4 100755 --- a/licenseGen.sh +++ b/licenseGen.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e if [ $# -lt 1 ]; then echo "USAGE: [License Gen args...]" diff --git a/src/bitBetter/Program.cs b/src/bitBetter/Program.cs index e28030a..2d1ed78 100644 --- a/src/bitBetter/Program.cs +++ b/src/bitBetter/Program.cs @@ -29,7 +29,7 @@ internal class Program Console.WriteLine(embeddedResourceToRemove.Name); - EmbeddedResource embeddedResourceToAdd = new("Bit.Core.licensing.cer", cert) {Attributes = embeddedResourceToRemove.Attributes }; + EmbeddedResource embeddedResourceToAdd = new("Bit.Core.licensing.cer", cert) { Attributes = embeddedResourceToRemove.Attributes }; moduleDefMd.Resources.Add(embeddedResourceToAdd); moduleDefMd.Resources.Remove(embeddedResourceToRemove); diff --git a/src/licenseGen/Dockerfile b/src/licenseGen/Dockerfile index b552cca..b5aa0fb 100644 --- a/src/licenseGen/Dockerfile +++ b/src/licenseGen/Dockerfile @@ -12,4 +12,4 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0 WORKDIR /app COPY --from=build /app . -ENTRYPOINT [ "dotnet", "/app/licenseGen.dll", "--core", "/app/Core.dll", "--cert", "/app/cert.pfx" ] +ENTRYPOINT [ "dotnet", "/app/licenseGen.dll", "--core", "/app/Core.dll", "--executable", "/app/Api", "--cert", "/app/cert.pfx" ] \ No newline at end of file diff --git a/src/licenseGen/Program.cs b/src/licenseGen/Program.cs index 160463f..581789f 100644 --- a/src/licenseGen/Program.cs +++ b/src/licenseGen/Program.cs @@ -377,7 +377,6 @@ internal class Program Set("Expires", DateTime.UtcNow.AddYears(100)); Set("Trial", false); Set("LicenseType", Enum.Parse(licenseTypeEnum, "User")); - Set("Hash", Convert.ToBase64String((Byte[])type.GetMethod("ComputeHash").Invoke(license, []))); Set("Signature", Convert.ToBase64String((Byte[])type.GetMethod("Sign").Invoke(license, [cert]))); @@ -437,8 +436,11 @@ internal class Program Set("Trial", false); Set("LicenseType", Enum.Parse(licenseTypeEnum, "Organization")); Set("LimitCollectionCreationDeletion", true); //This will be used in the new version of BitWarden but can be applied now - Set("AllowAdminAccessToAllCollectionItems", true); - Set("UseRiskInsights", true); + Set("AllowAdminAccessToAllCollectionItems", true); + Set("UseRiskInsights", true); + Set("UseOrganizationDomains", true); + Set("UseAdminSponsoredFamilies", true); + Set("UseRiskInsights", true); Set("UseOrganizationDomains", true); Set("UseAdminSponsoredFamilies", true); Set("Hash", Convert.ToBase64String((Byte[])type.GetMethod("ComputeHash").Invoke(license, [])));