From 8131f5c58c4cb213565e76e8347681729acd5824 Mon Sep 17 00:00:00 2001 From: Kevin Burgmann Date: Tue, 30 May 2023 13:21:25 +0200 Subject: [PATCH 1/4] Increase file system hkv key size --- src/main/kotlin/id/walt/services/hkvstore/FileSystemHKVStore.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/id/walt/services/hkvstore/FileSystemHKVStore.kt b/src/main/kotlin/id/walt/services/hkvstore/FileSystemHKVStore.kt index 1c33447a3..f8498a282 100644 --- a/src/main/kotlin/id/walt/services/hkvstore/FileSystemHKVStore.kt +++ b/src/main/kotlin/id/walt/services/hkvstore/FileSystemHKVStore.kt @@ -123,7 +123,7 @@ class FileSystemHKVStore(configPath: String) : HKVStoreService() { private fun dataDirCombinePath(key: Path) = configuration.dataDirectory.combineSafe(key) companion object { - private const val MAX_KEY_SIZE = 100 + private const val MAX_KEY_SIZE = 111 private const val hashMappingDesc = "FileSystemHKVStore hash mappings properties" } } From 5f329dc43f74d9e3d425562e82b186f1ed1815fb Mon Sep 17 00:00:00 2001 From: Kevin Burgmann Date: Tue, 30 May 2023 13:21:33 +0200 Subject: [PATCH 2/4] Added CHEQD test case --- .../kotlin/id/walt/ecosystems/CheqdTest.kt | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/test/kotlin/id/walt/ecosystems/CheqdTest.kt diff --git a/src/test/kotlin/id/walt/ecosystems/CheqdTest.kt b/src/test/kotlin/id/walt/ecosystems/CheqdTest.kt new file mode 100644 index 000000000..56823e4e7 --- /dev/null +++ b/src/test/kotlin/id/walt/ecosystems/CheqdTest.kt @@ -0,0 +1,61 @@ +package id.walt.ecosystems + +import com.google.common.util.concurrent.ServiceManager +import id.walt.auditor.Auditor +import id.walt.auditor.policies.SignaturePolicy +import id.walt.credentials.w3c.W3CIssuer +import id.walt.model.DidMethod +import id.walt.servicematrix.ServiceMatrix +import id.walt.services.did.DidService +import id.walt.services.keystore.KeyStoreService +import id.walt.signatory.ProofConfig +import id.walt.signatory.Signatory +import io.kotest.core.spec.style.StringSpec +import io.kotest.matchers.shouldBe + +class CheqdTest : StringSpec({ + + ServiceMatrix("service-matrix.properties") + + var did: String? = null + + "Generating fresh did:cheqd" { + println("Generating did:cheqd...") + did = DidService.create(DidMethod.cheqd) + println("Created did: $did") + } + + var vc: String? = null + + "Create VC with did:cheqd" { + vc = Signatory.getService().issue("VerifiableId", ProofConfig(did!!, did!!), issuer = W3CIssuer(did!!)) + println("Generated VC: $vc") + } + + "Remove did:cheqd from keystore" { + KeyStoreService.getService().delete(did!!) + println("Deleted: $did") + } + + /*"Import did:cheqd" { + println("Importing: $did") + DidService.importDidAndKeys(did!!) + }*/ + + "Test did:cheqd verification" { + val verificationResult = Auditor.getService().verify(vc!!, listOf(SignaturePolicy())) + + verificationResult.policyResults.entries.forEach { + if (it.value.isFailure) { + println("ERROR at ${it.key}") + it.value.errors.forEachIndexed { index, throwable -> + println("Error #$index: ${throwable.message}") + throwable.printStackTrace() + } + } else println("OK: ${it.key}") + } + verificationResult.result shouldBe true + + } + +}) From f18c334bcb9badb896bd489d4fa9596d6e0d65ee Mon Sep 17 00:00:00 2001 From: Kevin Burgmann Date: Thu, 1 Jun 2023 17:16:14 +0200 Subject: [PATCH 3/4] feat: make maxKeySize configurable --- .github/workflows/build.yml | 45 +++++++++++-------- .github/workflows/release.yml | 21 ++++++--- config/fsStore.conf | 1 + .../services/hkvstore/FileSystemHKVStore.kt | 10 ++--- 4 files changed, 46 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1ab62ae03..e0e643775 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,6 @@ on: - '**' - '!main' - jobs: build: name: "Build" @@ -28,7 +27,7 @@ jobs: uses: actions/setup-java@v2.1.0 with: distribution: 'adopt-hotspot' - java-version: '16' + java-version: '17' - name: Setup cache uses: actions/cache@v2 with: @@ -46,20 +45,28 @@ jobs: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} with: - arguments: build --no-daemon -# arguments: build publish --no-daemon -# - name: Docker Build and Push SNAPSHOT -# uses: philpotisk/github-action-docker-build-push@master -# env: -# DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}} -# DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} -# DOCKER_FILE: Dockerfile -# CONTAINER_TAG: waltid/ssikit:latest -# - name: Prepare CD K8S -# run: sed "s/_DEFAULT_DEPLOYMENT_/$GITHUB_SHA/g" k8s/deployment-dev.yaml > k8s/deployment-dev_mod.yaml -# - name: Continuous deployment K8S -# uses: actions-hub/kubectl@master -# env: -# KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} -# with: -# args: apply -n dev -f k8s/deployment-dev_mod.yaml + arguments: build publish --no-daemon + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{secrets.DOCKER_USERNAME}} + password: ${{secrets.DOCKER_PASSWORD}} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + push: true + tags: waltid/ssikit:${{ env.release_version }} + + - name: Prepare CD K8S + run: sed "s/_DEFAULT_DEPLOYMENT_/$GITHUB_SHA/g" k8s/deployment-dev.yaml > k8s/deployment-dev_mod.yaml + - name: Continuous deployment K8S + uses: actions-hub/kubectl@master + env: + KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} + with: + args: apply -n dev -f k8s/deployment-dev_mod.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b957bf42e..430dd086d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,13 +38,20 @@ jobs: MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} with: arguments: build publish --no-daemon - - name: Docker build and push - uses: philpotisk/github-action-docker-build-push@master - env: - DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}} - DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} - DOCKER_FILE: Dockerfile - CONTAINER_TAG: waltid/ssikit:latest + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{secrets.DOCKER_USERNAME}} + password: ${{secrets.DOCKER_PASSWORD}} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + push: true + tags: waltid/ssikit:latest - name: Changelog uses: ardalanamini/auto-changelog@v3 id: changelog diff --git a/config/fsStore.conf b/config/fsStore.conf index ccbc15f35..43bffc0dc 100644 --- a/config/fsStore.conf +++ b/config/fsStore.conf @@ -1 +1,2 @@ dataRoot: "./data" +maxKeySize = 111 diff --git a/src/main/kotlin/id/walt/services/hkvstore/FileSystemHKVStore.kt b/src/main/kotlin/id/walt/services/hkvstore/FileSystemHKVStore.kt index f8498a282..b84b52517 100644 --- a/src/main/kotlin/id/walt/services/hkvstore/FileSystemHKVStore.kt +++ b/src/main/kotlin/id/walt/services/hkvstore/FileSystemHKVStore.kt @@ -11,7 +11,8 @@ import java.util.* import kotlin.io.path.* data class FilesystemStoreConfig( - val dataRoot: String + val dataRoot: String, + val maxKeySize: Int = 111 ) : ServiceConfiguration { val dataDirectory: Path = Path.of(dataRoot) } @@ -53,7 +54,7 @@ class FileSystemHKVStore(configPath: String) : HKVStoreService() { ?: throw IllegalArgumentException("No HKVS mapping found for hash: $hashMapping") private fun hashIfNeeded(path: Path): File { - if (path.name.length > MAX_KEY_SIZE) { + if (path.name.length > configuration.maxKeySize) { val hashedFileNameBytes = DigestUtils.sha3_512(path.nameWithoutExtension) val hashedFileName = Base32().encodeToString(hashedFileNameBytes).replace("=", "").replace("+", "") @@ -92,7 +93,7 @@ class FileSystemHKVStore(configPath: String) : HKVStoreService() { when (recursive) { false -> pathFileList?.filter { it.isFile }?.map { var mapping = it.toPath() - if (mapping.name.length > MAX_KEY_SIZE) { + if (mapping.name.length > configuration.maxKeySize) { mapping = mapping.parent.resolve(retrieveHashMapping(mapping.name)) } @@ -101,7 +102,7 @@ class FileSystemHKVStore(configPath: String) : HKVStoreService() { true -> pathFileList?.flatMap { var mapping = it.toPath() - if (mapping.name.length > MAX_KEY_SIZE) { + if (mapping.name.length > configuration.maxKeySize) { mapping = mapping.parent.resolve(retrieveHashMapping(mapping.name)) } @@ -123,7 +124,6 @@ class FileSystemHKVStore(configPath: String) : HKVStoreService() { private fun dataDirCombinePath(key: Path) = configuration.dataDirectory.combineSafe(key) companion object { - private const val MAX_KEY_SIZE = 111 private const val hashMappingDesc = "FileSystemHKVStore hash mappings properties" } } From 2833544d0e9af5c00e22d60dd07e7a7cbca930bd Mon Sep 17 00:00:00 2001 From: Kevin Burgmann Date: Thu, 1 Jun 2023 17:23:54 +0200 Subject: [PATCH 4/4] ci: update CI --- .github/workflows/build.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e0e643775..dc1c7fb3f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,15 +14,15 @@ jobs: runs-on: "ubuntu-latest" steps: - uses: actions/checkout@v3 -# - name: Calculate release version -# run: | -# echo "release_version=1.$(date +'%g%m%d%H%M').$(echo ${{ github.ref_name }} | tr / -)" >> $GITHUB_ENV -# - name: Set version -# run: | -# sed -i "s/1.SNAPSHOT/${{ env.release_version }}/g" build.gradle.kts src/main/kotlin/id/walt/Values.kt -# - run: | -# git tag v${{ env.release_version }} -# git push --tags + - name: Calculate release version + run: | + echo "release_version=1.$(date +'%g%m%d%H%M').$(echo ${{ github.ref_name }} | tr / -)" >> $GITHUB_ENV + - name: Set version + run: | + sed -i "s/1.SNAPSHOT/${{ env.release_version }}/g" build.gradle.kts src/main/kotlin/id/walt/Values.kt + - run: | + git tag v${{ env.release_version }} + git push --tags - name: Setup java uses: actions/setup-java@v2.1.0 with: