The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Community: the cover of a harness reports hid is not served (#1863)
0xken15f8ff04041002
diff --git a/backend/src/routes/community.test.ts b/backend/src/routes/community.test.tsindex 26f39ae5a..963da794b 100644--- a/backend/src/routes/community.test.ts+++ b/backend/src/routes/community.test.ts@@ -545,6 +545,21 @@ describe('persistent social actions', () => {expect((await call('GET', 'harnesses?mine=true', 'alice')).json().data.harnesses).toHaveLength(1)expect((await report('bob', 'starter-orbit')).statusCode).toBe(404)})+ // #1026: a harness hidden by reports (a sexual or violent cover) was 404 everywhere but its cover, served for a day.+ it('cover of a report-hidden harness is 404', async () => {+ const bytes = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10, 0, 0])+ const id = await publish('alice', { ...sample, cover: `data:image/png;base64,${bytes.toString('base64')}` } as typeof sample)+ expect((await call('GET', `harnesses/${id}/cover`)).statusCode).toBe(200)+ for (const token of ['bob', 'carol', 'dave']) await call('POST', 'reports', token, { targetType: 'harness', targetId: id, reason: 'other' })+ expect((await call('GET', `harnesses/${id}`)).statusCode).toBe(404)+ // An <img> sends no environment header: the hidden row is found in the publication's own environment.+ expect((await call('GET', `harnesses/${id}/cover`, undefined, undefined, 'stag')).statusCode).toBe(404)+ expect((await call('GET', `harnesses/${id}/cover`, 'bob')).statusCode).toBe(404)+ // Its author still has it, as they still have its page; a reviewer's restore brings it back for everyone.+ expect((await call('GET', `harnesses/${id}/cover`, 'alice')).statusCode).toBe(200)+ await call('POST', 'reports/review', 'admin', { targetType: 'harness', targetId: id, decision: 'restore' })+ expect((await call('GET', `harnesses/${id}/cover`)).statusCode).toBe(200)+ })it('lets a reviewer see reports and restore or remove what they hid', async () => {const id = await publish('alice', { ...sample, title: 'Reported' })const comment = (await call('POST', `harnesses/${id}/comments`, 'bob', { body: 'Buy now', clientId: crypto.randomUUID() })).json().data.commentdiff --git a/backend/src/routes/community.ts b/backend/src/routes/community.tsindex f93207b03..e615c57ea 100644--- a/backend/src/routes/community.ts+++ b/backend/src/routes/community.ts@@ -232,8 +232,11 @@ export async function communityRoutes(app: FastifyInstance): Promise<void> {// Read by an <img>, which sends no environment header: a publication id is a UUID, unique across both.app.get<{ Params: z.infer<typeof params> }>('/api/community/harnesses/:id/cover', { preHandler: validateParams(params) }, async (req, reply) => {- const post = await prisma.communityHarness.findFirst({ where: { id: req.params.id, deletedAt: null }, select: { cover: true } })- const image = post?.cover ? coverImage(post.cover) : null+ const post = await prisma.communityHarness.findFirst({ where: { id: req.params.id, deletedAt: null }, select: { cover: true, autonomousEnv: true, authorId: true } })+ // A harness reports hid is hidden here too, as on its page (#1026: a hidden cover was still served); its author still+ // has it. The hidden row is the publication's own environment's, since an <img> names none.+ const hidden = post && post.authorId !== req.user?.sub && await isHiddenFrom(post.autonomousEnv, 'harness', req.params.id)+ const image = post?.cover && !hidden ? coverImage(post.cover) : nullif (!image) return sendError(reply, 'This cover is unavailable.', 'NOT_FOUND', 404)reply.header('Content-Type', image.type).header('X-Content-Type-Options', 'nosniff').send(image.bytes)})