Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: validate appId parameter in JIRA report endpoints (#9607)

Adam Eivycca846c0f89f
diff --git a/server/routes/jira.js b/server/routes/jira.js
index cbfff103b1..4628d3dacf 100644
--- a/server/routes/jira.js
+++ b/server/routes/jira.js
@@ -59,11 +59,17 @@ const nonEmptyStringList = z.array(z.string().min(1)).min(1);
const jiraLabelsSchema = z.object({ labels: nonEmptyStringList });
const jiraSprintIssuesSchema = z.object({ issueKeys: nonEmptyStringList });
+const appIdSchema = z.string().regex(/^[A-Za-z0-9._-]+$/, 'appId contains invalid characters');
+
const reportParamsSchema = z.object({
- appId: z.string().regex(/^[A-Za-z0-9._-]+$/, 'appId contains invalid characters'),
+ appId: appIdSchema,
date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, 'date must be YYYY-MM-DD')
});
+const generateReportSchema = z.object({
+ appId: appIdSchema.optional()
+});
+
const router = express.Router();
router.param('ticketId', validateTicketParam);
router.param('issueKey', validateTicketParam);
@@ -397,7 +403,7 @@ router.get('/reports', asyncHandler(async (req, res) => {
* Generate status report for a specific app or all JIRA-enabled apps
*/
router.post('/reports/generate', asyncHandler(async (req, res) => {
- const { appId } = req.body;
+ const { appId } = validateRequest(generateReportSchema, req.body);
if (appId) {
const app = await getAppById(appId);
@@ -420,7 +426,8 @@ router.post('/reports/generate', asyncHandler(async (req, res) => {
* Get the latest report for an app
*/
router.get('/reports/:appId/latest', asyncHandler(async (req, res) => {
- const report = await jiraReports.getLatestReport(req.params.appId);
+ const { appId } = validateRequest(z.object({ appId: appIdSchema }), req.params);
+ const report = await jiraReports.getLatestReport(appId);
if (!report) {
throw new ServerError('No reports found for this app', { status: 404, code: 'NOT_FOUND' });
}
diff --git a/server/routes/jira.test.js b/server/routes/jira.test.js
index d1c12bb2a8..a90a6920c4 100644
--- a/server/routes/jira.test.js
+++ b/server/routes/jira.test.js
@@ -84,6 +84,73 @@ describe('GET /reports/:appId/:date', () => {
});
});
+describe('GET /reports/:appId/latest', () => {
+ beforeEach(() => vi.clearAllMocks());
+
+ it('rejects invalid appId characters with 400 VALIDATION_ERROR', async () => {
+ const response = await request(makeApp()).get('/api/jira/reports/bad@app/latest');
+
+ expect(response.status).toBe(400);
+ expect(response.body.code).toBe('VALIDATION_ERROR');
+ expect(jiraReports.getLatestReport).not.toHaveBeenCalled();
+ });
+
+ it('rejects appId with spaces and special characters', async () => {
+ const response = await request(makeApp()).get('/api/jira/reports/bad%20app/latest');
+
+ expect(response.status).toBe(400);
+ expect(response.body.code).toBe('VALIDATION_ERROR');
+ expect(jiraReports.getLatestReport).not.toHaveBeenCalled();
+ });
+
+ it('accepts valid appId with alphanumeric, dot, underscore, and dash', async () => {
+ jiraReports.getLatestReport.mockResolvedValue({ appId: 'valid-app.v2_0', date: '2026-01-01', status: 'ok' });
+
+ const response = await request(makeApp()).get('/api/jira/reports/valid-app.v2_0/latest');
+
+ expect(response.status).toBe(200);
+ expect(jiraReports.getLatestReport).toHaveBeenCalledWith('valid-app.v2_0');
+ });
+
+ it('returns 404 when no reports found', async () => {
+ jiraReports.getLatestReport.mockResolvedValue(null);
+
+ const response = await request(makeApp()).get('/api/jira/reports/example-app/latest');
+
+ expect(response.status).toBe(404);
+ expect(response.body.code).toBe('NOT_FOUND');
+ });
+});
+
+describe('POST /reports/generate', () => {
+ beforeEach(() => vi.clearAllMocks());
+
+ it('rejects invalid appId in request body', async () => {
+ const response = await request(makeApp()).post('/api/jira/reports/generate').send({ appId: 'bad@app' });
+
+ expect(response.status).toBe(400);
+ expect(response.body.code).toBe('VALIDATION_ERROR');
+ expect(jiraReports.generateReport).not.toHaveBeenCalled();
+ });
+
+ it('accepts empty appId to generate all reports', async () => {
+ jiraReports.generateAllReports.mockResolvedValue([{ appId: 'app1' }, { appId: 'app2' }]);
+
+ const response = await request(makeApp()).post('/api/jira/reports/generate').send({});
+
+ expect(response.status).toBe(200);
+ expect(jiraReports.generateAllReports).toHaveBeenCalled();
+ });
+
+ it('rejects non-string appId values', async () => {
+ const response = await request(makeApp()).post('/api/jira/reports/generate').send({ appId: 123 });
+
+ expect(response.status).toBe(400);
+ expect(response.body.code).toBe('VALIDATION_ERROR');
+ expect(jiraReports.generateReport).not.toHaveBeenCalled();
+ });
+});
+
describe('GET /instances/:instanceId/my-sprint-tickets/:projectKey', () => {
let app;
beforeEach(() => {