commit e4bfba6c5537cde45477de3d54d4f5236c3fe5f6
parent ae65a612878337c7622e307aca9b14226deabd15
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Thu, 12 Nov 2026 21:07:30 +0530
parent ae65a612878337c7622e307aca9b14226deabd15
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Thu, 12 Nov 2026 21:07:30 +0530
Read frozen image formats from bytes, not filenames Opaque asset-N snapshots broke otherwise valid JPEG imprints. Select the existing decoder by signature and retain same-byte unit and frozen-input regressions. Request colour/alpha interpolation to match browser upscaling, verified on both pages through release.
13 files changed, 153 insertions(+), 20 deletions(-)
diff --git a/.gitattributes b/.gitattributes @@ -1,4 +1,6 @@ # Keep generated fixtures and font assets byte-identical on every checkout. *.png -text +*.jpg -text +*.jpeg -text *.pdf -text *.ttf -text
diff --git a/.scratch/roadmap/ticket-12.md b/.scratch/roadmap/ticket-12.md @@ -89,6 +89,15 @@ Source/image verification is recorded in /tmp/signet-roadmap-build-final.log and built from original68ed63b schema. No shared or production DB was changed. - Node/shell syntax and git diff --check pass. +## Follow-up image regression + +Ticket14 resource review found the PDF writer was using suffixes to choose JPEG, +which fails for private asset-N snapshots. Header-based format detection restores +RGB JPEG support without changing snapshot names. A synthetic JPEG now covers +unit, live-input deletion, extracted-byte preservation and both-page browser/ +visual checks; image interpolation was aligned with browser upscaling. See +`.scratch/roadmap/ticket-14.md` for the newer evidence and remaining native gates. + ## Resource evidence and remaining gates /tmp/signet-ticket12-rss-samples.log samples the isolated app UID processes
diff --git a/.scratch/roadmap/ticket-14.md b/.scratch/roadmap/ticket-14.md @@ -86,6 +86,44 @@ Latest image/container signet-command-final on :8086: exclusions, rounding/sampling and non-certification limits as above. - Image ID: /tmp/signet-ticket14-command-image.txt. No production services touched. +### Opaque JPEG snapshot regression repaired + +Resource-path review found that pdfw selected JPEG by filename suffix, while +snapshots deliberately name files asset-N. A controlled same-byte test succeeds +with image.jpg and fails with an opaque name before the fix (red assertion in +/tmp/signet-ticket14-jpeg-red.log). get_image now checks the byte signature; +PNG and JPEG decoding remain the existing implementations. No filename format +leaks into the snapshot model and no new dependency is introduced. + +The new synthetic4x2 RGB JPEG is reproducible from make-fixtures.py using a fixed +encoded swatch, without an encoder dependency. Image-contract tests exercise +named/opaque JPEG and misleading-suffix PNG, PDF validity and interpolation flags. +Snapshot-contract now removes the live JPEG before rendering/retry, extracts the +JPEG from the proof with pdfimages and compares exact bytes to the fixture; +correction/release/damaged-input/replay cases also include it. + +The mandatory visual comparison caught nearest-neighbour blocks on the enlarged +swatch versus the browser's smooth image. Colour and alpha XObjects now request +/Interpolate true. Both-page edit/proof/stamped/final plus audit were inspected +again: fitting and image upscaling agree (preview markers intentionally tint the +copy), correct facsimiles persist, and the audit is readable. No text-fitting +algorithm changed. RGB fixture coverage is not certification of every JPEG +colour space, progressive variant or unusual PDF. + +Fresh image signet-jpeg-final, container signet-jpeg-loopback bound to +127.0.0.1:18087: clean build with no warnings, +full E2E (image+command+identity+snapshot), render/hang/replay and both browser +suites pass. Logs /tmp/signet-ticket14-jpeg-{unit,build,e2e,render,browser,progress}.log, +image ID /tmp/signet-ticket14-jpeg-image.txt; visuals +/tmp/signet-ticket14-jpeg-browser/. Fixture sampling observed approximately +30,204KB aggregate app RSS across1,306samples, with the same exclusions and +sampling/rounding/non-native/non-concurrency limits above. This does not close +any native deployment gate. No production/shared-service changes were made. +An IPv4/IPv6 overlap with an existing local service was detected on the earlier +:8087 mapping; only our Signet test stacks were stopped, the unrelated service +was untouched. Full suites/browser were rerun on the checked-free loopback port. +Older stacks are retained stopped; ticket11 :8080 remains running as requested. + ## Unfinished technical acceptance (must not be checked off) - Real trusted-header overwrite/spoof prevention, missing identity, authenticated
diff --git a/HANDOFF.md b/HANDOFF.md @@ -59,7 +59,7 @@ verification below remains mandatory. **Not verified / never run:** OpenRC scripts, `etc/lighttpd-signet.conf` (production config incl. WebDAV + CSP), real Authelia in front, `make install` -on a real host, JPEG embedding, TTF fonts other than DejaVuSans, rotated or +on a real host, JPEG variants beyond the RGB fixture, TTF fonts other than DejaVuSans, rotated or CropBox-offset source PDFs, template with different page counts, concurrent submits on one series. @@ -315,6 +315,9 @@ The implementation scopes and acceptance criteria are in other parse paths, decoded assets and aggregate/service-level resources remain unbounded by those guards and require further work. Owner inputs, remaining work and evidence: `.scratch/roadmap/ticket-14.md`. + Image-reader review also repaired opaque JPEG snapshots and matched image + interpolation to the browser; RGB byte-preservation and both-page visual + regressions pass. See the same ticket14 evidence, not a native certificate. Keep provider-specific auth experiments separate from application work. 6. Later: font-list validation and document-list pagination/search. @@ -323,8 +326,10 @@ historical completed tickets do not substitute for fresh evidence. ## 8. Dev environment facts -* Latest isolated verification: image/container `signet-command-final` on :8086; - metadata-guard stack on :8084, ticket12 on :8082, ticket11 on :8080. +* Latest isolated verification: image `signet-jpeg-final`, container + `signet-jpeg-loopback` at `http://127.0.0.1:18087`. Earlier :8087 conflicted + across IPv4/IPv6 with another local service; that service was not touched. + Our older test stacks are retained stopped, except preserved ticket11 :8080. Throw-away DBs and explicit identities; no production/maa-1 services changed. Fixture RSS samples do not certify native peak resource safety. * Podman machine `podman-machine-default` (2 CPU / 2 GB / 20 GB) was created
diff --git a/src/pdfw.c b/src/pdfw.c @@ -2,7 +2,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <strings.h> #include <png.h> #include <zlib.h> @@ -13,7 +12,7 @@ #define MAX_FONTS 8 #define MAX_IMAGES 64 -#define MAX_PIXELS (4u * 1024 * 1024) /* keeps the worker inside its RSS budget */ +#define MAX_PIXELS (4u * 1024 * 1024) /* Per PNG, not an aggregate RSS bound. */ enum { OBJ_CATALOG = 1, OBJ_PAGES, OBJ_RESOURCES, OBJ_HELVETICA, OBJ_FIRST_FREE }; @@ -281,6 +280,7 @@ pdfw_text(pdfw *p, int font, double size, double x, double y, const char *s) } /* --- images ---------------------------------------------------------------- */ +/* Interpolate colour and alpha streams, matching browser image upscaling. */ static int jpeg_info(const unsigned char *d, size_t len, int *w, int *h, int *ncomp) @@ -330,7 +330,7 @@ embed_jpeg(pdfw *p, struct pimage *im, const char *path) im->w > 0 && im->h > 0) { snprintf(dict, sizeof(dict), "/Type /XObject /Subtype /Image " "/Width %d /Height %d /BitsPerComponent 8 /ColorSpace %s " - "/Filter /DCTDecode%s", im->w, im->h, + "/Interpolate true /Filter /DCTDecode%s", im->w, im->h, nc == 1 ? "/DeviceGray" : nc == 4 ? "/DeviceCMYK" : "/DeviceRGB", nc == 4 ? " /Decode [1 0 1 0 1 0 1 0]" : ""); im->obj = new_obj(p); @@ -386,7 +386,8 @@ embed_png(pdfw *p, struct pimage *im, const char *path) goto out; snprintf(dict, sizeof(dict), "/Type /XObject /Subtype /Image " "/Width %d /Height %d /BitsPerComponent 8 " - "/ColorSpace /DeviceGray /Filter /FlateDecode", im->w, im->h); + "/ColorSpace /DeviceGray /Interpolate true /Filter /FlateDecode", + im->w, im->h); smask = new_obj(p); stream_obj(p, smask, dict, z, zlen); free(z); @@ -398,7 +399,8 @@ embed_png(pdfw *p, struct pimage *im, const char *path) goto out; i = (size_t)snprintf(dict, sizeof(dict), "/Type /XObject /Subtype /Image " "/Width %d /Height %d /BitsPerComponent 8 " - "/ColorSpace /DeviceRGB /Filter /FlateDecode", im->w, im->h); + "/ColorSpace /DeviceRGB /Interpolate true /Filter /FlateDecode", + im->w, im->h); if (smask) snprintf(dict + i, sizeof(dict) - i, " /SMask %d 0 R", smask); im->obj = new_obj(p); @@ -415,7 +417,8 @@ static struct pimage * get_image(pdfw *p, const char *path) { struct pimage *im; - const char *ext; + FILE *f; + unsigned char magic[2]; int i, rc; for (i = 0; i < p->nimages; i++) @@ -425,8 +428,14 @@ get_image(pdfw *p, const char *path) return NULL; im = &p->images[p->nimages]; memset(im, 0, sizeof(*im)); - ext = strrchr(path, '.'); - if (ext != NULL && (strcasecmp(ext, ".jpg") == 0 || strcasecmp(ext, ".jpeg") == 0)) + /* Frozen assets have opaque names; format belongs to the bytes, not the path. */ + if ((f = fopen(path, "rb")) == NULL) + return NULL; + rc = fread(magic, 1, sizeof(magic), f) == sizeof(magic); + fclose(f); + if (!rc) + return NULL; + if (magic[0] == 0xFF && magic[1] == 0xD8) rc = embed_jpeg(p, im, path); else rc = embed_png(p, im, path);
diff --git a/test/dev-up.sh b/test/dev-up.sh @@ -28,6 +28,7 @@ fi mkdir -p /var/lib/signet/sig-inbox cp /usr/share/fonts/dejavu/DejaVuSans.ttf /var/www/dam/fonts/ cp /src/test/fixtures/seal.png /var/www/dam/seals/agency_seal.png +cp /src/test/fixtures/image.jpg /var/www/dam/seals/agency_image.jpg cp /src/test/fixtures/sig.png /var/lib/signatures/ceo.png cp /src/test/fixtures/sig.png /var/lib/signatures/manager.png chown -R signet:signet /var/lib/signet && chmod 2770 /var/lib/signet
diff --git a/test/e2e.sh b/test/e2e.sh @@ -1,6 +1,9 @@ #!/bin/sh # API/worker acceptance against an isolated dev container (run as root). set -eu +if [ "${1-}" = image-contract ]; then + exec sh /src/test/image-contract.sh +fi if [ "${1-}" = command-contract ]; then exec sh /src/test/command-contract.sh fi @@ -14,6 +17,7 @@ if [ "${1-}" = identity-contract ]; then exec sh /src/test/identity-contract.sh fi sh /src/test/command-contract.sh +sh /src/test/image-contract.sh sh /src/test/identity-contract.sh B=http://localhost:8080 curl -fsS "$B/pim/pim.js" >/dev/null # Clean installs must include the PIM client.
diff --git a/test/fixtures/image.jpg b/test/fixtures/image.jpg Binary files differ.
diff --git a/test/image-contract.c b/test/image-contract.c @@ -0,0 +1,33 @@ +#include <assert.h> +#include <stdio.h> + +#include "pdfw.h" +#include "util.h" + +int +main(int argc, char **argv) +{ + pdfw *p; + int w, h; + char opaque[1024], output[1024]; + + assert(argc == 4); + snprintf(opaque, sizeof(opaque), "%s/asset-0", argv[3]); + snprintf(output, sizeof(output), "%s/image.pdf", argv[3]); + assert((p = pdfw_open(output)) != NULL); + assert(pdfw_page(p, 595.28, 841.89) == 0); + assert(pdfw_image_size(p, argv[1], &w, &h) == 0 && w == 4 && h == 2); + assert(copy_file(argv[1], opaque) == 0); + assert(pdfw_image_size(p, opaque, &w, &h) == 0 && + "extensionless frozen JPEG must retain its format"); + assert(w == 4 && h == 2); + assert(pdfw_image(p, opaque, 50, 600, 200, 100) == 0); + /* Same path deliberately has a misleading JPEG suffix for the PNG case. */ + snprintf(opaque, sizeof(opaque), "%s/asset-1.jpg", argv[3]); + assert(copy_file(argv[2], opaque) == 0); + assert(pdfw_image_size(p, opaque, &w, &h) == 0 && w == 200 && h == 200); + assert(pdfw_image(p, opaque, 50, 300, 200, 200) == 0); + assert(pdfw_close(p) == 0); + puts("image content contract: all passed"); + return 0; +}
diff --git a/test/image-contract.sh b/test/image-contract.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# Native image writer regression; source/fixtures are synthetic, services unused. +set -eu +ulimit -c 0 +cd "$(dirname "$0")/.." +TMP=$(mktemp -d /tmp/signet-image.XXXXXX) +trap 'rm -rf "$TMP"' EXIT +${CC:-cc} -O2 -std=c99 -Ivendor -c vendor/sha256.c -o "$TMP/sha256.o" +${CC:-cc} -O2 -std=c99 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -Wall -Wextra \ + -Isrc -Ivendor test/image-contract.c src/pdfw.c src/ttf.c src/util.c \ + "$TMP/sha256.o" -lpng -lz -lm -o "$TMP/image-contract" +"$TMP/image-contract" test/fixtures/image.jpg test/fixtures/seal.png "$TMP" +qpdf --check "$TMP/image.pdf" >/dev/null +qpdf --json "$TMP/image.pdf" | jq -e '[.. | objects | select(.["/Subtype"]? == "/Image") | .["/Interpolate"]] | length > 0 and all(. == true)' >/dev/null
diff --git a/test/make-fixtures.py b/test/make-fixtures.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -"""Regenerate test/fixtures (dev machine only; synthetic seal, signature, 2-page A4 letter).""" -import math, os, struct, zlib +"""Regenerate synthetic fixtures: seal, facsimile, RGB JPEG and two-page A4 letter (dev only).""" +import base64, math, os, struct, zlib OUT = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'fixtures') os.makedirs(OUT, exist_ok=True) @@ -25,6 +25,12 @@ def sig(x, y): png('seal.png', 200, 200, seal) png('sig.png', 300, 80, sig) +# Fixed JPEG encoding of a synthetic 4x2 blue/grey RGB swatch (no encoder dependency). +with open(os.path.join(OUT, 'image.jpg'), 'wb') as f: + f.write(base64.b64decode(''' +/9j/4AAQSkZJRgABAQAASABIAAD/4QBMRXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAABKADAAQAAAABAAAAAgAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgAAgAEAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMAAgICAgICAwICAwUDAwMFBgUFBQUGCAYGBgYGCAoICAgICAgKCgoKCgoKCgwMDAwMDA4ODg4ODw8PDw8PDw8PD//bAEMBAgICBAQEBwQEBxALCQsQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEP/dAAQAAf/aAAwDAQACEQMRAD8A/Qv9hf8A5NY8E/8AcS/9ONzX1rXyV+wv/wAmseCf+4l/6cbmvrWvd4o/5GeK/wCvk/8A0pnDln+7Uv8ACvyP/9k= +''')) + text = lambda t: f"BT /F1 18 Tf 72 770 Td ({t}) Tj ET" c1, c2 = text("Signet test letter - page 1"), text("Page 2 - signatures") page = "<< /Type /Page /Parent 2 0 R /MediaBox [0 0 595.28 841.89] /Resources << /Font << /F1 7 0 R >> >> /Contents %d 0 R >>"
diff --git a/test/signing-flow.mjs b/test/signing-flow.mjs @@ -17,7 +17,7 @@ try { await context.setExtraHTTPHeaders({ 'Remote-User': user, 'Remote-Groups': groups, 'X-Requested-With': 'signet' }); } await identity('root', 'signet-admins'); - for (const [key, type, value] of [['gstin', 'text', '33AAAAA0000A1Z5'], ['seal', 'image', 'seals/agency_seal.png']]) { + for (const [key, type, value] of [['gstin', 'text', '33AAAAA0000A1Z5'], ['seal', 'image', 'seals/agency_seal.png'], ['logo', 'image', 'seals/agency_image.jpg']]) { assert((await context.request.post(base + '/pim-api/attrs', { multipart: { org: 'BROWSER11', key, type, value } })).ok()); } await identity('asha', 'clerks'); @@ -28,6 +28,7 @@ try { { type: 'pim_text', page: 1, ref: 'gstin', prefix: 'GSTIN: ', coords: [120, 150, 520, 180], font: 'fonts/DejaVuSans.ttf' }, { type: 'signature_zone', page: 1, party: 'Manager', coords: [120, 550, 500, 700], min_w: 50, min_h: 20 }, { type: 'pim_image', page: 2, ref: 'seal', shape: 'circle', coords: [300, 1100, 90] }, + { type: 'pim_image', page: 2, ref: 'logo', shape: 'rect', coords: [120, 1250, 320, 1350] }, { type: 'signature_zone', page: 2, party: 'Partner', coords: [400, 1000, 850, 1200], min_w: 70, min_h: 25 }, ] } }; assert((await context.request.post(base + `/api/docs/${id}/save`, { multipart: { json: JSON.stringify(layout) } })).ok());
diff --git a/test/snapshot-contract.sh b/test/snapshot-contract.sh @@ -9,10 +9,12 @@ SERIES=S12_$(date +%s) FONT=/var/www/dam/fonts/DejaVuSans.ttf EXPLICIT=/var/www/dam/fonts/snapshot12.ttf SEAL=/var/www/dam/seals/snapshot12.png +JPEG=/var/www/dam/seals/snapshot12.jpg TMP=$(mktemp -d /tmp/snapshot-contract.XXXXXX) chmod 0755 "$TMP" cp "$FONT" "$TMP/font.ttf" cp /src/test/fixtures/seal.png "$SEAL" +cp /src/test/fixtures/image.jpg "$JPEG" cp "$FONT" "$EXPLICIT" mkdir "$TMP/bin" touch "$TMP/qpdf-calls" @@ -31,7 +33,7 @@ start() { PATH="$TMP/bin:$PATH" su-exec signetd:signet /usr/local/sbin/signetd > cleanup() { sql -c 'DROP TRIGGER IF EXISTS snapshot_fail ON documents; DROP FUNCTION IF EXISTS snapshot_fail(); DROP TRIGGER IF EXISTS snapshot_complete ON documents; DROP FUNCTION IF EXISTS snapshot_complete();' >/dev/null 2>&1 || true cp "$TMP/font.ttf" "$FONT" - rm -f "$TMP/fail-qpdf" "$EXPLICIT" "$SEAL" /var/www/dam/seals/snapshot12-link.png /var/www/dam/seals/snapshot12-large.png + rm -f "$TMP/fail-qpdf" "$EXPLICIT" "$SEAL" "$JPEG" /var/www/dam/seals/snapshot12-link.png /var/www/dam/seals/snapshot12-large.png stop su-exec signetd:signet /usr/local/sbin/signetd >>/tmp/snapshot-worker.log 2>&1 & } @@ -77,9 +79,10 @@ new_doc() { stop redis-cli DEL "$Q" "$Q:processing" >/dev/null redis-cli HSET "$ORG:metadata" gstin BEFORE_SUBMIT >/dev/null -redis-cli HSET "$ORG:images" seal seals/snapshot12.png >/dev/null +redis-cli HSET "$ORG:images" seal seals/snapshot12.png logo seals/snapshot12.jpg >/dev/null as root signet-admins -H "$X" -F "code=$SERIES" --form-string "pattern=$SERIES/{seq:02}" "$B/api/series" >/dev/null LAYOUT=$(jq -nc --arg org "$ORG" --arg series "$SERIES" '{title:"Frozen revision",org_code:$org,series_code:$series,route:{parties:[{name:"Manager",signer:"manager"},{name:"Audit",signer:"auditor"},{name:"Partner",signer:"ceo"}]},layout:{reference_width:1000,reference_height:1414,imprints:[{type:"pim_text",page:1,ref:"gstin",value:"FORGED_CLIENT_VALUE",font:"fonts/snapshot12.ttf",coords:[120,150,600,180]},{type:"pim_image",page:2,ref:"seal",shape:"circle",coords:[250,1050,90]},{type:"signature_zone",page:1,party:"Manager",coords:[120,550,500,700],min_w:50,min_h:20},{type:"signature_zone",page:2,party:"Partner",coords:[400,1000,850,1200],min_w:70,min_h:25}]}}') +LAYOUT=$(printf '%s' "$LAYOUT" | jq -c '.layout.imprints += [{type:"pim_image",page:2,ref:"logo",shape:"rect",coords:[120,1200,320,1300]}]') PL1='{"page":1,"coords":[120,550,500,700],"ref_w":1000,"ref_h":1414}' PL2='{"page":2,"coords":[400,1000,850,1200],"ref_w":1000,"ref_h":1414}' new_doc @@ -137,6 +140,7 @@ echo 'ok - submit freezes server-only text/assets; unsafe/oversized inputs and # Change all live inputs before the worker runs, then force a real render failure. redis-cli HSET "$ORG:metadata" gstin AFTER_SUBMIT >/dev/null +rm "$JPEG" cp /src/test/fixtures/sig.png "$SEAL" cp /usr/share/fonts/dejavu/DejaVuSansMono.ttf "$EXPLICIT" cp /usr/share/fonts/dejavu/DejaVuSansMono.ttf "$FONT" @@ -153,6 +157,11 @@ cmp "$BASE/proof.pdf" "$BASE/stamped.pdf" || fail 'proof and initial stamped bod body_has "$BASE/proof.pdf" BEFORE_SUBMIT pdftotext "$BASE/proof.pdf" - | grep -q FORGED_CLIENT_VALUE && fail 'client forged content' || true fonts_match "$BASE/proof.pdf" "$TMP/font.ttf" +pdfimages -j "$BASE/proof.pdf" "$TMP/jpeg" +for image in "$TMP"/jpeg-*.jpg; do + [ -f "$image" ] || fail 'frozen JPEG did not survive opaque naming' + cmp "$image" /src/test/fixtures/image.jpg || fail 'frozen JPEG bytes changed' +done decide manager signoff --form-string "placement=$PL1" >/dev/null wait_ready body_has "$BASE/stamped.pdf" BEFORE_SUBMIT @@ -163,15 +172,16 @@ decide auditor correction --form-string 'comment=Snapshot correction' >/dev/null cp /usr/share/fonts/dejavu/DejaVuSansMono.ttf "$FONT" cp "$FONT" "$EXPLICIT" cp /src/test/fixtures/sig.png "$SEAL" +cp /src/test/fixtures/image.jpg "$JPEG" redis-cli HSET "$ORG:metadata" gstin NEW_REVISION >/dev/null -redis-cli HSET "$ORG:images" seal seals/snapshot12.png >/dev/null +redis-cli HSET "$ORG:images" seal seals/snapshot12.png logo seals/snapshot12.jpg >/dev/null stop submit >/dev/null NEWKEY=$(sql -c "SELECT snapshot_id FROM documents WHERE id='$ID'") [ "$KEY" != "$NEWKEY" ] && [ -d "$SNAP" ] || fail 'revision snapshot not isolated/retained' jq -e '.revision==1 and .org_code=="SNAPSHOT12" and .layout.imprints[0].value=="BEFORE_SUBMIT"' "$SNAP/manifest.json" >/dev/null || fail 'previous revision resolved metadata was lost' get | jq -e --arg serial "$SERIAL" --arg date "$DATE" '.revision==2 and .serial==$serial and .doc_date==$date and .current_party==1' >/dev/null || fail 'revision changed numbering' -rm "$FONT" "$EXPLICIT" "$SEAL" +rm "$FONT" "$EXPLICIT" "$SEAL" "$JPEG" redis-cli HSET "$ORG:metadata" gstin CHANGED_AFTER_RESUBMIT >/dev/null start wait_ready @@ -195,8 +205,9 @@ echo 'ok - correction creates fresh frozen inputs with stable serial/date; rel cp "$TMP/font.ttf" "$FONT" cp "$FONT" "$EXPLICIT" cp /src/test/fixtures/seal.png "$SEAL" +cp /src/test/fixtures/image.jpg "$JPEG" redis-cli HSET "$ORG:metadata" gstin DAMAGE_TEST >/dev/null -redis-cli HSET "$ORG:images" seal seals/snapshot12.png >/dev/null +redis-cli HSET "$ORG:images" seal seals/snapshot12.png logo seals/snapshot12.jpg >/dev/null stop new_doc submit >/dev/null @@ -211,7 +222,7 @@ echo "$D" | jq -e '.render_error|contains("live PIM/DAM fallback is forbidden")' cp "$TMP/frozen-original" "$SNAP/asset-0" chown signet:signet "$SNAP/asset-0" chmod 0440 "$SNAP/asset-0" -rm "$FONT" "$EXPLICIT" "$SEAL" +rm "$FONT" "$EXPLICIT" "$SEAL" "$JPEG" sql <<SQL >/dev/null CREATE FUNCTION snapshot_complete() RETURNS trigger LANGUAGE plpgsql AS \$\$ BEGIN IF NEW.id='$ID' AND NEW.rendered_seq>OLD.rendered_seq THEN RAISE EXCEPTION 'snapshot completion replay $ID'; END IF; RETURN NEW; END \$\$;
: asapien/signet