Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ body:
attributes:
label: ALPR Community version
description: Find this under Settings → Release. Include the source revision there when reporting an installation or update problem.
placeholder: v0.1.60
placeholder: v0.1.61
validations:
required: true

Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.1.61 — 2026-11-02

- Return HTTP 404 for Home Assistant display image IDs outside the supported PostgreSQL integer range. Reject these IDs before querying images, avoiding the previous HTTP 503 response.
- Preserve display authentication, camera scope, expiration, revocation and read-only restrictions. Add integer-boundary unit, PostgreSQL and production-browser regression checks.
- Update User Guide 3.29 and current release/install/update guidance. This patch adds no database migrations; existing installations use the normal updater.

## 0.1.60 — 2026-11-02

- Track ordered SQL migrations with verified checksums and legacy completion markers. Preserve the single-file updater entry point, atomic application, count validation and rollback. Completed cleanups no longer replay; Blue Iris v2 events remain visible and preserved.
Expand Down
6 changes: 6 additions & 0 deletions docs/HOME_ASSISTANT.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ The legacy **Enable Whitelist** and IP login-bypass controls are retired. Old
configuration values are retained for compatibility but grant no access. The
obsolete verifier endpoint returns HTTP 410 to authenticated callers.

From v0.1.61, an authenticated display image request with an out-of-range image
ID returns HTTP 404 without querying images. Missing images, reads outside the
camera scope, and reads older than 24 hours also return 404. Missing, expired,
revoked or invalid credentials still return 401. An unavailable image does not
prevent the display from listing the read or refreshing other images.

## Verification

`test/home-assistant-display.test.mjs` checks credential isolation and policy
Expand Down
2 changes: 1 addition & 1 deletion docs/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Clone the canonical repository and detach at the exact stable release tag:
```bash
git clone https://github.com/prsmith777/ALPR-Database-Community.git
cd ALPR-Database-Community
git checkout --detach v0.1.60
git checkout --detach v0.1.61
./alpr-community install
```

Expand Down
12 changes: 9 additions & 3 deletions docs/UPDATES.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ shown on the GitHub Releases page, rather than deploying moving `main`:
```bash
git clone https://github.com/prsmith777/ALPR-Database-Community.git
cd ALPR-Database-Community
git checkout --detach v0.1.60
git checkout --detach v0.1.61
./alpr-community install
```

