Skip to content

Commit 24a0de6

Browse files
committed
Add permit_subreports config option
1 parent 43ab340 commit 24a0de6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

schemas/qwc-document-service.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
"type": "string",
3333
"default": "/reports"
3434
},
35+
"permit_subreports": {
36+
"description": "Whether to automatically permit subreports included from a permitted parent report",
37+
"type": "boolean",
38+
"default": false
39+
},
3540
"max_memory": {
3641
"description": "Maximum Java heap size for compiling like 1024M or 2G.",
3742
"type": "string",

src/report_compiler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def compile_report(self, report_filename, fill_params, tmpdir, resources, permit
260260
self.logger.info("Subreport filename %s" % subreport_filename)
261261
self.logger.info("Subreport template %s" % subreport_template)
262262
if os.path.exists(subreport_filename):
263-
if subreport_template in permitted_resources:
263+
if self.permit_subreports or subreport_template in permitted_resources:
264264
subreport_result = self.compile_report(subreport_filename, fill_params, tmpdir, resources, permitted_resources, single_report, True)
265265
if not subreport_result:
266266
self.logger.info("Failed to compile subreport %s" % subreport_filename)
@@ -274,7 +274,7 @@ def compile_report(self, report_filename, fill_params, tmpdir, resources, permit
274274
if m:
275275
fill_params[m.group(1)] = self.resolve_datasource(subreport_datasource, subreport_filename, opened_connections)
276276
else:
277-
self.logger.info("Filtering out unpermitted report %s" % subreport_filename)
277+
self.logger.info("Filtering out unpermitted subreport %s" % subreport_filename)
278278
subreportExpression.text = ""
279279

280280
# Write modified jrxml
@@ -377,6 +377,7 @@ def get_document(self, config, permitted_resources, tenant, template, fill_param
377377
resources = (config.resources() or {}).get('document_templates', [])
378378

379379
self.report_dir = config.get('report_dir', '/reports').rstrip('/')
380+
self.permit_subreports = config.get('permit_subreports', False)
380381
self.logger.info("Report dir is '%s'", self.report_dir)
381382

382383
if template not in permitted_resources:

0 commit comments

Comments
 (0)