Move SSD truth cell IDs to typed Kotlin
ober
e30d1e6b5a3b88a29a7b61f17f054db340171c96
--- a/.build.yml +++ b/.build.yml @@ -5,7 +5,7 @@ packages: - make=4.4.1-r4 sources: # Build dependency: full immutable commit, mirrored in dependencies.lock.json. - - "https://git.sr.ht/~lisp/jerboa#c0e0f09a8e0082c2c2aeb08c5dfcac44dbc82bb3" + - "https://git.sr.ht/~lisp/jerboa#6fd51087d62a40f8d59ee556da023971a99792b0" # The second source is the build subject selected by the SourceHut submitter. - https://git.sr.ht/~lisp/jerboa-android tasks: @@ -14,6 +14,6 @@ tasks: test "$(apk info -v chez-scheme)" = chez-scheme-10.3.0-r2 test "$(apk info -v git)" = git-2.54.0-r0 test "$(apk info -v make)" = make-4.4.1-r4 - test "$(git -C ../jerboa rev-parse HEAD)" = c0e0f09a8e0082c2c2aeb08c5dfcac44dbc82bb3 - test "$(git -C ../jerboa rev-parse 'HEAD^{tree}')" = 2e133170b097ee5b7857677a2d087d592439296b + test "$(git -C ../jerboa rev-parse HEAD)" = 6fd51087d62a40f8d59ee556da023971a99792b0 + test "$(git -C ../jerboa rev-parse 'HEAD^{tree}')" = 832ff5f75d3f1ae470789de02f5fd7fbd357e90c JERBOA="chez --libdirs .:../jerboa/lib --script" make test --- a/dependencies.lock.json +++ b/dependencies.lock.json @@ -11,8 +11,8 @@ "generator_runtime": { "name": "jerboa", "repository": "https://git.sr.ht/~lisp/jerboa", - "commit": "c0e0f09a8e0082c2c2aeb08c5dfcac44dbc82bb3", - "tree": "2e133170b097ee5b7857677a2d087d592439296b" + "commit": "6fd51087d62a40f8d59ee556da023971a99792b0", + "tree": "832ff5f75d3f1ae470789de02f5fd7fbd357e90c" }, "assurance_tools": { "osv_scanner": { --- a/scripts/verify-supply-chain.sh +++ b/scripts/verify-supply-chain.sh @@ -3,8 +3,8 @@ set -eu repo=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd -P) lock="$repo/dependencies.lock.json" -jerboa_commit=c0e0f09a8e0082c2c2aeb08c5dfcac44dbc82bb3 # gitsafe:ignore -jerboa_tree=2e133170b097ee5b7857677a2d087d592439296b # gitsafe:ignore +jerboa_commit=6fd51087d62a40f8d59ee556da023971a99792b0 # gitsafe:ignore +jerboa_tree=832ff5f75d3f1ae470789de02f5fd7fbd357e90c # gitsafe:ignore gradle_sha=20f1b1176237254a6fc204d8434196fa11a4cfb387567519c61556e8710aed78 jdk_macos_sha=8fa1eff40bb637a33613b2ccb8b12c70dc3661cc22cf8e784943715769a05336 jdk_linux_sha=d8afc263758141a66e0e3aafc321e783f7016696f4eaea067d340a269037d331 --- a/templates/ssd-review.ss +++ b/templates/ssd-review.ss @@ -2313,6 +2313,35 @@ (json-object-put-json-object! cached "source" source) cached))))))) + (typed-kotlin-file "com/sfb/ssdreview/TruthCellIds.kt" + (typed-library (com sfb ssdreview) + (export uniqueTruthCellId) + (type Int32) + (def (truthCellIdBase (groupId : String) (originalId : String)) : String + (string-replace-regex + (string-append + "truth_" + (string-append groupId (string-append "_" originalId))) + "[^A-Za-z0-9_]" + "_")) + (def (uniqueTruthCellIdAtIndex (base : String) + (usedIds : (Set String)) + (index : Int32)) : String + (let ((candidate + (if (= index (int32 0)) + base + (string-append base (string-append "_" (int32->string index)))))) + (if (set-contains? usedIds candidate) + (uniqueTruthCellIdAtIndex base usedIds (+ index (int32 1))) + candidate))) + (def (uniqueTruthCellId (groupId : String) + (originalId : String) + (usedIds : (Set String))) : String + (uniqueTruthCellIdAtIndex + (truthCellIdBase groupId originalId) + usedIds + (int32 0))))) + (typed-kotlin-file "com/sfb/ssdreview/PathSafety.kt" (typed-library (com sfb ssdreview) (export safePathComponent safeLeaf safeZipEntryName validSourceKey validatedSourceKey) @@ -5607,17 +5636,6 @@ " group.cellIds.addAll(remappedIds)" " }" "" - " private fun uniqueTruthCellId(groupId: String, originalId: String, usedIds: Set<String>): String {" - " val base = \"truth_${groupId}_${originalId}\".replace(Regex(\"\"\"[^A-Za-z0-9_]\"\"\"), \"_\")" - " var candidate = base" - " var index = 1" - " while (usedIds.contains(candidate)) {" - " candidate = \"${base}_$index\"" - " index += 1" - " }" - " return candidate" - " }" - "" " private fun writeRemoteTruth(" " truth: JSONObject," " modified: Long,"