Expand Down Expand Up @@ -88,7 +88,7 @@ alpr_native_update() (
set -Eeuo pipefail
download_dir="$(mktemp -d /tmp/alpr-maintenance-download.XXXXXX)"
trap 'rm -rf -- "$download_dir"' EXIT
asset_base="https://github.com/prsmith777/ALPR-Database-Community/releases/download/v0.1.60"
asset_base="https://github.com/prsmith777/ALPR-Database-Community/releases/download/v0.1.61"
curl -fLsS --retry 3 "$asset_base/community-maintenance.sh" -o "$download_dir/community-maintenance.sh"
curl -fLsS --retry 3 "$asset_base/community-maintenance.sh.sha256" -o "$download_dir/community-maintenance.sh.sha256"
(cd "$download_dir" && sha256sum --check --strict community-maintenance.sh.sha256)
Expand All @@ -99,7 +99,7 @@ unset -f alpr_native_update
```

The launcher verifies the canonical repository and exact released tag, loads the
fixed tools outside your checkout, and asks for **INSTALL v0.1.60**. It uses the
fixed tools outside your checkout, and asks for **INSTALL v0.1.61**. It uses the
same guarded backup/install workflow and does not reset or reinstall your system.
It temporarily stops only this installation's matching per-user systemd update
agent, then restarts it with the installed code. Keep the terminal open and do
Expand Down Expand Up @@ -372,6 +372,12 @@ ALPR_UPDATE_CLEANUP=ALPR_UPDATE_CLEANUP
These acknowledgements prevent an unattended typo from installing, accepting,
rolling back, or deleting rollback assets. They are not passwords.

## v0.1.61: Home Assistant image validation

Use the normal update workflow. Oversized display image IDs now return HTTP 404
instead of HTTP 503. Existing display links continue to use their saved camera
scope, expiration and revocation settings. This patch adds no database migrations.

## v0.1.60: tracked migration transition

Existing installations use the normal Windows or Linux update workflow. A direct
Expand Down
4 changes: 2 additions & 2 deletions lib/help-manual.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const HELP_MANUAL = Object.freeze({
title: "ALPR Database Community User Guide",
shortTitle: "User Guide",
description: "A practical guide to using, configuring, and safely administering the portable Community application.",
manualVersion: "3.28",
manualVersion: "3.29",
updatedAt: "November 2, 2026",
coverageBaseline: "Published clean-history Community release with portable configuration and no private deployment controls.",
filename: "ALPR-Database-Community-User-Guide.pdf",
Expand Down Expand Up @@ -560,7 +560,7 @@ export const HELP_MANUAL = Object.freeze({
"Open Settings > Home Assistant. The legacy IP whitelist is retired and cannot bypass authentication.",
"Enter a display name and the exact Home Assistant origin, including http:// or https:// and the port. Dashboard paths and wildcards are not accepted.",
"Choose one camera or all cameras, then choose an expiration of 1 to 90 days. Create the link and copy it immediately into a Home Assistant webpage card. The credential is displayed once; keep it private.",
"The display shows up to 25 recent reads and their images from the last 24 hours. It cannot open settings, modify records, use normal application APIs or create an administrator session.",
"The display shows up to 25 recent reads and their images from the last 24 hours. A read can remain listed when its image is unavailable. The display cannot open settings, modify records, use normal application APIs or create an administrator session.",
"Use HTTPS for ALPR when Home Assistant uses HTTPS. Display credentials do not depend on third-party cookies. Access from an unapproved iframe origin is blocked.",
"Revoke a display to stop subsequent data and image requests. The display clears on its next refresh; information already viewed cannot be recalled. A normal browser still requires ALPR login.",
],
Expand Down
4 changes: 3 additions & 1 deletion lib/home-assistant-display.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ export class HomeAssistantDisplayService {
return { label: grant.label, reads: result.rows };
}
async imagePath(grant, readId) {
if (!/^[1-9]\d{0,9}$/.test(String(readId || ""))) return null;
// plate_reads.id is a PostgreSQL integer; reject overflow before binding it.
const value = String(readId ?? "");
if (!/^[1-9]\d{0,9}$/.test(value) || Number(value) > 2_147_483_647) return null;
const result = await this.pool.query(`SELECT COALESCE(vehicle_image_path,image_path) AS path
FROM public.plate_reads WHERE id = $1 AND ($2::text IS NULL OR camera_name = $2)
AND timestamp > CURRENT_TIMESTAMP - INTERVAL '24 hours'`, [readId, grant.cameraName]);
Expand Down
11 changes: 4 additions & 7 deletions lib/release-info.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ import builtReleaseMetadata from "./built-release-metadata.mjs";
import { HELP_MANUAL } from "./help-manual.mjs";

export const CURRENT_RELEASE_NOTES = Object.freeze({
title: "Reliable upgrades, Blue Iris setup and Home Assistant displays",
title: "Home Assistant display image validation",
publishedAt: "2026-11-02",
items: Object.freeze([
"Apply only pending database migrations, verify their checksums, and adopt existing completion markers without replaying historical cleanup.",
"Preserve Blue Iris v2 direction observations and expose them to current-direction queries while retaining backup, row-count validation and rollback.",
"Bind ALPR camera aliases to explicit Blue Iris recording short IDs, refresh camera inventory in setup, and use the saved binding in automatic vehicle processing.",
"Show separate Blue Iris alert and ALPR read tolerances and require an explicit image owner when several ALPR reads match.",
"Create revocable, expiring, camera-scoped read-only Home Assistant display links with exact parent-origin restrictions; retire the inactive IP login-bypass controls.",
"Update User Guide 3.28, release and installation guidance. Existing installations use their normal update workflow without manual SQL or an intermediate release.",
"Return HTTP 404 for oversized Home Assistant display image IDs before querying images, replacing the previous HTTP 503 response.",
"Preserve read-only display access, camera scope, expiration, revocation and exact parent-origin restrictions.",
"Add integer-boundary unit, PostgreSQL and production-browser regression coverage; update User Guide 3.29. This patch adds no database migrations and uses the normal update workflow.",
]),
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blueiris-alpr-database",
"version": "0.1.60",
"version": "0.1.61",
"private": true,
"engines": {
"node": ">=24.0.0 <25"
Expand Down
5 changes: 5 additions & 0 deletions scripts/test-community-browser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ export async function exerciseBrowser(config) {
assert.notEqual(shell.headers.get("x-frame-options"),"DENY");
assert.ok(shell.headers.get("content-security-policy").includes(`frame-ancestors ${parentOrigin};`));
assert.equal((await fetch(origin+`/api/home-assistant/display/${grant.id}`)).status,401);
for (const readId of ["2147483648", "9999999999"]) {
const missing = await fetch(origin+`/api/home-assistant/display/${grant.id}/image/${readId}`,{headers:{Authorization:"Bearer "+grant.token}});
assert.equal(missing.status,404,"Out-of-range display image IDs are unavailable, not server errors");
assert.equal(missing.headers.get("cache-control"),"no-store, private");
}
assert.equal((await fetch(origin+"/api/current-access",{headers:{Authorization:"Bearer "+grant.token}})).status,401);
const normal=await fetch(origin+"/login");assert.equal(normal.headers.get("x-frame-options"),"DENY");
browser=await chromium.launch({executablePath,headless:true});
Expand Down
5 changes: 5 additions & 0 deletions scripts/test-community-bugfixes-postgres.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ export async function exerciseCommunityBugfixes(server, { browserTest } = {}) {
assert.equal(await displays.imagePath(auth,other.id),null);
const handler = createDisplayReadHandler({service:displays,readImage:async()=>Buffer.from("fixture-image")});
assert.equal((await handler(new Request("http://fixture",{headers:{authorization:"Bearer "+grant.token}}),{params:{grantId:grant.id,readId:read.id}})).status,200);
for (const readId of ["2147483647", "2147483648", "9999999999"]) {
const missing = await handler(new Request("http://fixture",{headers:{authorization:"Bearer "+grant.token}}),{params:{grantId:grant.id,readId}});
assert.equal(missing.status,404,"Unknown or out-of-range image ID: "+readId);
assert.equal(missing.headers.get("cache-control"),"no-store, private");
}
await displays.revoke(grant.id);
assert.equal(await displays.authorize(grant.id,"Bearer "+grant.token),null);
assert.equal(await displays.publicGrant(grant.id),null);
Expand Down
2 changes: 1 addition & 1 deletion test/help-manual.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function source(path) {
}

test("the user guide is structured, searchable, and role-aware", () => {
assert.equal(HELP_MANUAL.manualVersion, "3.28");
assert.equal(HELP_MANUAL.manualVersion, "3.29");
assert.ok(HELP_MANUAL.sections.length >= 24);

const ids = HELP_MANUAL.sections.map((section) => section.id);
Expand Down
21 changes: 21 additions & 0 deletions test/home-assistant-display.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,24 @@ test("unauthorized image requests never read storage or execute the data query",
const handler = createDisplayReadHandler({service:{authorize:async()=>null, imagePath:()=>assert.fail("unexpected data access")},readImage:()=>assert.fail("unexpected storage access")});
assert.equal((await handler(new Request("http://alpr.invalid"),{params:{grantId:id,readId:"1"}})).status,401);
});

test("oversized display image IDs return 404 without querying images or storage", async () => {
const service = new HomeAssistantDisplayService({ query: async () => assert.fail("Invalid image IDs must not reach PostgreSQL") });
service.authorize = async () => ({ id, label: "Display", cameraName: "Camera" });
const handler = createDisplayReadHandler({ service, readImage: async () => assert.fail("Invalid image IDs must not read storage") });
for (const readId of ["2147483648", "9999999999", "99999999999999999999"]) {
const response = await handler(new Request("http://alpr.invalid"), { params: { grantId: id, readId } });
assert.equal(response.status, 404, readId);
assert.equal(response.headers.get("cache-control"), "no-store, private");
assert.equal((await response.arrayBuffer()).byteLength, 0);
}
});

test("display image lookup accepts the positive PostgreSQL integer boundary", async () => {
const calls = [];
const service = new HomeAssistantDisplayService({ query: async (_sql, values) => { calls.push(values); return { rows: [] }; } });
const grant = { cameraName: "Camera" };
assert.equal(await service.imagePath(grant, "2147483647"), null);
assert.equal(await service.imagePath(grant, "1"), null);
assert.deepEqual(calls, [["2147483647", "Camera"], ["1", "Camera"]]);
});
21 changes: 10 additions & 11 deletions test/release-info.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,28 @@ test("release information resolves a commit-pinned deployment image", () => {
ALPR_RELEASE_CHANNEL: "staging",
});

assert.equal(release.version, "0.1.60");
assert.equal(release.manualVersion, "3.28");
assert.equal(release.version, "0.1.61");
assert.equal(release.manualVersion, "3.29");
assert.equal(release.manualUpdatedAt, "November 2, 2026");
assert.equal(release.gitSha, "8cd2fa8");
assert.equal(release.channel, "staging");
assert.equal(release.source, "commit-pinned image");
assert.equal(release.readOnly, true);
assert.equal(
release.notes.title,
"Reliable upgrades, Blue Iris setup and Home Assistant displays"
"Home Assistant display image validation"
);
assert.equal(release.notes.publishedAt, "2026-11-02");
assert.ok(release.notes.items.length >= 3);
const notes = release.notes.items.join(" ");
assert.match(notes, /pending database migrations/);
assert.match(notes, /checksums/);
assert.match(notes, /Blue Iris v2 direction observations/);
assert.match(notes, /row-count validation and rollback/);
assert.match(notes, /recording short IDs/);
assert.match(notes, /explicit image owner/);
assert.match(notes, /read-only Home Assistant/);
assert.match(notes, /HTTP 404/);
assert.match(notes, /oversized Home Assistant display image IDs/);
assert.match(notes, /before querying images/);
assert.match(notes, /read-only display access/);
assert.match(notes, /camera scope, expiration, revocation/);
assert.match(notes, /parent-origin restrictions/);
assert.match(notes, /User Guide 3\.28/);
assert.match(notes, /no database migrations/);
assert.match(notes, /User Guide 3\.29/);

});

Expand Down
Loading